sasoptpy.actions.solve

solve(options=None, primalin=False)[source]

Solves the active optimization problem and generates results

Parameters
optionsdict, optional

Solver options

This dictionary can have several fields.

  • withstring

    Name of the solver, see possible values under Notes.

See Solver Options for a list of solver options. All fields in options (except with) is passed directly to the solver.

primalinbool, optional

When set to True, uses existing variable values as an initial point in MILP solver

Returns
sssasoptpy.abstract.statement.SolveStatement

Solve statement object.

Contents of the response can be retrieved using get_response function.

Notes

Possible solver names for with parameter:

  • lp : Linear programming

  • milp : Mixed integer linear programming

  • nlp : General nonlinear programming

  • qp : Quadratic programming

  • blackbox : Black-box optimization

SAS Optimization also has a constraint programming solver (clp), and network solver (network) but they are not currently supported by sasoptpy.

Examples

Regular solve:

>>> with so.Workspace('w') as w:
>>>     x = so.Variable(name='x', lb=1, ub=10)
>>>     o = so.Objective(2*x, sense=so.maximize, name='obj')
>>>     s = solve()
>>>     p = print_item(x)
>>> print(so.to_optmodel(w))
proc optmodel;
    var x >= 1 <= 10;
    max obj = 2 * x;
    solve;
    print x;
quit;

Option alternatives:

>>> with so.Workspace('w') as w:
>>>     # Problem declaration, etc..
>>>     solve()
>>>     solve(options={'with': 'milp'})
>>>     solve(options={'with': 'milp'}, primalin=True)
>>>     solve(options={'with': 'milp', 'presolver': None, 'feastol': 1e-6,
>>>                    'logfreq': 2, 'maxsols': 3, 'scale': 'automatic',
>>>                    'restarts': None, 'cutmir': 'aggressive'})
>>> print(so.to_optmodel(w))
proc optmodel;
    solve;
    solve with milp;
    solve with milp / primalin;
    solve with milp / presolver=None feastol=1e-06 logfreq=2 maxsols=3 scale=automatic restarts=None cutmir=aggressive;
quit;