0
votes

I have the following decision variable Xbmt ...(I have a few similar of them, some continuous and some binary)

Originally declared as :

dvar float+ Xbmt[PitBlocks][Plants][TimePeriods];

But now for some of the PitBlocks and some time periods I want to define this decision variable as 0.[or rather exclude them, as the number of variables have grown extremely large leading OPL to crash]. Those time periods for which I want to set the decision variable as 0 are defined in a tuple nullVariables. It has block id (same as PitBlocks), and it has time_period (same as TimePeriod). Hence I want something like below. But I cannot declare the decision variable twice. I need it 0 only for those ids in the nullVariable set.

dvar float+ Xbmt[NullVariablesSet.block_id][Plants][NullVariablesSet.time_period] in 0..0;

How can this be achieved where some of Xbmt indices from NullVariableSet are removed by setting as 0 while the rest remain as continuous decision variables.

The nullVariable set looks below while the complete PitBlock list is a more exhaustive one and TimePeriods are 1 to 5 :

block_id    time_period
P14           1
P15           1
P16           1
P17           1
P27           1
P29           1
...and so on
P247        1
P247        2
P247        3

Note : I have posted this before but probably my explanation there of what I want to achieve wasnt good enough. Is it possible to pre-assign values to decision variables in CPLEX OPL

1

1 Answers

0
votes

Of course it is very easy to fix the value of a variable before solving in OPL by simply adding a constraint that forces it to take a specific value. This will usually give CPLEX a smaller problem to solve so it will usually solve faster.

BUT I think that will not help you at all as it doesn't change the number of variables in your OPL model.

Where does OPL crash? What messages do you get? How much memory do you have and how much is OPL using when you try to run this? How may PitBlocks, Plants and TimePeriods do you have?

If you are having a problem with OPL crashing because "the number of variables have grown extremely large" and looking at your 3-dimensional array, then you seriously need to look at how to do sparse modelling, using e.g. a set of tuples to index your array of decision variables.

First naive observation is that probably only some combinations of [PitBlocks][Plants][TimePeriods] will make sense.

So I suggest that you read the section on decision variables in the OPL language reference manual (it's usually about page 32 in the PDF, or in ...doc/html/en-US/OPL_Studio/opllangref/topics/opl_langref_decisiontypes_dvars.html in the installed copy of CPLEX on Windows) where it says:

In particular, it is also possible, and desirable for larger problems, to index arrays of decision variables by finite sets

The key idea here is to use a set of tuples as the index set for your decision variables. So in your example you can maybe do something like:

tuple BlockPlantTime {
    int block;
    int plant;
    int time;
}

Then you populate that tupleset with just the tuples that match the valid combinations of block, plant and time that you want in your model:

{BlockPlantTime} bpt = {<1,1,1>, <1,1,2>, <2,2,5>, etc...}

Obviously you will need to do that programatically from your base data - again read the documentation and examples to work out how best to do this.

Then use that tupleset as the index set for your decision variables:

dvar float+ Xbmt[bpt];

That way you only create the decision variables that you actually want/need in your model. Obviously you will need to re-write your constraint code to work in terms of this tupleset, but there is a lot of stuff in OPL to allow you to slice and dice through your filter set in different ways. Again, read the documentation and look at the examples.

It seems harder to start with but this is absolutely the way to go with large models in OPL.