0
votes

I have some network flow problem, where c[A] are the costs per arc of the network and x is the decision variable to define the amount distributed via which arc

range A = 1..100;
float c[A] = ...; // array of 100 floats from .dat file 

dvar x[A];


minimize sum (a in A) c[a] * x[a];

subject to{


}

I want to change a certain set if cost arcs depending on the decision variable.

Lets say: when the amount per arc is larger then 100, 10 % discount.

: c[i] <= c[i]*0.9 other value, when x[i] >= given value. How to formulate this as a constraint?

1

1 Answers

0
votes
range A = 1..100;
float c[a in A] = a*2; 

dvar int x[A];


minimize sum (a in A) c[a] * x[a];

subject to{

forall(i in A:c[i]<=100) x[i] >= c[i]*0.9;
forall(i in A:c[i]>100) x[i] >= c[i];

}

works fine

range A = 1..100;
float c[a in A] = a*2; 

dvar int x[A];


minimize sum (a in A) c[a] * x[a];

subject to{

forall(i in A) (x[i]<=100) => (x[i] >= c[i]*0.9);
forall(i in A) (x[i]>=101) => (x[i] >= c[i]);

}

works fine too

range A = 1..100;
float c[a in A] = a*2; 

dvar int x[A];


minimize sum (a in A) c[a] * x[a];

subject to{

forall(i in A) (x[i] >= ((c[i]<=100)?c[i]:c[i]*0.9));


}