"""Maximize production value subject to two capacity limits."""

from alleria import solve_model


model = {
    "name": "production",
    "objective_sense": "maximize",
    "columns": [
        {
            "name": "x",
            "lower_bound": 0.0,
            "upper_bound": 10.0,
            "obj_coeff": 3.0,
            "col_type": "continuous",
        },
        {
            "name": "y",
            "lower_bound": 0.0,
            "upper_bound": 10.0,
            "obj_coeff": 2.0,
            "col_type": "continuous",
        },
    ],
    "constraints": [
        {
            "name": "capacity",
            "sense": "<=",
            "rhs": 4.0,
            "coeffs": [[0, 1.0], [1, 1.0]],
        },
        {
            "name": "x_limit",
            "sense": "<=",
            "rhs": 3.0,
            "coeffs": [[0, 1.0]],
        },
    ],
}

result = solve_model(
    model, backend="inprocess", preset="exact", include_primal=True
)
print(f"status: {result.status}")
if result.status != "optimal" or result.incumbent_primal is None:
    raise RuntimeError("This small example should have an optimal solution.")
print(f"objective: {result.objective:g}")
for name, value in zip(result.column_names, result.incumbent_primal):
    print(f"{name}: {value:g}")
