sasoptpy.Model.add_statement

Model.add_statement(self, statement, after_solve=None)[source]

Adds a PROC OPTMODEL statement to the model

Parameters
statementExpression or string

Statement object

after_solveboolean

Switch for appending the statement after the problem solution

Notes

  • If the statement string includes ‘print’, then the statement is automatically placed after the solve even if after_solve is False.

Examples

>>> I = m.add_set(name='I')
>>> x = m.add_variables(I, name='x', vartype=so.INT)
>>> a = m.add_parameter(I, name='a')
>>> c = m.add_constraints((x[i] <= 2 * a[i] for i in I), name='c')
>>> m.add_statement('print x;', after_solve=True)
>>> print(m.to_optmodel())
proc optmodel;
min m_obj = 0;
set I;
var x {I} integer >= 0;
num a {I};
con c {i_1 in I} : x[i_1] - 2.0 * a[i_1] <= 0;
solve;
print _var_.name _var_.lb _var_.ub _var_ _var_.rc;
print _con_.name _con_.body _con_.dual;
print x;
quit;