Solve an optimisation model
solveSolves a linear, quadratic or mixed-integer optimisation model and returns the solution state, the objective value and each variable's value by name. Give the model as text, in LP format unless 'format' says otherwise. For example: Maximize obj: 3 x + 5 y Subject To budget: x + y <= 10 Bounds 0 <= x <= 8 General x End A coefficient goes before its variable with a space, as in 3 x: there is no * for that, no division and no parentheses. Variables go on the left-hand side, and a single number on the right. Squares and products go together inside one pair of square brackets, each with its coefficient inside too, written as a single number: [ 0.5 x ^2 + 0.004 x * y + 3 y ^2 ], not 0.5 [ x ^2 ] or 2 * 0.002 x * y. A variable is 0 or more unless Bounds says otherwise; General makes it integer, Binary 0 or 1. What is not LP format is an error that names the line. A long solve reports progress, if asked for. OPTIMAL means proven optimal; FEASIBLE means a solution was found but not proven optimal, typically because a time limit was reached. The objective and the variables' values are given only with a solution, and 'note' explains any other state.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"model": "<model>"
},
"name": "solve"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes | The model, as text | |
| sense | No | Minimise or maximise. Overrides what the model says; LP and MPS models say it themselves, EBM ones do not | |
| format | No | LP (CPLEX LP format), MPS, or EBM (ojAlgo's own) | LP |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| note | No | What the state means, when it is not OPTIMAL | |
| state | Yes | OPTIMAL, DISTINCT (optimal and the only optimum), FEASIBLE, INFEASIBLE, UNBOUNDED, APPROXIMATE, FAILED, or another of ojAlgo's solution states | |
| optimal | Yes | ||
| feasible | Yes | ||
| objective | No | Absent unless there is a solution | |
| variables | No | Each variable's value, by name. Absent unless there is a solution |