In my project, I am using OPL with execute and main blocks, for calculations (heavy) and flow control. The projects includes two optimization problems with partially overlapping data while the second problem is run iteratively. Now, I am trying to make order in the data generation with the aim to execute each piece of data generation no more than once. Currently I am unable to design models/files to do it efficiently. There is a list of questions I can not resolve, please take a look, share your expertise:
1. If one has a defined variable in the model (e.g. "int x = 1;") and load external data (with .dat file or addDataSource()) with the same variable then he gets an error "Data element "x" has already been set.". How does one instruct OPL to ignore such cases, or alternatively, overwrite the existing value of x. I just want the code not to exit here.... do not propose "int x = ...;", my question is about "int x = 1;".
2. If one has in the model "int x = ...;" and external data source does not supply it then one gets error "External data element "x" was not defined." on generation step. How to ignore such errors? It looks like it can be treated as "int x;" if not provided by the external data.
3. If one does not have any definition of the variable in the model, but the external data does have it, then error raised "Element "x" not defined.". Same question, how to ignore such errors, avoid exit.
4. AFAIK there are two types of data in OPL, internal and external. External data is easy to share in the main block by using something like
var Data = thisOplModel.dataElements;
Is there a way to similarly transfer internal data into IloOplDataElements object? I found the following workaround for it, but if someone knows better please share:
var ofile = new IloOplOutputFile("InternalData.dat");
var IntData = new IloOplDataSource("InternalData.dat");
Appreciate your help,