Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  Indexing Arrays with Decision Variables

    Posted Thu February 21, 2013 06:00 PM

    Originally posted by: SystemAdmin


    I am new to CPLEX so my apologies if I am missing something obvious.

    Here is a reduced version of my problem:
    I would like to index arrays in my objective function with the values of the decision variables. However, when I tried to do it I get: "Indexing array "Q" with type dvar int not supported by this algorithm." error. So, I tried to work around with a separate int variable "t" but this results in an unexpected outcome: instead of a positive value of the objective function (which is expected because we are maximizing a sum of products of positive values) the solver returns zero because all rows and columns are eliminated at the pre-solve stage.

    When I tried to force the first value of "t" the solver reported infeasibility.

    There will be more constraints imposed on the decision variables once the problem of using it as an index for defined arrays is resolved.

    Any help will be much appreciated.

    int k = 144;
    range time = 1..k;
    range time0 = 0..k;

    int Qmax = 400;
    range states = 0..Qmax;

    float Qstatesstates = ...; //non negative values read from the data file
    float Ptime=...; //non-negative values read from the data file

    int ttime0; //I had to introduce this variable because d can not act as an index for Q
    dvar int dtime0 in states;

    maximize
    sum(k in time) P[k]*Q[tk-1][tk]; //sum of products of positive values
    subject to {
    forall(k in time0) t[k]==d[k];
    }
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Indexing Arrays with Decision Variables

    Posted Fri February 22, 2013 04:35 PM

    Originally posted by: SystemAdmin


    When I looked at my question I realized that I did not write it well and I copied the wrong code...

    Here is what I am trying to do:

    int k = 144;
    range time = 1..k;
    range time0 = 0..k;

    int Qmax = 400;
    range states = 0..Qmax;

    float Qstatesstates = ...;
    float Ptime=...;

    dvar int dtime0 in states;

    maximize
    sum(k in time) P[k]*Q[dk-1][dk];
    subject to {
    d[0]==150;
    forall(k in time) d[k]-dk-1 <=13;
    forall(k in time) d[k]-dk-1 >=-13;
    }

    and the objective function will not take d as the index for Q
    Thank you in advance.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Indexing Arrays with Decision Variables

    Posted Sat February 23, 2013 10:07 AM

    Originally posted by: SystemAdmin


    Hi,

    It is not possible to index with decision variables. You need to reformulate the problem to avoid this.

    One way for the reformulation is to change
    dvar int d(time0) in states;
    to
    dvar boolean d(time0)(states);
    where
    forall(t in time0) sum(s in states) d(t)(s) == 1;
    then your objective function becomes quadratic
    sum(k in time)sum(s1 in states)sum(s2 in states) P(k)*Q(s1)(s2)*d(k-1)(s1)*d(k)(s2);
    and the constraint is something like
    forall(k in time) forall(s1 in states) forall(s2 in states : s2-s1 > 13 || s1-s2 > 13) d(k)(s2) <= 1 - d(k-1)(s1);

    The above approach will work only if Q is positive semi-definite

    Regards,
    Zahar
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Indexing Arrays with Decision Variables

    Posted Mon February 25, 2013 02:56 PM

    Originally posted by: SystemAdmin


    Thank you, Zahar - this works. The problem becomes quite large in size but this is precisely what I needed.
    It would be great if CPLEX could do this transformation...
    Thank you, again for taking the time to answer my question.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer