Hi. I’m new in AMPL. I have a quick question.
set YEARS; # Set representing the years
set UNITS; # Set representing the types of units
param demand{YEAR in YEARS}; # Demand data for each year
param capacity{UNIT in UNITS}; # Capacity data for each type of unit
param cost{UNIT in UNITS}; # Cost data for each type of unit
param unit_no{UNIT in UNITS}; # Limited number of units available
var units{UNIT in UNITS, YEAR in YEARS} integer >= 0; # Amount of units installed
# Objective:
minimize Total_Cost:
sum{YEAR in YEARS, UNIT in UNITS} (cost[UNIT] * units[UNIT, YEAR]) / (1.05^((YEAR - 2025)));
# Demand constraints: Total capacity of installed units should meet the demand
subject to Demand_Constraint{YEAR in YEARS}:
sum{UNIT in UNITS} (capacity[UNIT] * units[UNIT, YEAR]) >= demand[YEAR];
# Limited number of units available constraint
subject to Unit_Limit_Constraint{UNIT in UNITS}:
sum{UNIT in UNITS} (units[UNIT, YEAR]) <= unit_no[UNIT];
data;
set YEARS := 2025 2030 2035 2040 2045 2050 2055 2060 2065;
set UNITS := Coal Gas Solar Wind Energy;
param demand :=
2025 0
2030 1000
2035 1600
2040 2200
2045 2600
2050 3000
2055 3500
2060 4000
2065 4400;
param capacity :=
Coal 500
Gas 200
Solar 100
Wind 50
Energy 150;
param cost :=
Coal 400
Gas 200
Solar 120
Wind 75
Energy 100;
param unit_no :=
Coal 1
Gas 10
Solar 8
Wind 10
Energy 4;
end;
this is my code.
I m getting this error;
hm.mod, line 23 (offset 902):
syntax error
context: sum{UNIT >>> in <<< UNITS} (units[UNIT, YEAR]) <= unit_no[UNIT];
ampl:
What can be cause this error?
Thank you.