Can someone kindly let me know what is the problem with my code? When I run it I get the error message:
"Sorry, a demo license for AMPL is limited to 300 variables
and 300 constraints and objectives (after presolve) for nonlinear
problems. You have 250 variables, 402 constraints, and 1 objective."
However, I don't think it should contain as many variables and constraints but it is giving me this result since I should select a set of the binary variables that only give me a value of 1 and eliminate zeros so that any the number of constraints is reduced to only 4 cities insted of 25, but I don't know how to do so. *Note: the objective function is on this form in order to have the problem as mixed-integer linear programming instead of non-linear.
The model file:
set Q; #quarters
set c; #cities
param d{i in c, j in c}; # distance between cities i and j
param D{i in c, q in Q}; # demand of each city in each quarter
param U{i in c, q in Q}; # produced capacity in city i in quarter q
param ccp{i in c}; # contract cost for production facility in city i
param cp{q in Q}; # cost per unit produced in quarter q
param cw{q in Q}; # cost per unit warehoused at the end of quarter q
param t1 = .1; # transportation cost as a function of distance to warehouse
param t2 = .125; # the transportation cost as a function of the distance to city
var fp{i in c} binary; # 1 if production centers in city i was selected, 0 o.w. (total of 4 cities)
var fw{i in c} binary; # 1 if warehouse in city i was selected, 0 o.w. (total of 3 cities)
var xp{i in c,q in Q}>=0 :=; # the numb of units to be produced in each production facility and quarter
var xw{i in c, q in Q}>=0; # the number of units in each warehouse’s inventory at the end of each quarter
minimize tot_cost:
(sum{i in c, q in Q} cp[q]*xp[i,q])*(sum{i in c}fp[i]) + (sum{i in c} ccp[i])*(sum{i in c}fp[i]) + (sum{q in Q,i in c} cw[q]*xw[i,q])*(sum{i in c}fw[i]) + (sum{i in c,j in c,q in Q} t1*d[i,j]*xp[i,q])*(sum{i in c}fp[i]) + (sum{i in c, j in c,q in Q} t2 *d[i,j]*xp[i,q])*(sum{i in c}fp[i]);
s.t.
Production_Cities: sum{i in c} fp[i] = 4;
WH_Cities: sum{i in c}fw[i] = 3;
relation{i in c, q in Q}: xp[i,q]<= 1000000 * fp[i]; # to relate binary variable fp with xp
relation2{i in c, q in Q}: xw[i,q]<= 1000000 * fw[i];
Demand{i in c, q in Q}: xp[i,q]*fp[i] = D[i,q]; # quarterly demand of a city must be met exactly
Capacity{i in c, q in Q}: xp[i,q]*fp[i] <=U[i,q]*fp[i]; #capacity limit