Norman Schmitz
Norman Schmitz

Reputation: 13

OPL constraint index

I am programming an OPL model and do not know how to express the following constraint:

q_t-D_t_T*v_t <=0

Where D_t_T is the sum of all q_t in the set of t to T.

-- Update --

Yes, just q[t] and v[t] are variables. Is the suggestion also working if I defined the range of t as follows:

//parameters
int T=...;                          
range Perioden=1..T;

My constraint looks then:

forall(t in Perioden)
  constraint1:
    q[t]- (sum(i in t..T) q[i])*v[t]<=0;

Maybe one more basic question: How do I express the [t-1] in the following expression:

forall(t in Perioden)
  constraint2:
    y[t-1]+q[t]-y[t]==q[t];

Upvotes: 0

Views: 266

Answers (1)

Norman Schmitz
Norman Schmitz

Reputation: 13

Yes, just q[t] and v[t] are variables. Is your suggestion also working if I defined the range of t as follows:

//parameters
int T=...;                          
range Perioden=1..T;

My constraint looks then:

forall(t in Perioden)
  constraint1:
    q[t]- (sum(i in t..T) q[i])*v[t]<=0;

Maybe one more basic question: How do I express the [t-1] in the following expression:

forall(t in Perioden)
  constraint2:
    y[t-1]+q[t]-y[t]==q[t];

Upvotes: 1

Related Questions