index_set 内の各要素に対して制約が生成される。 条件式 ( : condition ) を追加して、特定のインデックスに対してのみ制約を生成することも可能。 # --- In model file (model.mod) --- set PLANTS; set PRODUCTS; set PERIODS ordered; param capacity {PLANTS, PRODUCTS}; param demand {PRODUCTS, PERIODS}; var Produce {PLANTS, PRODUCTS, PERIODS} >= 0; var Inventory {PRODUCTS, PERIODS} >= 0; # Production capacity constraint for each plant, product, period subject to CapacityLimit {pl in PLANTS, pr in PRODUCTS, t in PERIODS}: Produce[pl, pr, t] <= capacity[pl, pr]; # Inventory balance constraint for each product, period (except the first) subject to InvBalance {pr in PRODUCTS, t in PERIODS: t > first(PERIODS)}: Inventory[pr, t] = Inventory[pr, prev(t)] + sum {pl in PLANTS} Produce[pl, pr, t] - demand[pr, t]; 40