flopt
latest

Contents:

  • Installation
  • Tutorial
  • Case Studies
  • Solvers
    • Solver Selector
    • Iterative Search
    • Swarm Intelligence Search
    • Baysian Search
    • Evolution Search
    • Quadratic Programming Search
    • Linear Programming Search
      • PulpSearch
        • PulpSearch
      • ScipyMilpSearch
        • ScipyMilpSearch
    • non-Linear Programming Search
    • Quantum Annealing Search
  • API Reference
  • Internal Reference
  • Recipes
flopt
  • Solvers
  • Linear Programming Search
  • Edit on GitHub

Linear Programming Search

PulpSearch

Solver name is “Pulp”.

https://img.shields.io/badge/Variable-Number-blue.svghttps://img.shields.io/badge/Objective-Linear-orange.svghttps://img.shields.io/badge/Constraints-Linear-green.svg
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”.

https://img.shields.io/badge/Variable-Number-blue.svghttps://img.shields.io/badge/Objective-Linear-orange.svghttps://img.shields.io/badge/Constraints-Linear-green.svg
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

Previous Next

© Copyright 2021, Nariaki Tateiwa. Revision ff418914.

Built with Sphinx using a theme provided by Read the Docs.