Hi,
I am trying the following constraints to build in AMPL for Convex combination modelling of a piecewise linear function:
# Parameters
param K; # Number of k values
param Z; # Number of z values
param N; # Number of n values - intervals of divisions of plf
param xbar{1..N}; # x̄[n] values
param ybar{1..N}; # ȳ[n] values
# Variables
var lambda{1..N, 1..Z, 1..K} >= 0; # λ_k values, non-negative
var delta{1..N-1, 1..Z, 1..K} binary; # δ_s values, binary for 1 to K-1
# Constraints
subject to constraint_x {z in 1..Z, k in 1..K}:
sum{n in 1..N} xbar[n] * lambda[n, z, k] = x[z, k];
subject to constraint_y {z in 1..Z, k in 1..K}:
sum{n in 1..N} ybar[n] * lambda[n, z, k] = y[z, k];
subject to constraint_sum_lambda{z in 1..Z, k in 1..K}:
sum{n in 1..N} lambda[n, z, k] = 1;
# Lambda constraints based on delta
subject to lambda_n1{z in 1..Z, k in 1..K}:
lambda[1, z, k] <= delta[1, z, k];
subject to lambda_n2_to_N1 {n in 2..N-1, z in 1..Z, k in 1..K}:
lambda[n, z, k] <= delta[n-1, z, k] + delta[n, z, k];
subject to lambda_N{z in 1..Z, k in 1..K}:
lambda[N, z, k] <= delta[N-1, z, k];
# Constraint for delta sum
subject to constraint_delta_sum{z in 1..Z, k in 1..K}:
sum{s in 1..N-1} delta[s, z, k] = 1;
# Objective
maximize obj: sum{z in 1..Z, k in 1..K} y[z, k];
But, I am keep getting this error:
subject to constraint_sum_lambda{z in 1…Z, k in 1…K}:
sum{n in 1…N} lambda[n, z, k] = 1; I am getting this error: all variables eliminated, but lower bound = 1 > 0
Although I am able to build up these constraints in Gurobi in Python platform, and it’s working!
I want to know how can I get it working in AMPL?