0

I have a varaiable depends on another decision variable say the opening cost of a facility which is calculated based on a cell or region, this requires the allocation variable to be calculated first then start calculating the opening cost. I want this opening cost to be included in the objective.

Originally I would make the calculation as a dexpr however the logic is too complex to be added as a one line formula.

Is there a solution where I can make an execute block to act as a dexpr? or add a condition or constraint to postpone the variable calculation so that it's after finding an intial solution to the allocation variable?

1 Answers1

0

You can write compute a depr out of some other dexpr:

dvar float x in -5..5;
dexpr float y=2*x;
dexpr float z=3*y;

minimize x;
subject to
{
  
}

but you can also write constraints:

dvar float x in -5..5;
dvar float y;
dvar float z;


minimize x;
subject to
{
  y==2*x;
  z==3*y;
}

But you cannot write formula in an execute scripting block

Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15