Solved

Reset all manually set options

  • 24 October 2022
  • 4 replies
  • 89 views

Badge

In our project we set options manually. For example, we have lines of code like ‘option CPLEX_22_1.integrality := 1e-05;’. For a specific case that we have, we would like set all these options to their default values and run the case again. What procedure can we use for this?

Two things we tried that did not work:

  • We cannot just remove all lines of code where we manually set options, since the case that we have problems with has been run before; hence, the default options in this case have already been overridden.
  • We also tried using the procedure ‘OptionGetValue’ to get the default value and set every option to its default value, but this does not work for the majority of our options. For example, when applying our procedure to the option ‘Advanced_Start’ we get the error ‘Option not found, or not a numeric option’. Another example is the option ‘CPLEX_22_1.integrality’; in that case we get the error ‘The option “CPLEX_22_1.integrality” has not been found’.

Thank you!

 

icon

Best answer by Marcel Hunting 26 October 2022, 13:40

View original

4 replies

Userlevel 5
Badge +7

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.

Badge

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!

Userlevel 5
Badge +6

How about opening a new project, exporting its empty settings and importing to your project? It is not ideal, but it might work. 

Userlevel 5
Badge +4

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.

Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator