Originally posted by: SystemAdmin
Hi everybody!
Is it possible in OPL to late initialize a dexpr? Quick example: in most of the programming languages, you can easily write
int a;
// declaration
//[...] a = 1;
// initialization
Even if I think it's possible in OPL to do it for constants (albeit the initialization has to be within an "execute" block), I couldn't find any way to do it for dexprs. I'm asking because I'd like to write sets of dexprs which encode equality systems:
dexpr
int x = y - 1;
// compile-time error: y is not declared yet dexpr
int y = 3 - x;
in place of declaring x and y as variables, and putting the equalities in the "subject to" block. Unfortunately, the former syntax leads to an error because y dexpr is used before is declared, and I can't find any way to declare x without initializing it at the same time. Indeed a syntax like
dexpr
int x;
// declaration of x dexpr
int y = 3 - x;
// no compile-time error here, because x is already declared x = y - 1;
// initialization of x
does not work.
Any ideas?
Regards,
Stefano
#DecisionOptimization#OPLusingCPLEXOptimizer