Skip to main content

`mip-tool` is a package for Python-MIP.

Project description

MIP-Tool

MIP-Tool is a package for Python-MIP.

Installation

pip install mip-tool

Example

Non-convex piecewise linear constraint

import numpy as np
from mip import INF, Model, OptimizationStatus
from mip_tool import add_lines, show_model

m = Model()
x = m.add_var("x", lb=-INF)
y = m.add_var("y", obj=-1)
curve = np.array([[-2, 6], [-1, 7], [2, -2], [4, 5]])
add_lines(m, curve, x, y)
m.optimize()
assert m.status == OptimizationStatus.OPTIMAL
assert (x.x, y.x) == (-1, 7)
show_model(m)

Output

\Problem name: 

Minimize
OBJROW: - y
Subject To
constr(0):  - x + w_0 + w_1 + w_2 = 2
constr(1):  - y + w_0 -3 w_1 + 3.50000 w_2 = -6
constr(2):  - w_0 + z_0 <= -0
constr(3):  w_0 <= 1
constr(4):  - w_1 + 3 z_1 <= -0
constr(5):  - w_1 + 3 z_0 >= -0
constr(6):  - w_2 + 2 z_1 >= -0
Bounds
 x Free
 0 <= z_0 <= 1
 0 <= z_1 <= 1
Integers
z_0 z_1 
End

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

mip_tool-0.0.2-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page