problem = prob2struct(prob)
| Parameter | Description |
|---|---|
| prob | optimization problem object. |
| Parameter | Description |
|---|---|
| problem | structure with solver, objective, x0 and direct-solver fields when the problem can be lowered. |
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.
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
| Version | Description |
|---|---|
| 2.0.0 | initial version |