prob2struct
Convert an optimization problem to a solver structure.
📝Syntax
problem = prob2struct(prob)
📥Input Arguments
Parameter Description
prob optimization problem object.
📤Output Arguments
Parameter Description
problem structure with solver, objective, x0 and direct-solver fields when the problem can be lowered.
📄Description

prob2struct lowers supported problem-based models to the direct solver problem-structure form.

For linear objectives and linear constraints, the returned structure contains f, A, b, Aeq, beq, lb, ub and intcon. Variables are ordered by name to make the generated coefficient matrices deterministic.

For continuous quadratic objectives with linear constraints, prob2struct returns solver = 'quadprog' with H, f, linear constraints and bounds. Constant objective offsets are stored and are restored by solve.

💡Examples
x = optimvar('x');
prob = optimproblem('Objective', (x + 1)^2);
s = prob2struct(prob)
x = optimvar('x', 2, 1, 'LowerBound', 0);
prob = optimproblem;
prob.Objective = [3 4] * x;
prob.Constraints.balance = [1 2] * x == 5;
s = prob2struct(prob);
s.Aeq
y = optimvar('y', 2, 1);
prob = optimproblem('Objective', (y(1) - 1)^2 + (y(2) + 3)^2);
s = prob2struct(prob);
s.solver
🔗See Also
optimproblemsolvequadprog
Used Functions
optimproblem solve
📚Bibliography
J. Nocedal and S. J. Wright, Numerical Optimization, Springer, 2006.
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub