Reputation: 1
I keep running into an error with AMPL wherein whenever I try to model my mod file I get an error:
giap.mod, line 23 (offset 1996): d is not defined
context: {(d, b) >>> : <<< d in Donors_Deliver, b in All_FoodBank}
# Donor ke Gudang Makanan
# Sets
set Time; # Time periods in the planning horizon
set Donors_Deliver; # Donors that deliver food items to food banks
set Collection_Donors; # Donors that require collection of food items by food banks
set Financial_Donors; # Donors that provide financial donations to food banks
set All_Donors := Donors_Deliver union Collection_Donors union Financial_Donors; # All donors, D = DD union CD union FD (subsets are pairwise disjoint)
set Existing_FoodBank; # Existing food bank warehouses at the beginning of the planning horizon
set Potential_Sites; # Potential sites for locating new food bank warehouses
set All_FoodBank := Existing_FoodBank union Potential_Sites; # All food bank locations, B = OB union PB and OB intersect PB = empty set
set Received_FoodBank within (Donors_Deliver cross All_FoodBank); # Food banks that can receive food products from donor d in DD, Bd ⊆ B
set Served_Charities; # Beneficiary organizations served by some food bank at the beginning of the planning horizon
set Hold_Charities; # Non-profit organizations on hold, i.e., organizations on the waiting list of the food bank association
set All_Organisations := Served_Charities union Hold_Charities; # All organizations, C = SC union HC and SC intersect HC = empty set
set FoodGroup; # Families of food products
set Individual_Food {k in FoodGroup}; # Individual food items belonging to family k in K
set All_Product := union {k in FoodGroup} Individual_Food[k]; # All food products, P = union of Pk
set Levels; # Discrete capacity levels for storage areas/transport resources
set I; # Set asal (origin)
set J; # Set tujuan (destination)
# Define set All_destination as the union of all relevant relationships
set All_destination :=
{(d, b) : d in Donors_Deliver, b in All_FoodBank} # Donor ke Gudang Makanan
union {(d, b) : d in Collection_Donors union Financial_Donors, b in All_FoodBank} # Donor Pengumpulan/Sumbangan ke Gudang Makanan
union {(b, c) : b in All_FoodBank, c in Served_Charities};
Upvotes: -1
Views: 56
Reputation: 77
In your set expression {(d, b) : d in Donors_Deliver, b in All_FoodBank}
, (d,b)
needs to be a in some set, something like (d,b) in some_set
, before you specify the filter conditions. There are many ways to express a set. For example,
{d in Donors_Deliver, b in All_FoodBank}
Moreover, your expression could be simplified into Donors_Deliver union All_FoodBank
directly.
Another option could be using the "setof" operator, could be useful when generating more complex sets.
setof {d in Donors_Deliver, b in All_FoodBank: d <= 3 and d !=b} (d,2*b);
Upvotes: 2