sasoptpy.actions.set_value

set_value(left, right)[source]

Creates an assignment statement

Parameters
leftsasoptpy.Expression

Any expression (variable or parameter)

rightsasoptpy.Expression or float

Right-hand-side expression

Examples

>>> with so.Workspace('ex_9_1_matirx_sqrt', session=None) as w:
>>>     so.LiteralStatement('call streaminit(1);')
>>>     n = so.Parameter(name='n', value=5)
>>>     rn = so.Set(name='RN', value=so.exp_range(1, n))
>>>     A = so.ParameterGroup(rn, rn, name='A', value="10-20*rand('UNIFORM')")
>>>     P = so.ParameterGroup(rn, rn, name='P')
>>>     for i in for_loop(rn):
>>>         for j in for_loop(so.exp_range(i, n)):
>>>             set_value(P[i, j], so.expr_sum(A[i, k] * A[j, k] for k in rn))
>>> print(so.to_optmodel(w))
proc optmodel;
    call streaminit(1);
    num n = 5;
    set RN = 1..n;
    num A {RN, RN} = 10-20*rand('UNIFORM');
    num P {RN, RN};
    for {o7 in RN} do;
        for {o10 in o7..n} do;
            P[o7, o10] = sum {k in RN} (A[o7, k] * A[o10, k]);
        end;
    end;
quit;