Hello,
Assuming that most options are set in a few specific procedures, how about the following approach:
Separate the procedure to solve into a procedure that does not contain option settings, and name it: pr_solveWithoutAnySpecificOptionSettings;
Based on this procedure, you can create two procedures as follows:
pr_solveUsingTailoredSettings:
body:
block where
CPLEX_22_1.integrality := 0,
CPLEX_22_1.feasibility := 1e-06,
....
;
pr_solveWithoutAnySpecificOptionSettings();
endblock ;
pr_solveUsingDefautlSettings:
body:
block ! Using default option settings
pr_solveWithoutAnySpecificOptionSettings();
endblock ;
Does this approach help?
Perhaps interesting is the how-to: https://how-to.aimms.com/Articles/208/208-setting-options.html
With kind regards,
Chris.
Thank you for your quick response!
Unfortunately this would be quite cumbersome for us.
- Options are not set in one but in multiple procedures.
- Your approach requires us to set the default value manually. However it is quite cumbersome to find out what the default value is.
Is there any other way to automatically reset all settings? We would expect this to be a natural use case.
Thanks!
How about opening a new project, exporting its empty settings and importing to your project? It is not ideal, but it might work.
You can use the following procedure to reset all options for a certain solver:
Procedure ResetSolverOptions {
Arguments: SolverName;
Body: {
SolverString := SolverName + '::';
for ( IndexOptions | FindString(IndexOptions,SolverString) ) do
res := OptionGetDefaultString( IndexOptions, defkey );
if ( res ) then ! Keyword option
res := OptionGetString( IndexOptions, curkey );
if ( res and ( defkey <> curkey ) ) then
OptionSetString( IndexOptions, defkey );
endif;
else ! Numerical option
res := OptionGetValue( IndexOptions, low, cur, def, upp );
if ( res and ( def <> cur ) ) then
OptionSetValue( IndexOptions, def );
endif;
endif;
endfor;
}
StringParameter SolverName {
Property: Input;
}
StringParameter SolverString;
Parameter low;
Parameter upp;
Parameter cur;
Parameter def;
StringParameter curkey;
StringParameter defkey;
Parameter res;
}
I have attached a small example project in which several CPLEX 22.1 options have been set to a non-default value. After calling ResetSolverOptions(‘CPLEX 22.1’) all these options are reset to their default.