Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/FabianeloV/Metodo-simplex/llms.txt

Use this file to discover all available pages before exploring further.

The /api/v1/binary/solve endpoint solves Binary Integer Programming (BIP) problems where every decision variable is constrained to be either 0 or 1. The solver uses Branch & Bound, relaxing the integrality constraints at each node to an LP and branching on fractional variables until a provably optimal 0/1 solution is found or the problem is declared infeasible.

Request

POST /api/v1/binary/solve
Content-Type: application/json
objective
list[float]
required
Coefficients of the objective function, one per binary variable. Must contain between 2 and 5 elements. Variables are named x1, x2, …, x5 in order.Example: [3, 5] represents 3x1 + 5x2.
goal
string
required
Optimisation direction. Accepted values: "max" or "min".
constraints
list[Constraint]
required
At least one linear constraint. Every constraint must have the same number of coefficients as objective.

Response

A successful call returns a BinaryResponse object.
status
string
Outcome of the solve. One of:
  • "optimal" — a best 0/1 solution was found.
  • "infeasible" — no feasible 0/1 assignment satisfies all constraints.
  • "limit" — the node limit was reached before proving optimality.
objective_value
float | null
Optimal objective value. null when status is "infeasible".
variables
object | null
Map of variable names to their optimal binary values (0 or 1), e.g. {"x1": 1, "x2": 0}. null when status is "infeasible".
nodes_explored
integer
Total number of Branch & Bound nodes evaluated during the search.
nodes
list[BBNode]
Complete Branch & Bound exploration tree, one entry per node.
message
string
Human-readable status message describing the result.

Example

Maximize 3x1 + 5x2 subject to:
  • 2x1 + 4x2 ≤ 6
  • x1 + x2 ≤ 2
(A classic 2-variable 0/1 knapsack-style problem.)
curl -X POST https://api.example.com/api/v1/binary/solve \
  -H "Content-Type: application/json" \
  -d '{
    "objective": [3, 5],
    "goal": "max",
    "constraints": [
      {"coefficients": [2, 4], "inequality": "<=", "rhs": 6},
      {"coefficients": [1, 1], "inequality": "<=", "rhs": 2}
    ]
  }'
{
  "status": "optimal",
  "objective_value": 8.0,
  "variables": {
    "x1": 1,
    "x2": 1
  },
  "nodes_explored": 3,
  "nodes": [
    {
      "node_id": 0,
      "parent_id": null,
      "depth": 0,
      "fixed_vars": {},
      "lp_value": 8.5,
      "lp_vars": {"x1": 1.0, "x2": 0.875},
      "status": "branched",
      "branched_on": "x2",
      "edge_label": null
    },
    {
      "node_id": 1,
      "parent_id": 0,
      "depth": 1,
      "fixed_vars": {"x2": 0},
      "lp_value": 4.5,
      "lp_vars": {"x1": 1.0, "x2": 0.0},
      "status": "pruned_bound",
      "branched_on": null,
      "edge_label": "x2=0"
    },
    {
      "node_id": 2,
      "parent_id": 0,
      "depth": 1,
      "fixed_vars": {"x2": 1},
      "lp_value": 8.0,
      "lp_vars": {"x1": 1.0, "x2": 1.0},
      "status": "integer_feasible",
      "branched_on": null,
      "edge_label": "x2=1"
    }
  ],
  "message": "Optimal binary solution found"
}
The nodes array forms a directed tree. Reconstruct the tree by linking each node to its parent via parent_id. The root node always has parent_id: null and depth: 0.
All variables are implicitly restricted to {0, 1}. If the continuous LP relaxation at the root is already integer-feasible, the solver returns immediately without branching.

Health Check

GET /api/v1/binary/health Returns a liveness confirmation for the Binary Integer Programming service.
curl https://api.example.com/api/v1/binary/health
{
  "status": "ok",
  "service": "binary-optimizer-api"
}

Build docs developers (and LLMs) love