Error executing "solve" command:
error processing objective Nutrient_Value_Score:
invalid subscript shortfall[18,1]
#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
var shortfall {n in N, t in T} >= 0;
sum {k in K, n in K, t in T} (1 - shortfall[n,t]) / (total_nutrition * total_month) * 100
sum {n in N, t in T} (1 - shortfall[n,t]) / (total_nutrition * total_month) * 100
On Tue, Nov 7, 2023 at 2:09 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
okey, thank you very much robert
On Mon, Nov 6, 2023 at 4:33 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Line 108 of T2.dat needs to have a ; character at the end. (The ; tells AMPL that the previous data table has ended, and that a new table starts with line 110. When the ; is missing, AMPL sees line 110 as part of the previous table, which results in the unexpected error that you see.)
Also, check you other tables in T2.dat to be sure that each one ends with a ; character.
--
Robert Fourer
We're switching to a new, enhanced user forum.
Join it now at discuss.ampl.com.