Optimization Action Set

Tuning Multiple Problems by Using the Full Set of Parameters

This section contains PROC CAS code.

Note: Input data must be accessible in your CAS session, either as a CAS table or as a transient-scope table. A CAS table has a two-level name: the first level is your CAS engine libref, and the second level is the table name. You refer to this table in the CAS procedure by specifying only the second level. For more information about two-level names, see Chapter 3, Shared Concepts (SAS Optimization: Mathematical Optimization Procedures). A transient-scope table is called directly from the action and exists in memory for the duration of the action. For more information about accessing data, see SAS Viya: System Programming Guide. For more information about PROC CAS and programming in CASL, see SAS Cloud Analytic Services: CASL Programmer’s Guide and SAS Cloud Analytic Services: CASL Reference.

This example illustrates how to tune problems by using the full set of tuning parameters, how to set or overwrite the CAS input table’s objective sense, and how to output the CAS tables of primal and dual solutions of the best run that the tuner action found so far.

The following code calls the tuner action to tune the data tables air04 and air05 by using the full set of tuning parameters:

libname caslib cas;
filename air04 "path-to-air04.mps file";
filename air05 "path-to-air05.mps file";

%mps2sasd(mpsfile=air04, outdata=caslib.air04);
%mps2sasd(mpsfile=air05, outdata=caslib.air05);
proc cas;
loadactionset 'optimization';
tuner /
   instances={
      {data="air04", objSense='minimize'},
      {data="air05"}
   }
   milpParameters={maxtime=100, primalout='pout', dualout='dout'}
   tunerParameters={maxtime=400, nthreads=4, optionmode='full'}
;
run;
quit;
proc print data=caslib.pout(obs=15); run;
proc print data=caslib.dout(obs=15); run;

Output 2.17.1 and Output 2.17.2 show partial results of the CAS tables of primal and dual solutions. The output tables that are specified in the primalout and dualout subparameters are similar to those for the solveMilp action, except that they have an extra column that displays the name of each tuning problem.

Output 2.17.1: Primal Solution Output

Obs_PROBLEM__OBJ_ID__RHS_ID__VAR__TYPE__OBJCOEF__LBOUND__UBOUND__VALUE__SOL_
1AIR04COSTRHSCL000001B9710111
2AIR04COSTRHSCL000002B2030111
3AIR04COSTRHSCL000003B5300101
4AIR04COSTRHSCL000004B2710111
5AIR04COSTRHSCL000005B5660111
6AIR04COSTRHSCL000006B4770111
7AIR04COSTRHSCL000007B2680111
8AIR04COSTRHSCL000008B4210111
9AIR04COSTRHSCL000009B14910101
10AIR04COSTRHSCL000010B4100111
11AIR04COSTRHSCL000011B5660101
12AIR04COSTRHSCL000012B13860111
13AIR04COSTRHSCL000013B4240111
14AIR04COSTRHSCL000014B3500111
15AIR04COSTRHSCL000015B8390101


Output 2.17.2: Dual Solution Output

Obs_PROBLEM__OBJ_ID__RHS_ID__ROW__TYPE__RHS__L_RHS__U_RHS__ACTIVITY__SOL_
1AIR04COSTRHSRW000001E1..11
2AIR04COSTRHSRW000002E1..11
3AIR04COSTRHSRW000003E1..11
4AIR04COSTRHSRW000004E1..11
5AIR04COSTRHSRW000005E1..11
6AIR04COSTRHSRW000006E1..11
7AIR04COSTRHSRW000007E1..11
8AIR04COSTRHSRW000008E1..11
9AIR04COSTRHSRW000009E1..11
10AIR04COSTRHSRW000010E1..11
11AIR04COSTRHSRW000011E1..11
12AIR04COSTRHSRW000012E1..11
13AIR04COSTRHSRW000013E1..11
14AIR04COSTRHSRW000014E1..11
15AIR04COSTRHSRW000015E1..11


Tuning Multiple Problems by Using the Full Set of Parameters

This section contains Lua code for the analysis in the CASL version of this example, which contains details about the results.

Note: In order to run this code, the data that are described in the CASL version need to be loaded into CAS. One way to do this is to convert the example data to the comma-separated-value (CSV) files air04.csv and air05.csv and then use the following code to load the CSV files into CAS:

s:loadtable{casLib="casuser", path="air04.csv"}
s:loadtable{casLib="casuser", path="air05.csv"}

For more information about coding in Lua, see Getting Started with SAS Viya for Lua and SAS Viya: System Programming Guide.

The following code calls the tuner action to tune the data tables air04 and air05 by using the full set of tuning parameters:

s:optimization_tuner{
   instances={{data={name="air04"},objSense="minimize"},
      {data={name="air05"}}},
   milpParameters={maxTime=100,primalOut={name="pout"},dualOut={name="dout"}},
   tunerParameters={maxTime=400,nThreads=4,optionMode="full"}
}

Tuning Multiple Problems by Using the Full Set of Parameters

This section contains Python code for the analysis in the CASL version of this example, which contains details about the results.

Note: In order to run this code, the data that are described in the CASL version need to be loaded into CAS. One way to do this is to convert the example data to the comma-separated-value (CSV) files air04.csv and air05.csv and then use the following code to load the CSV files:

s.upload('air04.csv')
s.upload('air05.csv')

For more information about coding in Python, see Getting Started with SAS Viya for Python and SAS Viya: System Programming Guide.

The following code calls the tuner action to tune the data tables air04 and air05 by using the full set of tuning parameters:

s.optimization.tuner(
    instances=[{'data':{'name':'air04'},'objsense':'minimize'},
        {'data':{'name':'air05'}}],
    milpparameters={'maxtime':100,'primalout':{'name':'pout'},
        'dualout':{'name':'dout'}},
    tunerparameters={'maxtime':400,'nthreads':4,'optionmode':'full'}
)

Tuning Multiple Problems by Using the Full Set of Parameters

This example is not available for the R programming language.

Last updated: April 22, 2022