Linear Programming Search¶
PulpSearch¶
Solver name is “Pulp”.
- class flopt.solvers.pulp_search.PulpSearch[source]¶
API for PuLP, linear programming modeling tool
- Parameters
solver (pulp.Solver) – solver pulp use, see https://coin-or.github.io/pulp/technical/solvers.html. default is pulp.PULP_CBC_CMD
Examples
import flopt # Variables a = flopt.Variable("a", lowBound=0, upBound=1, cat="Integer") b = flopt.Variable("b", lowBound=1, upBound=2, cat="Continuous") c = flopt.Variable("c", lowBound=-1, upBound=3, cat="Continuous") # Problem prob = flopt.Problem() prob += a + b + c + 2 prob += a + b >= 2 prob += b - c >= 3 prob.solve(solver="Pulp", msg=True)
When you use other solvers in pulp, for example GLPK solver, you set solver parameter in PulpSearch object.
solver = flopt.Solver("Pulp") import pulp glpk_solver = pulp.GLPK_CMD() solver.setParams(solver=glpk_solver) prob.solve(solver, msg=True)
ScipyMilpSearch¶
Solver name is “ScipyMilp”.
- class flopt.solvers.scipy_searches.ScipyMilpSearch[source]¶
Scipy optimize milp API Solver
Note
In scipy version 1.9.0, we can not obtain the incumbent solution from scipy.optimize.milp API, and can not use callback to this API for logging. Therefore, we can obtain the solution when only scipy.optimize.milp terminate the execution normally.
Examples
import flopt # Variables a = flopt.Variable("a", lowBound=0, upBound=1, cat="Integer") b = flopt.Variable("b", lowBound=1, upBound=2, cat="Continuous") c = flopt.Variable("c", lowBound=-1, upBound=3, cat="Continuous") # Problem prob = flopt.Problem() prob += a + b + c + 2 prob += a + b >= 2 prob += b - c >= 3 solver = flopt.Solver("ScipyMilp") prob.solve(solver, msg=True)
See also
scipy.optimize.milp