Identify Error
When creating a case file, for instance during a pro::DelegateToServer
, errors may occur during the evaluation of the definitions.
Here we show a little trick to identify the set or parameter that has the definition in which this error occurred.
1Procedure pr_CheckDefinitions {
2 Arguments: (s_TestedIds);
3 Body: {
4 for i_ti | ( ( i_ti in AllDefinedSets ) or (i_ti in AllDefinedParameters ) ) do
5 block
6 s_OneId := {} ;
7 s_OneId += i_ti ;
8 update s_OneId ;
9 onerror ep_err do
10 sp_msg := FormatString("Definition evaluation error of %e with message: \"%s\"",
11 i_ti, errh::Message(ep_err));
12 errh::Adapt(ep_err,message:sp_msg);
13 endblock ;
14 endfor ;
15 }
16 StringParameter sp_msg;
17 Set s_OneId {
18 SubsetOf: AllIdentifiers;
19 }
20 ElementParameter ep_err {
21 Range: errh::PendingErrors;
22 }
23 Set s_TestedIds {
24 SubsetOf: AllIdentifiers;
25 Index: i_ti;
26 Property: Input;
27 }
28}
Remarks about the above code:
line 6,7: the singleton set is constructed.
line 8: the definition is evaluated.
line 10-12: the message is adapted such that the identifier at hand is included in the message.
A sample call is below:
1util::pr_CheckDefinitions(pro::ManagedSessionInputCaseIdentifierSet);
Here we check all definitions of the sets and parameters that are passed in input case to the solver session. Note that by default in modern versions of AIMMS and of AIMMS PRO most if not all parameter definition are avoided anyway.
Example download
You can download the section (.ams
file) that contains this procedure and sample below: CheckDefinitions.zip
To use it, you’ll need to Import a section to your project.