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 presolve 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=...; //nonnegative 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[tk1][tk]; //sum of products of positive values
subject to {
forall(k in time0) t[k]==d[k];
}
Topic

Re: Indexing Arrays with Decision Variables
20130222T21:35:12ZThis is the accepted answer. This is the accepted answer.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[dk1][dk];
subject to {
d[0]==150;
forall(k in time) d[k]dk1 <=13;
forall(k in time) d[k]dk1 >=13;
}
and the objective function will not take d as the index for Q
Thank you in advance. 
Re: Indexing Arrays with Decision Variables
20130223T15:07:04ZThis is the accepted answer. This is the accepted answer. SystemAdmin
 20130222T21:35:12Z
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[dk1][dk];
subject to {
d[0]==150;
forall(k in time) d[k]dk1 <=13;
forall(k in time) d[k]dk1 >=13;
}
and the objective function will not take d as the index for Q
Thank you in advance.
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(k1)(s1)*d(k)(s2);
and the constraint is something like
forall(k in time) forall(s1 in states) forall(s2 in states : s2s1 > 13  s1s2 > 13) d(k)(s2) <= 1  d(k1)(s1);
The above approach will work only if Q is positive semidefinite
Regards,
Zahar 
Re: Indexing Arrays with Decision Variables
20130225T19:55:33ZThis is the accepted answer. This is the accepted answer. SystemAdmin
 20130223T15:07:04Z
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(k1)(s1)*d(k)(s2);
and the constraint is something like
forall(k in time) forall(s1 in states) forall(s2 in states : s2s1 > 13  s1s2 > 13) d(k)(s2) <= 1  d(k1)(s1);
The above approach will work only if Q is positive semidefinite
Regards,
Zahar
It would be great if CPLEX could do this transformation...
Thank you, again for taking the time to answer my question.