Originally posted by: StefanWeiser
Thanks for your fast reply. I attached my code at this post.
//Index
int N = ...;
int NbPeriods = ...;
range Periods = 1..NbPeriods;
// Parameters
float p[1..N] = ...;
float s[1..N+1] = ...;
float Demand [Periods] = ...;
// Decision Variables
dvar int x2 [Periods]; //Variable Price Quantity
// Objective function
dexpr float TotalCost [t in Periods] =
piecewise ( i in 1..N){
s[i] -> p[i];
s[N+1]
} (1, 1) x2[t];
minimize TotalCost ;
subject to {
forall ( t in Periods)
Demand [t] == x2[t];
forall ( t in Periods) {
x2[t] >= 0;
}
#CPLEXOptimizers#DecisionOptimization