Optimization Action Set

Tuning Multiple Problems by Using a User-Specified Parameters Set

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 shows different ways to specify user-provided tuning parameters, the parameter tuning range, and the initial tuning value in the tuningparameters parameter. The example also shows how to change the value of a default parameter in the milpparameters parameter. When you can specify the USER value in the optionmode subparameter in the tunerparameters parameter, then in the tuningparameters parameter you define the parameters, their ranges, and their initial values. The basic rule is that if you specify only a parameter name, the tuner action goes through all the valid values and uses the default value as the initial value. If you do not specify the initial parameter, the tuner action uses the default value or the first value specified in the values parameter as the initial value when the default value is not in the values parameter range.

If you want to specify a solveMilp action’s parameter that is not being tuned to a nondefault value, you can do so in the milpparameters parameter.

You can also output a detailed tuning results table by specifying the data table in the tunerout subparameter in the tunerparameters parameter. The table contains parameter settings and solution summaries of different problems under different parameter settings.

The following code calls the tuner action to tune the data tables air04 and air05 by using six tuning parameters with different ranges and initial values:

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'}, {data='air05'}}
   tuningParameters={
      {option='presolver', values={'basic', 'aggressive', 'none'}, initial='none'},
      {option='strongiter', values={-1, 100. 1000, 10000}, initial=-1},
      {option='cutstrategy'},
      'probe',
      {option='symmetry', initial='none'},
      {option='cutgub', values={'none','moderate'}}
   }
   milpParameters={conflictSearch='automatic', cutGub='moderate', maxtime=100}
   tunerParameters={maxtime=400, nthreads=4, optionmode='user',
      tunerOut={name='tout', replace=true}}
;
run;
quit;
proc print data=caslib.tout(obs=16); run;

Output 2.16.1 shows partial results of the data table specified in the tunerout subparameter. This table has a detailed summary of the results of each problem under different parameter configurations. The RANK=0 row shows the result of the initial run on each tuning problem. The rest of the rows are sorted according to the performance measure specified in the goal subparameter.

Output 2.16.1: Tuner Action Output

ObsRANKPROBLEMOBJSENSEpresolverstrongItercutStrategyprobesymmetrycutGubSTATUSSOLUTION_STATUSOBJECTIVERELATIVE_GAPABSOLUTE_GAPNODESSOLUTION_TIME
10AIR04MINnone-1automaticautomaticnonenoneOKOPTIMAL561370027098.12
20AIR05MINnone-1automaticautomaticnonenoneOKOPTIMAL2637400103125.86
31AIR04MINaggressive-1nonebasicaggressivenoneOKOPTIMAL56137001536.76
41AIR05MINaggressive-1nonebasicaggressivenoneOKOPTIMAL263740011716.25
52AIR04MINaggressive10000nonenonenonemoderateOKOPTIMAL56137001028.88
62AIR05MINaggressive10000nonenonenonemoderateOKOPTIMAL26374006785.27
73AIR04MINaggressive1000nonebasicmoderatenoneOKOPTIMAL56137001129.05
83AIR05MINaggressive1000nonebasicmoderatenoneOKOPTIMAL26374006595.46
94AIR04MINaggressive-1nonenonenonenoneOKOPTIMAL561370031310.81
104AIR05MINaggressive-1nonenonenonenoneOKOPTIMAL26374006764.72
115AIR04MINaggressive-1nonebasicmoderatenoneOKOPTIMAL56137001536.61
125AIR05MINaggressive-1nonebasicmoderatenoneOKOPTIMAL263740011718.57
136AIR04MINaggressive-1nonenoneaggressivenoneOKOPTIMAL561370031311.19
146AIR05MINaggressive-1nonenoneaggressivenoneOKOPTIMAL26374006765.12
157AIR04MINaggressive100automaticnonemoderatemoderateOKOPTIMAL56137001615.81
167AIR05MINaggressive100automaticnonemoderatemoderateOKOPTIMAL263740089310.36


Tuning Multiple Problems by Using a User-Specified Parameters Set

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 six tuning parameters with different ranges and initial values:

s:optimization_tuner{
   instances={{data={name="air04"}},{data={name="air05"}}},
   milpParameters={conflictSearch="none",cutGub="moderate",maxTime=100},
   tunerParameters={maxTime=400,nThreads=4,
      optionMode="user",tunerOut={name="tout",replace=true}},
   tuningParameters={
      {initial="none",values={"basic","aggressive","none"},option="presolver"},
      {initial=-1,values={-1,100,1000,10000},option="strongIter"},
      {option="cutStrategy"},
      {option="probe"},
      {initial="none",option="symmetry"},
      {values={"none","moderate"},option="cutGub"}
   }
}

Tuning Multiple Problems by Using a User-Specified Parameters Set

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 six tuning parameters with different ranges and initial values:

s.optimization.tuner(
    instances=[{'data':{'name':'air04'}},{'data':{'name':'air05'}}],
    milpparameters={'conflictsearch':'none','cutgub':'moderate','maxtime':100},
    tunerparameters={'maxtime':400,'nthreads':4,
        'optionmode':'user','tunerout':{'name':'tout','replace':True}},
    tuningparameters=[
        {'initial':'none','values':['basic','aggressive','none'],'option':'presolver'},
        {'initial':-1,'values':[-1,100,1000,10000],'option':'strongIter'},
        {'option':'cutStrategy'},
        {'option':'probe'},
        {'initial':'none','option':'symmetry'},
        {'values':['none','moderate'],'option':'cutGub'}
    ]
)

Tuning Multiple Problems by Using a User-Specified Parameters Set

This example is not available for the R programming language.

Last updated: December 08, 2021