Linear programming
lp solve <json_model>
Description
Solve a linear (or mixed integer) program: status (optimal, infeasible, unbounded), objective, values of the variables, activity, slack and binding of each constraint; for a continuous program, the shadow price (dual value) of each constraint and the reduced cost of each variable
Solve a linear (or mixed integer) program: status (optimal, infeasible, unbounded), objective, values of the variables, activity, slack and binding of each constraint; for a continuous program, the shadow price (dual value) of each constraint and the reduced cost of each variable
Parameters
json_model: The model - String - required
json_model: The model - String - required
admin
lp solve "{\"maximize\": {\"doors\": 3, \"windows\": 5}, \"constraints\": [{\"name\": \"plant1\", \"doors\": 1, \"<=\": 4}, {\"name\": \"plant2\", \"windows\": 2, \"<=\": 12}, {\"name\": \"plant3\", \"doors\": 3, \"windows\": 2, \"<=\": 18}]}"
mentdb
{"status": "optimal", "objective": 36, "values": {"doors": 2, "windows": 6}, "constraints": [{"name": "plant1", "activity": 2, "limit": 4, "slack": 2, "binding": false, "shadow_price": 0}, {"name": "plant2", "activity": 12, "limit": 12, "slack": 0, "binding": true, "shadow_price": 1.5}, {"name": "plant3", "activity": 18, "limit": 18, "slack": 0, "binding": true, "shadow_price": 1}], "reduced_costs": {"doors": 0, "windows": 0}}
Knapsack (binary variables)
admin
lp solve "{\"maximize\": {\"i1\": 10, \"i2\": 13, \"i3\": 7, \"i4\": 8}, \"constraints\": [{\"name\": \"weight\", \"i1\": 5, \"i2\": 7, \"i3\": 3, \"i4\": 4, \"<=\": 12}], \"binary\": [\"i1\", \"i2\", \"i3\", \"i4\"]}"
mentdb
{"nodes": 1, "status": "optimal", "objective": 25, "values": {"i1": 1, "i2": 0, "i3": 1, "i4": 1}, "constraints": [{"name": "weight", "activity": 12, "limit": 12, "slack": 0, "binding": true}]}
Diet: minimum cost
admin
lp solve "{\"minimize\": {\"oats\": 0.3, \"milk\": 0.9, \"eggs\": 1.5}, \"constraints\": [{\"name\": \"protein\", \"oats\": 4, \"milk\": 8, \"eggs\": 13, \">=\": 50}, {\"name\": \"energy\", \"oats\": 110, \"milk\": 160, \"eggs\": 160, \">=\": 2000}], \"bounds\": {\"eggs\": [0, 2]}}"
mentdb
{"status": "optimal", "objective": 5.454545455, "values": {"oats": 18.181818182, "milk": 0, "eggs": 0}, "constraints": [{"name": "protein", "activity": 72.727272727, "limit": 50, "slack": 22.727272727, "binding": false, "shadow_price": 0}, {"name": "energy", "activity": 2000, "limit": 2000, "slack": 0, "binding": true, "shadow_price": 0.002727}], "reduced_costs": {"oats": 0, "milk": 0.463636, "eggs": 1.063636}}
lp solve <json_model> <json_params>
Description
Solve with parameters: max_nodes (branch and bound limit, 20000)
Solve with parameters: max_nodes (branch and bound limit, 20000)
Parameters
json_model: The model - String - required
json_params: The parameters - String - required
json_model: The model - String - required
json_params: The parameters - String - required
admin
lp solve "{\"maximize\": {\"a\": 5, \"b\": 4}, \"constraints\": [{\"a\": 6, \"b\": 4, \"<=\": 24}, {\"a\": 1, \"b\": 2, \"<=\": 6}], \"integer\": [\"a\", \"b\"]}" "{\"max_nodes\": 1000}"
mentdb
{"nodes": 5, "status": "optimal", "objective": 20, "values": {"a": 4, "b": 0}, "constraints": [{"name": "c1", "activity": 24, "limit": 24, "slack": 0, "binding": true}, {"name": "c2", "activity": 4, "limit": 6, "slack": 2, "binding": false}]}
lp assignment <json_costs>
Description
Assignment problem (Hungarian algorithm): one column (task) per row (agent) with the minimum total cost; rectangular matrices allowed
Assignment problem (Hungarian algorithm): one column (task) per row (agent) with the minimum total cost; rectangular matrices allowed
Parameters
json_costs: The cost matrix - String - required
json_costs: The cost matrix - String - required
admin
lp assignment "[[9, 2, 7, 8], [6, 4, 3, 7], [5, 8, 1, 8], [7, 6, 9, 4]]"
mentdb
{"total": 13, "assignment": [{"row": 0, "column": 1, "cost": 2}, {"row": 1, "column": 0, "cost": 6}, {"row": 2, "column": 2, "cost": 1}, {"row": 3, "column": 3, "cost": 4}]}
lp assignment <json_costs> <goal>
Description
Assignment with a goal: min (costs) or max (scores, profits)
Assignment with a goal: min (costs) or max (scores, profits)
Parameters
json_costs: The matrix - String - required
goal: min or max - String - required
json_costs: The matrix - String - required
goal: min or max - String - required
admin
lp assignment "[[9, 2, 7, 8], [6, 4, 3, 7], [5, 8, 1, 8], [7, 6, 9, 4]]" "max"
mentdb
{"total": 33, "assignment": [{"row": 0, "column": 0, "cost": 9}, {"row": 1, "column": 3, "cost": 7}, {"row": 2, "column": 1, "cost": 8}, {"row": 3, "column": 2, "cost": 9}]}
Used in use cases (1 recipe)
Operations researcher › Workshop: job shop schedule and assignment of the operators
Operations researcher › Workshop: job shop schedule and assignment of the operators
lp transport <json_supply> <json_demand> <json_costs>
Description
Transportation problem: supplies of the sources, demands of the destinations, unit costs; the flows of minimum total cost
Transportation problem: supplies of the sources, demands of the destinations, unit costs; the flows of minimum total cost
Parameters
json_supply: The supplies - String - required
json_demand: The demands - String - required
json_costs: The unit costs (sources x destinations) - String - required
json_supply: The supplies - String - required
json_demand: The demands - String - required
json_costs: The unit costs (sources x destinations) - String - required
admin
lp transport "[20, 30, 25]" "[10, 25, 15, 25]" "[[8, 6, 10, 9], [9, 12, 13, 7], [14, 9, 16, 5]]"
mentdb
{"status": "optimal", "total_cost": 585, "flows": [{"from": 0, "to": 1, "quantity": 20, "cost": 120}, {"from": 1, "to": 0, "quantity": 10, "cost": 90}, {"from": 1, "to": 2, "quantity": 15, "cost": 195}, {"from": 1, "to": 3, "quantity": 5, "cost": 35}, {"from": 2, "to": 1, "quantity": 5, "cost": 45}, {"from": 2, "to": 3, "quantity": 20, "cost": 100}]}
