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_ |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | AIR04 | COST | RHS | CL000001 | B | 971 | 0 | 1 | 1 | 1 |
| 2 | AIR04 | COST | RHS | CL000002 | B | 203 | 0 | 1 | 1 | 1 |
| 3 | AIR04 | COST | RHS | CL000003 | B | 530 | 0 | 1 | 0 | 1 |
| 4 | AIR04 | COST | RHS | CL000004 | B | 271 | 0 | 1 | 1 | 1 |
| 5 | AIR04 | COST | RHS | CL000005 | B | 566 | 0 | 1 | 1 | 1 |
| 6 | AIR04 | COST | RHS | CL000006 | B | 477 | 0 | 1 | 1 | 1 |
| 7 | AIR04 | COST | RHS | CL000007 | B | 268 | 0 | 1 | 1 | 1 |
| 8 | AIR04 | COST | RHS | CL000008 | B | 421 | 0 | 1 | 1 | 1 |
| 9 | AIR04 | COST | RHS | CL000009 | B | 1491 | 0 | 1 | 0 | 1 |
| 10 | AIR04 | COST | RHS | CL000010 | B | 410 | 0 | 1 | 1 | 1 |
| 11 | AIR04 | COST | RHS | CL000011 | B | 566 | 0 | 1 | 0 | 1 |
| 12 | AIR04 | COST | RHS | CL000012 | B | 1386 | 0 | 1 | 1 | 1 |
| 13 | AIR04 | COST | RHS | CL000013 | B | 424 | 0 | 1 | 1 | 1 |
| 14 | AIR04 | COST | RHS | CL000014 | B | 350 | 0 | 1 | 1 | 1 |
| 15 | AIR04 | COST | RHS | CL000015 | B | 839 | 0 | 1 | 0 | 1 |
Output 2.17.2: Dual Solution Output
| Obs | _PROBLEM_ | _OBJ_ID_ | _RHS_ID_ | _ROW_ | _TYPE_ | _RHS_ | _L_RHS_ | _U_RHS_ | _ACTIVITY_ | _SOL_ |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | AIR04 | COST | RHS | RW000001 | E | 1 | . | . | 1 | 1 |
| 2 | AIR04 | COST | RHS | RW000002 | E | 1 | . | . | 1 | 1 |
| 3 | AIR04 | COST | RHS | RW000003 | E | 1 | . | . | 1 | 1 |
| 4 | AIR04 | COST | RHS | RW000004 | E | 1 | . | . | 1 | 1 |
| 5 | AIR04 | COST | RHS | RW000005 | E | 1 | . | . | 1 | 1 |
| 6 | AIR04 | COST | RHS | RW000006 | E | 1 | . | . | 1 | 1 |
| 7 | AIR04 | COST | RHS | RW000007 | E | 1 | . | . | 1 | 1 |
| 8 | AIR04 | COST | RHS | RW000008 | E | 1 | . | . | 1 | 1 |
| 9 | AIR04 | COST | RHS | RW000009 | E | 1 | . | . | 1 | 1 |
| 10 | AIR04 | COST | RHS | RW000010 | E | 1 | . | . | 1 | 1 |
| 11 | AIR04 | COST | RHS | RW000011 | E | 1 | . | . | 1 | 1 |
| 12 | AIR04 | COST | RHS | RW000012 | E | 1 | . | . | 1 | 1 |
| 13 | AIR04 | COST | RHS | RW000013 | E | 1 | . | . | 1 | 1 |
| 14 | AIR04 | COST | RHS | RW000014 | E | 1 | . | . | 1 | 1 |
| 15 | AIR04 | COST | RHS | RW000015 | E | 1 | . | . | 1 | 1 |
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.