Suffix and Uncontrolled Set Errors

Problems with modeling
Post Reply
drm
User
User
Posts: 1
Joined: 5 months ago

Suffix and Uncontrolled Set Errors

Post by drm »

Hello,

I have been trying to run a code which will allow me to optimize the total number of EV chargers in a school, their types and locations depending on power availability...all this while minimizing the cost. I want the code to display the cost, number of chargers to be installed, their types and locations in which they will be installed. Can you please fix the code where needed? Errors show from Constraint2.. onwards. Also, are the 'display' orders valid here in order to get results on the values I'm looking for?

$title Location Allocation Model for EV Charger Installation

$onText
Optimization model for the types and numbers of EV chargers to be installed at the university's campus
$offtext

option limrow = 0, limcol = 0;

Free Variable z "Objective is to minimze the total cost of installation";

set j /P1*P8/;

set i /type1*type3/;

Binary Variable Y (j) "0 if charger is not to be installed at location j / 1 if charger is to be installed at location j";


Positive Variables
N (i, j) "Number of chargers i to be installed at location j"
;


Scalar
C_civil /3000/
*Cost of civil work for installing each charger - 3,000 AED
C_int /40/
*Cost of removal and reassembly of interlock - 40 AED per meter
Cpaint /2000/
*Cost of the paint for each parking lot - 2,000 AED
;

Parameters
Ci (i) /"type1" 3000, "type2" 105000, "type3" 185000/
*Cost of charger i"
dj (j) /"P1" 95, "P2" 95, "P3" 75 , "P4" 95 , "P5" 35, "P6" 85, "P7" 130, "P8" 75/
Cpower (i) /"type1" 22, "type2" 60, "type3" 120/
*Cpower - power rating of charger i
Pspare (j) /"P1" 650, "P2" 300, "P3" 272 , "P4" 300 , "P5" 120, "P6" 120, "P7" 240, "P8" 350/
*spare load available at each building (buildings not included have 0kW of spare load/no spare load)
students (j) /"P1" 464, "P2" 0, "P3" 2366 , "P4" 2366 , "P5" 1096, "P6" 342, "P7" 27, "P8" 17/
*The total number of students in buildings that are readily available with power
Ci_cable(i, j);
*Cost of the cable connected to charger i"


Ci_cable(i, j)$(Ci(i) = 3000 and dj(j) <= 100) = 40;
Ci_cable(i, j)$(Ci(i) = 3000 and dj(j) > 100) = 60;
Ci_cable(i, j)$(Ci(i) = 105000 and dj(j) <= 100) = 120;
Ci_cable(i, j)$(Ci(i) = 105000 and dj(j) > 100) = 160;
Ci_cable(i, j)$(Ci(i) = 185000 and dj(j) <= 100) = 180;
Ci_cable(i, j)$(Ci(i) = 185000 and dj(j) > 100) = 200;


N.fx("type2",j)$(Pspare (j) < 50) = 0;
N.fx("type3",j)$(Pspare (j) < 50) = 0;
N.fx("type3",j)$(Pspare (j) < 100) = 0;


Equations
TC "Total Cost"
Constraint1
*The total number of chargers installed across the campus in a ratio of 3:1:1 should not exceed 80% of the total spare load
Constraint2
*If Nij = 0, Y(j) = 0
*Cost of interlock doesn't depend on the number of chargers, but it would depend on the total number of locations and their distances from the DB
Constraint3
*The total power of the chargers installed at location j should not exceed the spare load available in the location
Constraint4
*We should have at least q charger for a total of 50 students and above
;


TC..
z =e= sum ((i,j), Ci_cable(i, j) * dj (j)) + (C_civil * sum((i,j), N(i,j)) + sum ((i,j), N(i,j)* Ci(i)) + sum ((j), C_int * dj (j) * Y (j)) + sum ((i,j), N (i,j) * Cpaint));

Constraint1..
sum(j, (3 * Cpower("type1") * sum(i, N("type1", j))
+ 1 * Cpower("type2") * sum(i, N("type2", j))
+ 1 * Cpower("type3") * sum(i, N("type3", j))))
=l= 0.8 * sum(j, Pspare(j));


Constraint2..
Y(j)$(N (i,j)= 0) =e= 0;

Constraint3..
sum((i, j), N(i, j) * Y(j) * Cpower(i)) =l= Pspare(j);


Constraint4$(students(j) ge 50)..
sum(N(i, j) for i) =g= 1;


model LocAlloc /all/;
solve LocAlloc using mip min z;
display N;
display ci;
display Y;
display z;


Thank you,
MD
Manassaldi
User
User
Posts: 118
Joined: 7 years ago
Location: Rosario - Argentina

Re: Suffix and Uncontrolled Set Errors

Post by Manassaldi »

Hi, this is not a valid equation.

Code: Select all

Constraint2.. Y(j)$(N (i,j)= 0) =e= 0;
You can start by trying the following constraint:

Code: Select all

Constraint2(i,j).. N (i,j) =l= Y(j)*BigM;
BigM is sufficient large number.
I think you also have other errors in the sets specification.
Best
Post Reply