sasoptpy.actions.fix

fix(*args)[source]

Fixes values of variables to the specified values

Parameters
argssasoptpy.Variable, float, sasoptpy.Expression, tuple

Set of arguments to be fixed

Arguments get paired (if not given in tuples) to allow several fix operations

Examples

Regular fix statement:

>>> with so.Workspace('w') as w:
>>>     x = so.Variable(name='x')
>>>     fix(x, 1)
>>>     solve()
>>>     unfix(x)
>>> print(so.to_optmodel(w))
proc optmodel;
    var x;
    fix x=1;
    solve;
    unfix x;
quit;

Multiple fix-unfix:

>>> with so.Workspace('w') as w:
>>>     x = so.VariableGroup(4, name='x')
>>>     for i in cofor_loop(range(4)):
>>>         fix((x[0], i), (x[1], 1))
>>>         solve()
>>>         unfix(x[0], (x[1], 2))
>>> print(so.to_optmodel(w))
proc optmodel;
    var x {{0,1,2,3}};
    cofor {o7 in 0..3} do;
        fix x[0]=o7 x[1]=1;
        solve;
        unfix x[0] x[1]=2;
    end;
quit;