sasoptpy.actions.cofor_loop

cofor_loop(*args)[source]

Creates a cofor-loop to be executed on the server concurrently

Parameters
argssasoptpy.abstract.Set objects

Any number of sasoptpy.abstract.Set objects can be specified

Returns
set_iteratorsasoptpy.abstract.SetIterator, sasoptpy.abstract.SetIteratorGroup

Set iterators to be used inside cofor-loop

Notes

A cofor-loop runs its content concurrently. For tasks that depend on each other, consider using sasoptpy.actions.for_loop()

Examples

>>> with so.Workspace('w') as w:
>>>     x = so.VariableGroup(6, name='x', lb=0)
>>>     so.Objective(
>>>         so.expr_sum(x[i] for i in range(6)), name='z', sense=so.MIN)
>>>     a1 = so.Constraint(x[1] + x[2] + x[3] <= 4, name='a1')
>>>     for i in cofor_loop(so.exp_range(3, 6)):
>>>         fix(x[1], i)
>>>         solve()
>>>         put_item(i, x[1], so.Symbol('_solution_status_'), names=True)
>>> print(so.to_optmodel(w))
proc optmodel;
    var x {{0,1,2,3,4,5}} >= 0;
    min z = x[0] + x[1] + x[2] + x[3] + x[4] + x[5];
    con a1 : x[1] + x[2] + x[3] <= 4;
    cofor {o13 in 3..5} do;
        fix x[1]=o13;
        solve;
        put o13= x[1]= _solution_status_=;
    end;
quit;