good day, i want to ask about the error. Can you help me with this?
Error executing “solve” command:
error processing objective Nutrient_Value_Score:
invalid subscript shortfall[18,1]
this is my code:
#PARAMETER
param num_commodity integer; # number of commodity (K)
param num_nutrition integer; # number of nutrition (N)
param num_local_market integer; # number of local market (M)
param num_distribution_center integer; # number of distibution center (D)
param num_cost_commodity integer; # number of cost commodity (C)
param num_month integer; # number of month (T)
#SET/INDEKS
set K := 1 … num_commodity; # set of commodity (k)
set N := 1 … num_nutrition; # set of nutrition (n)
set M := 1 … num_local_market; # set of local market (m)
set D := 1 … num_distribution_center; # set of distribution center (d)
set C := 1 … num_cost_commodity; # set of cost commodity (c)
set T := 1 … num_month; # set of time period (t)
#PARAMETER (1)
param nutrient_value {K, N};
param cost_transportation {M, D, T};
param transportation_capacity {M, D, T};
param minimal_nutrient {N, T};
param cost_commodity {C};
param total_month;
param total_nutrition;
#VARIABLE
var ratio_commodity {K, T};
var flow_of_commodity {m in M, d in D, t in T} >= 0;
var nutrient_requirement {n in N} >= 0;
var shortfall {n in N, t in T} >= 0;
var overshoot {n in N, t in T} >= 0;
var shortfall_indicator {n in N, t in T} binary;
#OBJECTIVE FUNCTION
minimize total_operation_cost: sum {m in M, d in D, t in T} cost_transportation [m,d,t] * flow_of_commodity [m,d,t];
maximize kilocalories: sum {k in K, n in N, t in T} nutrient_value [k, n] * ratio_commodity [k, t] / total_month;
maximize nutrient_value_ccore: sum {k in K, n in K, t in T} (1 - shortfall [n,t]) / (total_nutrition * total_month) * 100;
#CONSTRAINT
subject to food_basket_optimize {n in N, t in T}:
sum {k in K} nutrient_value [k,n] * ratio_commodity [k,t] >= nutrient_requirement [n];
subject to capacity {m in M, d in D, k in K, t in T}:
sum {j in K} flow_of_commodity [m, d, t] <= transportation_capacity [m, d, t];
subject to supplied_nutrient {n in N, t in T}:
sum{k in K} nutrient_value [k,n] * ratio_commodity [k,t] = nutrient_requirement [n] * (1 - shortfall [n,t] + overshoot [n,t]);
subject to Shortfall {n in N, t in T}:
shortfall [n,t] <= shortfall_indicator [n,t];
subject to Overshoot {n in N, t in T}:
overshoot [n,t] <= (1 - shortfall [n,t]) * 10;
This is the data related to the shortfall