Quartz | Level 8

## Error message about Objective Function

Hi, I have a question to consult.

When I was using SAS Base 9.4 Optimization part,

the following error message shows

Min  obj = sum {j in SUPPLIERS, t in TIME_PERIODS} major_cost[j,t]*repl_order_1[j,t]

---

180

ERROR 180-322: Statement is not valid or it is used out of proper order.

Or the following error message shows when I try to run the whole optimization problem.

ERROR: A coefficient for symbol obj is missing or invalid.

The logic of my code is as below:

1. Proc optmodel;

2. Declare sets and numerators;

3. Objective function. Min ...

4. Constraints.

5. Solve with MILP;

6. quit;

And I am not sure how to debug the error.

Error

Thank you so much!

6 REPLIES 6
SAS Employee

## Re: Error message about Objective Function

If you are able to add a bit more of your code, folks may be able to help you more. It seems that a previous issue has confused the parser.

In the snippet you already posted, I notice a semicolon missing. If I add that semicolon and the other necessary declarations, I get a successful parse:

proc optmodel;

set SUPPLIERS, TIME_PERIODS;

num major_cost{SUPPLIERS, TIME_PERIODS};

var repl_order_1{SUPPLIERS, TIME_PERIODS} >= 0;

Min  obj = sum {j in SUPPLIERS, t in TIME_PERIODS} major_cost[j,t]*repl_order_1[j,t];

quit;

Quartz | Level 8

## Re: Error message about Objective Function

Hi!

Thank you for the reply. Below is an integrated part, and I have the semicolon to the objective function.

Max  Z = -sum {j in SUPPLIERS, t in TIME_PERIODS} major_cost[j,t]*repl_order_1[j,t]

- sum {j in SUPPLIERS, m in RAW_MATERIALS} minor_cost[j,m]*(repl_raw1[j,m] + repl_raw2[j,m] + repl_raw3[j,m] + repl_raw4[j,m] + repl_raw5[j,m])

- sum {m in RAW_MATERIALS, q in PRICE_INTERVALS} (unit_price1[m,q]*raw_quantity1_1[m,q]

+ unit_price1[m,q]*raw_quantity1_2[m,q]

+ unit_price1[m,q]*raw_quantity1_3[m,q]

+ unit_price1[m,q]*raw_quantity1_4[m,q]

+ unit_price1[m,q]*raw_quantity1_5[m,q]

+ unit_price2[m,q]*raw_quantity2_1[m,q]

+ unit_price2[m,q]*raw_quantity2_2[m,q]

+ unit_price2[m,q]*raw_quantity2_3[m,q]

+ unit_price2[m,q]*raw_quantity2_4[m,q]

+ unit_price3[m,q]*raw_quantity3_1[m,q]

+ unit_price3[m,q]*raw_quantity3_2[m,q]

+ unit_price3[m,q]*raw_quantity3_3[m,q]

+ unit_price3[m,q]*raw_quantity3_4[m,q])

- sum {p in PRODUCTS, t in TIME_PERIODS} (minor_cost_1[p,t]*manu_order[p,t] + produce_cost[p,t]*pro_size[p,t])

- sum {k in STAGES2, t in TIME_PERIODS} major_cost_1[k,t]*repl_order_k[k,t]

- sum {m in RAW_MATERIALS, t in TIME_PERIODS} holding_1[m,t]*inv_raw[m,t]

- sum {p in PRODUCTS, k in STAGES} holding_2[p,k]*inv_pro[p,k]

- sum {j in SUPPLIERS, m in RAW_MATERIALS} in_transit_1[j,m]*(raw_quantity_1[j,m] + raw_quantity_2[j,m] + raw_quantity_3[j,m]

+ raw_quantity_4[j,m] +raw_quantity_1[j,m])

- sum {p in PRODUCTS, k in STAGES2} in_transit_2[p,k]*(rep_size_2[p,k] + rep_size_3[p,k] + rep_size_4[p,k] + rep_size_5[p,k])

- sum {r in TRUCKS, j in SUPPLIERS} truck_cost_1[r,j]*(truck_raw_1[r,j]+truck_raw_2[r,j]+truck_raw_3[r,j]+truck_raw_4[r,j]+truck_raw_5[r,j])

- sum {k in STAGES4, r in TRUCKS} truck_cost_2[k,r]*(truck_pro_2[k,r]+truck_pro_3[k,r]+truck_pro_4[k,r]+truck_pro_5[k,r])

;

With the error message in log:

ERROR: A coefficient for symbol Z is missing or invalid.

Is there any other way about it?

Thanks!

SAS Super FREQ

## Re: Error message about Objective Function

You can narrow down which coefficient is problematic by commenting out all but one sum, considering one sum at a time.  Alternatively, please post your full code and data here.

Quartz | Level 8

## Re: Error message about Objective Function

Okay. Below are the codes. Sorry it is over 20kb and I can just copy and paste.

Title 'A Serial Supply Chain example';

/*Define Customer Demand*/

Data Demand1;

input product demand_1;

datalines;

1  300

2  400

;

Data Demand2;

input product demand_2;

datalines;

1  600

2  700

;

Data Demand3;

input product demand_3;

datalines;

1  600

2  700

;

Data Demand4;

input product demand_4;

datalines;

1  500

2  600

;

Data Demand5;

input product demand_5;

datalines;

1  300

2  400

;

/*Define manufacture and inventory capacity*/

Data Capacity;

input product produce_cap stage1_cap stage2_cap stage3_cap stage4_cap;

datalines;

1  2000  3000  12000  12000  12000

2  1200  3000  12000  12000  12000

3   800  3000  12000  12000  12000

4   800  3000  12000  12000  12000

5  2000  3000  12000  12000  12000

;

/*Define the transformation of raw materials into finished products*/

Data Bill_Ratio;

input product raw_1 raw_2;

datalines;

1  2  3

2  3  2

;

/*Define fill-in rate of raw materials and final products into 1 container*/

Data Fill_Ratio1;

input raw_material amount;

datalines;

1  1.2

2  1.5

;

Data Fill_Ratio2;

input final_product amount;

datalines;

1  2.5

2  3.0

;

/*Description of raw material suppliers*/

Data Supplier_info;

input supplier lead_time m1_cap m2_cap quality_rate1 quality_rate2 major_cost minor1_cost minor2_cost;

datalines;

1  0  9000  9000  0.97  0.97  9000  10000  11000

2  1  3500  3500  0.95  0.96  5000   7000   6000

3  1  4000  4000  0.95  0.95  3000   3500   3000

;

/*Define Inventory Holding Cost and Production Cost*/

Data Raw_inv_cost;

input time_period raw_material cost;

datalines;

1  1  2

2  1  2

3  1  2

4  1  2

5  1  2

1  2  1

2  2  1

3  2  1

4  2  1

5  2  1

;

Data Product_inv_cost;

input time_period stage product cost;

datalines;

1  2  1   7

1  2  2   9

1  3  1   8

1  3  2  11

1  4  1   9

1  4  2  12

2  2  1   7

2  2  2   9

2  3  1   8

2  3  2  11

2  4  1   9

2  4  2  12

;

Data Produce_cost;

input time_period product cost;

datalines;

1  1  24

1  2  29

2  1  25

2  2  30

3  1  29

3  2  35

4  1  29

4  2  35

5  1  24

5  2  29

;

/*Define in-transit inventory holding cost*/

Data in_transit_cost1;

input supplier type cost;

datalines;

1  1  2.0

1  2  1.0

2  1  2.2

2  2  0.9

3  1  1.8

3  2  1.1

;

Data in_transit_cost2;

input type stage cost;

datalines;

1  2   7.5

1  3   8.5

2  2   9.5

2  3  11.5

;

/*Define truck capacity and cost information*/

Data truck_cap;

input type capacity;

datalines;

1  50

2  55

3  65

;

Data truck_cost;

input type supplier stage cost;

datalines;

1  1  0  3000

1  1  2  1000

1  1  3  5000

1  2  0  2800

1  2  2  1000

1  2  3  5000

1  3  0  3100

1  3  0  1000

1  3  0  5000

2  1  0  3500

2  1  2  1100

2  1  3  6000

2  2  0  3300

2  2  2  1100

2  2  3  6000

2  3  0  3200

2  3  2  1100

2  3  3  6000

3  1  0  4000

3  1  2  1200

3  1  3  7000

3  2  0  3800

3  2  2  1200

3  2  3  7000

3  3  0  3900

3  3  2  1200

3  3  3  7000

;

/*Define initial and ending inventory level*/

Data Inventory_info1;

input raw_material stage initial ending;

datalines;

1  1  50  500

2  1  70  700

;

Data Inventory_info2;

input product stage initial ending;

datalines;

1  2  450   200

1  3  900   300

1  4  1500  500

2  2  500   150

2  3  600   400

2  4  800   300

;

/*Define major and minor fixed cost at manufacture stage*/

Data Fixed_cost;

input stage product \$ cost;

datalines;

1  1  1500

1  2  1250

1  .  5000

2  .  4000

3  .  4000

4  .  4000

;

/*Define price interval for raw materials*/

Data price_interval1;

input supplier raw_material interval1 interval2 interval3;

datalines;

1  1   9   9   9

1  2   7   7   7

;

Data price_interval2;

input supplier raw_material interval1 interval2 interval3;

datalines;

2  1  10   9   8

2  2   8   7   6

;

Data price_interval3;

input supplier raw_material interval1 interval2 interval3;

datalines;

3  1  11  10   9

3  2   9   7   5

;

Title 'A Serial Supply Chain example';

/*Define Customer Demand*/

/*Data Demand;*/

/*  input product time_period1 time_period2 time_period3 time_period4 time_period5;*/

/*  datalines;*/

/*1  300  600  600  500  300  */

/*2  400  700  700  600  400*/

/*;*/

/*Define manufacture and inventory capacity*/

Data Capacity;

input time_period produce_cap inv_cap1 inv_cap2 inv_cap3 inv_cap4;

datalines;

1  2000  3000  12000  12000  12000

2  1200  3000  12000  12000  12000

3   800  3000  12000  12000  12000

4   800  3000  12000  12000  12000

5  2000  3000  12000  12000  12000

;

Data Capacity1;

input stage inv_capk;

datalines;

2  12000

3  12000

4  12000

;

/*Define the transformation of raw materials into finished products*/

Data Bill_Ratio;

input raw_material product1 product2;

datalines;

1  2  3

2  3  2

;

/*Define Production Rate*/

Data Pro_rate;

input product pro_rate;

datalines;

1  4

2  3

;

/*Define fill-in rate of raw materials and final products into 1 container*/

Data Fill_Ratio1;

input raw_material fill1;

datalines;

1  1.2

2  1.5

;

Data Fill_Ratio2;

input product fill2;

datalines;

1  2.5

2  3.0

;

/*Description of raw material suppliers*/

Data Supplier_info;

input supplier lead_time raw_material1 raw_material2 perfect_rate1 perfect_rate2 major_cost minor1_cost minor2_cost time_period;

datalines;

1  0  9000  9000  0.97  0.97  9000  10000  11000  1

2  1  3500  3500  0.95  0.96  5000   7000   6000  1

3  1  4000  4000  0.96  0.95  3000   3500   3000  1

1  0  9000  9000  0.97  0.97  9000  10000  11000  2

2  1  3500  3500  0.95  0.96  5000   7000   6000  2

3  1  4000  4000  0.96  0.95  3000   3500   3000  2

1  0  9000  9000  0.97  0.97  9000  10000  11000  3

2  1  3500  3500  0.95  0.96  5000   7000   6000  3

3  1  4000  4000  0.96  0.95  3000   3500   3000  3

1  0  9000  9000  0.97  0.97  9000  10000  11000  4

2  1  3500  3500  0.95  0.96  5000   7000   6000  4

3  1  4000  4000  0.96  0.95  3000   3500   3000  4

1  0  9000  9000  0.97  0.97  9000  10000  11000  5

;

/*Define minimum perfect rate*/

Data min_perfect;

input raw_material min_perfect;

datalines;

1    0.96

2    0.955

;

/*Define Inventory Holding Cost and Production Cost*/

Data Raw_inv_cost;

input raw_material time_period1 time_period2 time_period3 time_period4 time_period5;

datalines;

1 1.8 1.8 1.8 1.8 1.8

2 1.5 1.5 1.5 1.5 1.5

;

/*The following does not consider time_periods, just repeat*/

Data Product_inv_cost;

input  product stages2 stages3 stages4;

datalines;

1  7  9   8

2 11  9  12

;

Data Produce_cost;

input product time_period1 time_period2 time_period3 time_period4 time_period5;

datalines;

1  24  25  29  29  24

2  29  30  35  35  29

;

/*Define in-transit inventory holding cost*/

Data in_transit_cost1;

input supplier raw_material1 raw_material2;

datalines;

1  2.0  1.5

2  2.2  1.4

3  1.8  1.6

;

Data in_transit_cost2;

input product stage2 stage3;

datalines;

1  7.5 8.5

2  9.5 11.5

;

/*Define truck capacity and cost information*/

Data truck_cap;

input truck truck_cap;

datalines;

1  50

2  55

3  65

;

Data truck_cost_1;

input supplier truck1 truck2 truck3;

datalines;

1  3000  3500  4000

2  2800  3200  3800

3  3100  3300  3900

;

Data truck_cost_2;

input stage truck1 truck2 truck3;

datalines;

2  1100  1000  1200

3  5500  5000  6000

;

/*Define initial and ending inventory level*/

Data Inventory_info1;

input raw_material stage initial ending;

datalines;

1  1  50  500

2  1  70  700

;

Data Inventory_info2;

input product stage initial ending;

datalines;

1  2  450   200

1  3  900   300

1  4  1500  500

2  2  500   150

2  3  600   400

2  4  800   300

;

/*Define major and minor fixed cost at manufacture stage*/

Data Minor_cost;

input supplier raw_material1 raw_material2;

datalines;

1  5000  6000

2  4000  3000

3  3500  3000

;

/*Data Minor_cost2;*/

/*  input raw_material time_period1 time_period2 time_period3 time_period4 time_period5;*/

/*  datalines;*/

/*1  4000  4000  4000  4000  .  */

/*2  3000  3000  3000  3000  .*/

/*;*/

/**/

/*Data Minor_cost3;*/

/*  input raw_material time_period1 time_period2 time_period3 time_period4 time_period5;*/

/*  datalines;*/

/*1  3500  3500  3500  3500  .  */

/*2  3000  3000  3000  3000  .*/

/*;*/

Data Major_cost;

input supplier time_period1 time_period2 time_period3 time_period4 time_period5;

datalines;

1  9000  9000  9000  9000  9000

2  5000  5000  5000  5000   .

3  3000  3000  3000  3000   .

;

Data Major_cost_1;

input stage time_period1 time_period2 time_period3 time_period4 time_period5;

datalines;

1  5000  5000  5000  5000  5000

2  4000  4000  4000  4000  4000

3  4000  4000  4000  4000  4000

4  4000  4000  4000  4000  4000

;

Data Minor_cost_1;

input product time_period1 time_period2 time_period3 time_period4 time_period5;

datalines;

1   1500   1500   1500   1500   1500

2   1250   1250   1250   1250   1250

;

/*Define price interval for raw materials*/

Data boundary_quantity;

input raw_material quantity1 quantity2 quantity3;

datalines;

1  1000  2000  10000000

2  1000  2000  10000000

;

Data initial_1;

input raw_material initial_1;

datalines;

1   50

2   70

;

Data ending_1;

input raw_material ending_1;

datalines;

1   500

2   700

;

Data initial_2;

input product initial_2;

datalines;

1   450

2   500

;

Data ending_2;

input product ending_2;

datalines;

1   200

2   150

;

Data initial_3;

input product initial_3;

datalines;

1   900

2   600

;

Data ending_3;

input product ending_3;

datalines;

1   300

2   400

;

Data initial_4;

input product initial_4;

datalines;

1   1500

2   800

;

Data ending_4;

input product ending_4;

datalines;

1   500

2   300

;

Proc Optmodel;

/*Declare Index Sets*/

set SUPPLIERS;

set SUPPLIERS_1 = {1};

set SUPPLIERS_2 = 1..3;

set SUPPLIERS_3 = 1..3;

set SUPPLIERS_4 = 1..3;

set SUPPLIERS_5 = 1..3;

set TIME_01 = 1..5;

set TIME_02 = 1..4;

set TIME_03 = 1..4;

set TIME_1 = 2..5;

set TIME_2 = 1..5;

set TIME_3 = 2..5;

set TIME_4 = 1..5;

set RAW_MATERIALS;

set PRODUCTS;

set STAGES = 2..4;

set STAGES1 = 1..4;

set STAGES2 = 2..3;

set STAGES3;

set STAGES4;

set STAGES5;

set TIME_PERIODS;

set TRUCKS = 1..3;

set TRUCKS1;

set PRICE_INTERVALS = 1..3 ;

/*Declare Parameters*/

num M = 1000000;

num B = 1000000;

num fill1 {RAW_MATERIALS};

read data Fill_Ratio1 into RAW_MATERIALS = [raw_material] fill1;

/*print fill1;*/

num fill2 {PRODUCTS};

read data Fill_Ratio2 into PRODUCTS = [product] fill2;

/*print fill2;*/

num bill_ratio {RAW_MATERIALS,PRODUCTS};

read data Bill_ratio into RAW_MATERIALS = [raw_material]

{p in PRODUCTS} <bill_ratio[raw_material,p]=col("product"||p)>;

/*print bill_ratio;*/

/*The following does not consider time_periods*/

num supplier_cap {SUPPLIERS, RAW_MATERIALS};

read data Supplier_info into SUPPLIERS = [supplier]

{m in RAW_MATERIALS} <supplier_cap[supplier,m]=col("raw_material"||m)>;

/*print supplier_cap;*/

num produce_cap {TIME_PERIODS};

read data Capacity into TIME_PERIODS = [time_period] produce_cap;

/*print produce_cap;*/

num produce_cap1 = 2000;

num produce_cap2 = 1200;

num produce_cap3 = 800;

num produce_cap4 = 800;

num produce_cap5 = 2000;

num inv_cap1 = 3000;

num inv_capk {STAGES5};

read data Capacity1 into STAGES5 = [stage] inv_capk;

print inv_capk;

num inv_cap {TIME_PERIODS, STAGES1};

read data Capacity into TIME_PERIODS = [time_period]

{k in STAGES1} <inv_cap[time_period,k]=col("inv_cap"||k)>;

/*print inv_cap;*/

num pro_rate {PRODUCTS};

read data Pro_rate into PRODUCTS=[product] pro_rate;

print pro_rate;

num perfect_rate {SUPPLIERS, RAW_MATERIALS};

read data Supplier_info into SUPPLIERS = [supplier]

{m in RAW_MATERIALS} <perfect_rate[supplier,m]=col("perfect_rate"||m)>;

/*print perfect_rate;*/

num min_perfect {RAW_MATERIALS};

read data min_perfect into RAW_MATERIALS = [raw_material] min_perfect;

/*print min_perfect;*/

num demand_2 {PRODUCTS};

read data Demand2 into PRODUCTS = [product] demand_2;

/*print demand;*/

num demand_3 {PRODUCTS};

read data Demand3 into PRODUCTS = [product] demand_3;

/*print demand;*/

num demand_4 {PRODUCTS};

read data Demand4 into PRODUCTS = [product] demand_4;

/*print demand;*/

num demand_5 {PRODUCTS};

read data Demand5 into PRODUCTS = [product] demand_5;

/*print demand;*/

num holding_1 {RAW_MATERIALS, TIME_PERIODS};

read data Raw_inv_cost into RAW_MATERIALS = [raw_material]

{t in TIME_PERIODS} <holding_1[raw_material,t]=col("time_period"||t)>;

/*print holding_1;*/

num holding_2 {PRODUCTS, STAGES};

read data Product_inv_cost into PRODUCTS = [product]

{k in STAGES} <holding_2[product,k]=col("STAGES"||k)>;

/*print holding_2;*/

num in_transit_1 {SUPPLIERS, RAW_MATERIALS};

read data in_transit_cost1 into SUPPLIERS = [supplier]

{m in RAW_MATERIALS} <in_transit_1[supplier,m]=col("raw_material"||m)>;

/*print in_transit_1;*/

num in_transit_2 {PRODUCTS, STAGES2};

read data in_transit_cost2 into PRODUCTS = [product]

{k in STAGES2} <in_transit_2[product,k]=col("stage"||k)>;

print in_transit_2;

num unit_price1 {RAW_MATERIALS, PRICE_INTERVALS};

read data price_interval1 into RAW_MATERIALS = [raw_material]

{q in PRICE_INTERVALS} <unit_price1[raw_material,q]=col("interval"||q)>;

/*print unit_price1; */

num unit_price2 {RAW_MATERIALS, PRICE_INTERVALS};

read data price_interval2 into RAW_MATERIALS = [raw_material]

{q in PRICE_INTERVALS} <unit_price2[raw_material,q]=col("interval"||q)>;

/*print unit_price2; */

num unit_price3 {RAW_MATERIALS, PRICE_INTERVALS};

read data price_interval3 into RAW_MATERIALS = [raw_material]

{q in PRICE_INTERVALS} <unit_price3[raw_material,q]=col("interval"||q)>;

/*print unit_price3; */

num major_cost {SUPPLIERS, TIME_PERIODS};

read data major_cost into SUPPLIERS = [supplier]

{t in TIME_PERIODS} <major_cost[supplier,t]=col("time_period"||t)>;

/*print major_cost;*/

num minor_cost {SUPPLIERS, RAW_MATERIALS};

read data Minor_cost into SUPPLIERS = [supplier]

{m in RAW_MATERIALS} <Minor_cost[supplier,m]=col("raw_material"||m)>;

/*print minor_cost;*/

num produce_cost {PRODUCTS, TIME_PERIODS};

read data produce_cost into PRODUCTS = [product]

{t in TIME_PERIODS} <produce_cost[product,t]=col("time_period"||t)>;

/*print produce_cost;*/

num Major_cost_1 {STAGES3, TIME_PERIODS};

read data Major_cost_1 into STAGES3 = [stage]

{t in TIME_PERIODS} <Major_cost_1[stage,t]=col("time_period"||t)>;

/*print Major_cost_1;*/

num Minor_cost_1 {PRODUCTS, TIME_PERIODS};

read data Minor_cost_1 into PRODUCTS = [product]

{t in TIME_PERIODS} <Minor_cost_1[product,t]=col("time_period"||t)>;

/*print Minor_cost_1;*/

num truck_cost_1 {SUPPLIERS, TRUCKS};

read data truck_cost_1 into SUPPLIERS = [supplier]

{r in TRUCKS} <truck_cost_1[supplier,r]=col("truck"||r)>;

/*print truck_cost_1;*/

num truck_cost_2 {STAGES4, TRUCKS};

read data truck_cost_2 into STAGES4 = [stage]

{r in TRUCKS} <truck_cost_2[stage,r]=col("truck"||r)>;

/*print truck_cost_2;*/

num truck_cap {TRUCKS1};

read data truck_cap into TRUCKS1 = [truck] truck_cap;

/*print truck_cap;*/

num boundary_quantity {RAW_MATERIALS, PRICE_INTERVALS};

read data boundary_quantity into RAW_MATERIALS = [raw_material]

{q in PRICE_INTERVALS} <boundary_quantity[raw_material,q]=col("quantity"||q)>;

print boundary_quantity;

num initial_1 {RAW_MATERIALS};

read data initial_1 into RAW_MATERIALS = [raw_material] initial_1;

num ending_1 {RAW_MATERIALS};

read data ending_1 into RAW_MATERIALS = [raw_material] ending_1;

num initial_2 {PRODUCTS};

read data initial_2 into PRODUCTS = [product] initial_2;

num ending_2 {PRODUCTS};

read data ending_2 into PRODUCTS = [product] ending_2;

num initial_3 {PRODUCTS};

read data initial_3 into PRODUCTS = [product] initial_3;

num ending_3 {PRODUCTS};

read data ending_3 into PRODUCTS = [product] ending_3;

num initial_4 {PRODUCTS};

read data initial_4 into PRODUCTS = [product] initial_4;

num ending_4 {PRODUCTS};

read data ending_4 into PRODUCTS = [product] ending_4;

/*Declare the variable*/

var raw_quantity1_1 {RAW_MATERIALS, PRICE_INTERVALS}>=0; /*For supplier 1, 0 time period*/

var raw_quantity1_2 {RAW_MATERIALS, PRICE_INTERVALS}>=0;

var raw_quantity1_3 {RAW_MATERIALS, PRICE_INTERVALS}>=0;

var raw_quantity1_4 {RAW_MATERIALS, PRICE_INTERVALS}>=0;

var raw_quantity1_5 {RAW_MATERIALS, PRICE_INTERVALS}>=0;

var raw_quantity2_1 {RAW_MATERIALS, PRICE_INTERVALS}>=0; /*For supplier 2, 0 time period*/

var raw_quantity2_2 {RAW_MATERIALS, PRICE_INTERVALS}>=0;

var raw_quantity2_3 {RAW_MATERIALS, PRICE_INTERVALS}>=0;

var raw_quantity2_4 {RAW_MATERIALS, PRICE_INTERVALS}>=0;

var raw_quantity3_1 {RAW_MATERIALS, PRICE_INTERVALS}>=0; /*For supplier 3, 0 time period*/

var raw_quantity3_2 {RAW_MATERIALS, PRICE_INTERVALS}>=0;

var raw_quantity3_3 {RAW_MATERIALS, PRICE_INTERVALS}>=0;

var raw_quantity3_4 {RAW_MATERIALS, PRICE_INTERVALS}>=0;

var raw_quantity_1 {SUPPLIERS, RAW_MATERIALS}>=0; /*Total quantity of raw materials*/

var raw_quantity_2 {SUPPLIERS, RAW_MATERIALS}>=0;

var raw_quantity_3 {SUPPLIERS, RAW_MATERIALS}>=0;

var raw_quantity_4 {SUPPLIERS, RAW_MATERIALS}>=0;

var raw_quantity_5 {SUPPLIERS, RAW_MATERIALS}>=0;

var inv_raw {RAW_MATERIALS, TIME_PERIODS}>=0; /*Inventory for raw materials*/

var inv_raw1 {RAW_MATERIALS}>=0;

var inv_raw2 {RAW_MATERIALS}>=0;

var inv_raw3 {RAW_MATERIALS}>=0;

var inv_raw4 {RAW_MATERIALS}>=0;

var inv_raw5 {RAW_MATERIALS}>=0;

var inv_pro {PRODUCTS, STAGES}>=0; /*Inventory for final products*/

var inv_pro2 {PRODUCTS, STAGES}>=0;

var inv_pro3 {PRODUCTS, STAGES}>=0;

var inv_pro4 {PRODUCTS, STAGES}>=0;

var inv_pro5 {PRODUCTS, STAGES}>=0;

var inv_pro2_2 {PRODUCTS}>=0;

var inv_pro2_3 {PRODUCTS}>=0;

var inv_pro2_4 {PRODUCTS}>=0;

var inv_pro2_5 {PRODUCTS}>=0;

var inv_pro3_2 {PRODUCTS}>=0;

var inv_pro3_3 {PRODUCTS}>=0;

var inv_pro3_4 {PRODUCTS}>=0;

var inv_pro3_5 {PRODUCTS}>=0;

var inv_pro4_2 {PRODUCTS}>=0;

var inv_pro4_3 {PRODUCTS}>=0;

var inv_pro4_4 {PRODUCTS}>=0;

var inv_pro4_5 {PRODUCTS}>=0;

var pro_size {PRODUCTS, TIME_PERIODS}>=0; /*production size*/

var pro_size1 {PRODUCTS}>=0;

var pro_size2 {PRODUCTS}>=0;

var pro_size3 {PRODUCTS}>=0;

var pro_size4 {PRODUCTS}>=0;

var pro_size5 {PRODUCTS}>=0;

var rep_size_2 {PRODUCTS, STAGES2}>=0; /*Replenish order*/

var rep_size_22 {PRODUCTS}>=0;

var rep_size_23 {PRODUCTS}>=0;

var rep_size_24 {PRODUCTS}>=0;

var rep_size_3 {PRODUCTS, STAGES2}>=0;

var rep_size_32 {PRODUCTS}>=0;

var rep_size_33 {PRODUCTS}>=0;

var rep_size_34 {PRODUCTS}>=0;

var rep_size_4 {PRODUCTS, STAGES2}>=0;

var rep_size_42 {PRODUCTS}>=0;

var rep_size_43 {PRODUCTS}>=0;

var rep_size_44 {PRODUCTS}>=0;

var rep_size_5 {PRODUCTS, STAGES2}>=0;

var rep_size_52 {PRODUCTS}>=0;

var rep_size_53 {PRODUCTS}>=0;

var rep_size_54 {PRODUCTS}>=0;

/*The amount of trucks should be integer*/

var truck_raw_1 {SUPPLIERS, TRUCKS} integer;

var truck_raw_2 {SUPPLIERS, TRUCKS} integer;

var truck_raw_3 {SUPPLIERS, TRUCKS} integer;

var truck_raw_4 {SUPPLIERS, TRUCKS} integer;

var truck_raw_5 {SUPPLIERS, TRUCKS} integer;

var truck_pro_2 {STAGES4, TRUCKS} integer;

var truck_pro_3 {STAGES4, TRUCKS} integer;

var truck_pro_4 {STAGES4, TRUCKS} integer;

var truck_pro_5 {STAGES4, TRUCKS} integer;

/*Below are binary variables*/

var repl_order_1 {SUPPLIERS, TIME_PERIODS} binary; /*Major for suppliers*/

var repl_order_11 {SUPPLIERS} binary;

var repl_order_12 {SUPPLIERS} binary;

var repl_order_13 {SUPPLIERS} binary;

var repl_order_14 {SUPPLIERS} binary;

var repl_order_15 {SUPPLIERS} binary;

var repl_raw1 {SUPPLIERS, RAW_MATERIALS} binary;/*Minor in suppliers*/

var repl_raw2 {SUPPLIERS, RAW_MATERIALS} binary;

var repl_raw3 {SUPPLIERS, RAW_MATERIALS} binary;

var repl_raw4 {SUPPLIERS, RAW_MATERIALS} binary;

var repl_raw5 {SUPPLIERS, RAW_MATERIALS} binary;

var repl_order_k {STAGES2, TIME_PERIODS} binary;/*Major cost in later stages*/

var repl_order_k2 {STAGES2} binary;

var repl_order_k3 {STAGES2} binary;

var repl_order_k4 {STAGES2} binary;

var repl_order_k5 {STAGES2} binary;

var manu_order {PRODUCTS, TIME_PERIODS} binary;/*Minor for final products*/

var repl_manu1  binary;/*For stage 1*/

var repl_manu2  binary;

var repl_manu3  binary;

var repl_manu4  binary;

var repl_manu5  binary;

var raw_order1_1 {RAW_MATERIALS, PRICE_INTERVALS} binary;

var raw_order1_2 {RAW_MATERIALS, PRICE_INTERVALS} binary;

var raw_order1_3 {RAW_MATERIALS, PRICE_INTERVALS} binary;

var raw_order1_4 {RAW_MATERIALS, PRICE_INTERVALS} binary;

var raw_order1_5 {RAW_MATERIALS, PRICE_INTERVALS} binary;

var raw_order2_1 {RAW_MATERIALS, PRICE_INTERVALS} binary;

var raw_order2_2 {RAW_MATERIALS, PRICE_INTERVALS} binary;

var raw_order2_3 {RAW_MATERIALS, PRICE_INTERVALS} binary;

var raw_order2_4 {RAW_MATERIALS, PRICE_INTERVALS} binary;

var raw_order3_1 {RAW_MATERIALS, PRICE_INTERVALS} binary;

var raw_order3_2 {RAW_MATERIALS, PRICE_INTERVALS} binary;

var raw_order3_3 {RAW_MATERIALS, PRICE_INTERVALS} binary;

var raw_order3_4 {RAW_MATERIALS, PRICE_INTERVALS} binary;

By the way, I tried to comment out other sums, and leave only one at a time. But the same error message shows:

ERROR: A coefficient for symbol Z is missing or invalid.

Thank you!

/*Maximize the objective function*/

Max  Z = -sum {j in SUPPLIERS, t in TIME_PERIODS} major_cost[j,t]*repl_order_1[j,t]

- sum {j in SUPPLIERS, m in RAW_MATERIALS} minor_cost[j,m]*(repl_raw1[j,m] + repl_raw2[j,m] + repl_raw3[j,m] + repl_raw4[j,m] + repl_raw5[j,m])

- sum {m in RAW_MATERIALS, q in PRICE_INTERVALS} (unit_price1[m,q]*raw_quantity1_1[m,q]

+ unit_price1[m,q]*raw_quantity1_2[m,q]

+ unit_price1[m,q]*raw_quantity1_3[m,q]

+ unit_price1[m,q]*raw_quantity1_4[m,q]

+ unit_price1[m,q]*raw_quantity1_5[m,q]

+ unit_price2[m,q]*raw_quantity2_1[m,q]

+ unit_price2[m,q]*raw_quantity2_2[m,q]

+ unit_price2[m,q]*raw_quantity2_3[m,q]

+ unit_price2[m,q]*raw_quantity2_4[m,q]

+ unit_price3[m,q]*raw_quantity3_1[m,q]

+ unit_price3[m,q]*raw_quantity3_2[m,q]

+ unit_price3[m,q]*raw_quantity3_3[m,q]

+ unit_price3[m,q]*raw_quantity3_4[m,q])

- sum {p in PRODUCTS, t in TIME_PERIODS} (minor_cost_1[p,t]*manu_order[p,t] + produce_cost[p,t]*pro_size[p,t])

- sum {k in STAGES2, t in TIME_PERIODS} major_cost_1[k,t]*repl_order_k[k,t]

- sum {m in RAW_MATERIALS, t in TIME_PERIODS} holding_1[m,t]*inv_raw[m,t]

- sum {p in PRODUCTS, k in STAGES} holding_2[p,k]*inv_pro[p,k]

- sum {j in SUPPLIERS, m in RAW_MATERIALS} in_transit_1[j,m]*(raw_quantity_1[j,m] + raw_quantity_2[j,m] + raw_quantity_3[j,m]

+ raw_quantity_4[j,m] +raw_quantity_1[j,m])

- sum {p in PRODUCTS, k in STAGES2} in_transit_2[p,k]*(rep_size_2[p,k] + rep_size_3[p,k] + rep_size_4[p,k] + rep_size_5[p,k])

- sum {r in TRUCKS, j in SUPPLIERS} truck_cost_1[r,j]*(truck_raw_1[r,j]+truck_raw_2[r,j]+truck_raw_3[r,j]+truck_raw_4[r,j]+truck_raw_5[r,j])

- sum {k in STAGES4, r in TRUCKS} truck_cost_2[k,r]*(truck_pro_2[k,r]+truck_pro_3[k,r]+truck_pro_4[k,r]+truck_pro_5[k,r]);

/*Declare constraints*/

constraint inv_flow1 {j in SUPPLIERS, m in RAW_MATERIALS, p in PRODUCTS}:

sum {j in SUPPLIERS} raw_quantity_1[j,m] + initial_1 = inv_raw1 + sum {p in Products} bill_ratio[m,p]*pro_size1

;

constraint inv_flow2 {j in SUPPLIERS, m in RAW_MATERIALS, p in PRODUCTS}:

sum {j in SUPPLIERS} raw_quantity_2[j,m] + inv_raw1 = inv_raw2 + sum {p in Products} bill_ratio[m,p]*pro_size2

;

constraint inv_flow3 {j in SUPPLIERS, m in RAW_MATERIALS, p in PRODUCTS}:

sum {j in SUPPLIERS} raw_quantity_3[j,m] + inv_raw2 = inv_raw3 + sum {p in Products} bill_ratio[m,p]*pro_size3

;

constraint inv_flow4 {j in SUPPLIERS, m in RAW_MATERIALS, p in PRODUCTS}:

sum {j in SUPPLIERS} raw_quantity_4[j,m] + inv_raw3 = inv_raw4 + sum {p in Products} bill_ratio[m,p]*pro_size4

;

constraint inv_flow5 {j in SUPPLIERS, m in RAW_MATERIALS, p in PRODUCTS}:

sum {j in SUPPLIERS} raw_quantity_4[j,m] + inv_raw4 = inv_raw5 + sum {p in Products} bill_ratio[m,p]*pro_size5

;

/* con raw_interval1 {q in PRICE_INTERVALS, j in SUPPLIERS, m in RAW_MATERIALS}:*/

/*     sum {q in PRICE_INTERVALS} raw_quantity1_1[q,m]+raw_quantity2_1[q,m]+raw_quantity3_1[q,m] = sum {j in SUPPLIERS} raw_quantity_1[j,m];*/

/* con raw_interval2 {q in PRICE_INTERVALS, j in SUPPLIERS, m in RAW_MATERIALS}:*/

/*                     sum {q in PRICE_INTERVALS} raw_quantity1_2[q,m]+raw_quantity2_2[q,m]+raw_quantity3_2[q,m] = sum {j in SUPPLIERS} raw_quantity_2[j,m];*/

/* con raw_interval3 {q in PRICE_INTERVALS, j in SUPPLIERS, m in RAW_MATERIALS}:*/

/* sum {q in PRICE_INTERVALS} raw_quantity1_3[q,m]+raw_quantity2_3[q,m]+raw_quantity3_3[q,m] = sum {j in SUPPLIERS} raw_quantity_3[j,m];*/

/* con raw_interval4 {q in PRICE_INTERVALS, j in SUPPLIERS, m in RAW_MATERIALS}:*/

/* sum {q in PRICE_INTERVALS} raw_quantity1_4[q,m]+raw_quantity2_4[q,m]+raw_quantity3_4[q,m] = sum {j in SUPPLIERS} raw_quantity_4[j,m];*/

/* con raw_interval5 {q in PRICE_INTERVALS, j in SUPPLIERS, m in RAW_MATERIALS}:*/

/* sum {q in PRICE_INTERVALS} raw_quantity1_5[q,m] = sum {j in SUPPLIERS} raw_quantity_5[j,m];*/

constraint inv_stage2_2 {p in PRODUCTS}:

pro_size2

+ initial_2

= inv_pro2_2

+ rep_size_22

;

constraint inv_stage2_3 {p in PRODUCTS}:

pro_size3

+ inv_pro2_2

= inv_pro2_3

+ rep_size_32

;

constraint inv_stage2_4 {p in PRODUCTS}:

pro_size4

+ inv_pro2_3

= inv_pro2_4

+ rep_size_42

;

constraint inv_stage2_5 {p in PRODUCTS}:

pro_size5

+ inv_pro2_4

= inv_pro2_5

+ rep_size_52

;

constraint inv_stage3_2 {p in PRODUCTS}:

rep_size_22

+ initial_3

= inv_pro3_2

+ rep_size_23

;

constraint inv_stage3_3 {p in PRODUCTS}:

rep_size_32

+ inv_pro3_2

= inv_pro3_3

+ rep_size_33

;

constraint inv_stage3_4 {p in PRODUCTS}:

rep_size_42

+ inv_pro3_3

= inv_pro3_4

+ rep_size_43

;

constraint inv_stage3_5 {p in PRODUCTS}:

rep_size_52

+ inv_pro3_4

= inv_pro3_5

+ rep_size_53

;

constraint inv_stage4_2 {p in PRODUCTS}:

rep_size_23

+ initial_4

= demand_2

+ inv_pro4_2

;

constraint inv_stage4_3 {p in PRODUCTS}:

rep_size_33

+ inv_pro4_2

= demand_3

+ inv_pro4_3

;

constraint inv_stage4_4 {p in PRODUCTS}:

rep_size_43

+ inv_pro4_3

= demand_4

+ inv_pro4_4

;

constraint inv_stage4_5 {p in PRODUCTS}:

rep_size_53

+ inv_pro4_4

= demand_5

+ inv_pro4_5

;

constraint perfect_rate1 {j in SUPPLIERS, m in RAW_MATERIALS}:

sum {j in SUPPLIERS} perfect_rate[j,m]*raw_quantity_1[j,m] >= sum {j in SUPPLIERS} raw_quantity_1[j,m]*min_perfect;

constraint perfect_rate2 {j in SUPPLIERS, m in RAW_MATERIALS}:

sum {j in SUPPLIERS} perfect_rate[j,m]*raw_quantity_2[j,m] >= sum {j in SUPPLIERS} raw_quantity_2[j,m]*min_perfect;

constraint perfect_rate3 {j in SUPPLIERS, m in RAW_MATERIALS}:

sum {j in SUPPLIERS} perfect_rate[j,m]*raw_quantity_3[j,m] >= sum {j in SUPPLIERS} raw_quantity_3[j,m]*min_perfect;

constraint perfect_rate4 {j in SUPPLIERS, m in RAW_MATERIALS}:

sum {j in SUPPLIERS} perfect_rate[j,m]*raw_quantity_4[j,m] >= sum {j in SUPPLIERS} raw_quantity_4[j,m]*min_perfect;

constraint perfect_rate5 {j in SUPPLIERS, m in RAW_MATERIALS}:

sum {j in SUPPLIERS} perfect_rate[j,m]*raw_quantity_5[j,m] >= sum {j in SUPPLIERS} raw_quantity_5[j,m]*min_perfect;

constraint supplier_cap1 {j in SUPPLIERS, m in RAW_MATERIALS}:

raw_quantity_1[j,m] <= supplier_cap[j,m]*repl_raw1[j,m];

constraint supplier_cap2 {j in SUPPLIERS, m in RAW_MATERIALS}:

raw_quantity_2[j,m] <= supplier_cap[j,m]*repl_raw2[j,m];

constraint supplier_cap3 {j in SUPPLIERS, m in RAW_MATERIALS}:

raw_quantity_3[j,m] <= supplier_cap[j,m]*repl_raw3[j,m];

constraint supplier_cap4 {j in SUPPLIERS, m in RAW_MATERIALS}:

raw_quantity_4[j,m] <= supplier_cap[j,m]*repl_raw4[j,m];

constraint supplier_cap5 {j in SUPPLIERS, m in RAW_MATERIALS}:

raw_quantity_5[j,m] <= supplier_cap[j,m]*repl_raw5[j,m];

constraint binary_minor1 {j in SUPPLIERS, m in RAW_MATERIALS}:

sum {m in RAW_MATERIALS} repl_raw1[j,m]<= M * repl_order_11;

constraint binary_minor2 {j in SUPPLIERS, m in RAW_MATERIALS}:

sum {m in RAW_MATERIALS} repl_raw2[j,m]<= M * repl_order_12;

constraint binary_minor3 {j in SUPPLIERS, m in RAW_MATERIALS}:

sum {m in RAW_MATERIALS} repl_raw3[j,m]<= M * repl_order_13;

constraint binary_minor4 {j in SUPPLIERS, m in RAW_MATERIALS}:

sum {m in RAW_MATERIALS} repl_raw4[j,m]<= M * repl_order_14;

constraint binary_minor5 {j in SUPPLIERS, m in RAW_MATERIALS}:

sum {m in RAW_MATERIALS} repl_raw5[j,m]<= M * repl_order_15;

constraint binary_manu {p in PRODUCTS, t in TIME_PERIODS}:

pro_size[p,t] <= B * manu_order[p,t];

constraint produce_rate1 {p in PRODUCTS}:

pro_size1

/pro_rate

<= produce_cap1*repl_manu1;

constraint produce_rate2 {p in PRODUCTS}:

pro_size2

/pro_rate

<= produce_cap2*repl_manu2;

constraint produce_rate3 {p in PRODUCTS}:

pro_size3

/pro_rate

<= produce_cap3*repl_manu3;

constraint produce_rate4 {p in PRODUCTS}:

pro_size4

/pro_rate

<= produce_cap4*repl_manu4;

constraint produce_rate5 {p in PRODUCTS}:

pro_size5

/pro_rate

<= produce_cap5*repl_manu5;

constraint repl_order2 {p in PRODUCTS, k in STAGES2}:

sum {p in PRODUCTS} rep_size_2[p,k] <= B*repl_order_k2;

constraint repl_order3 {p in PRODUCTS, k in STAGES2}:

sum {p in PRODUCTS} rep_size_3[p,k] <= B*repl_order_k3;

constraint repl_order4 {p in PRODUCTS, k in STAGES2}:

sum {p in PRODUCTS} rep_size_4[p,k] <= B*repl_order_k4;

constraint repl_order5 {p in PRODUCTS, k in STAGES2}:

sum {p in PRODUCTS} rep_size_5[p,k] <= B*repl_order_k5;

constraint raw_inv1 {m in RAW_MATERIALS}:

sum {m in RAW_MATERIALS} fill1*inv_raw1 <= inv_cap1;

constraint raw_inv2 {m in RAW_MATERIALS}:

sum {m in RAW_MATERIALS} fill1*inv_raw2 <= inv_cap1;

constraint raw_inv3 {m in RAW_MATERIALS}:

sum {m in RAW_MATERIALS} fill1*inv_raw3 <= inv_cap1;

constraint raw_inv4 {m in RAW_MATERIALS}:

sum {m in RAW_MATERIALS} fill1*inv_raw4 <= inv_cap1;

constraint raw_inv5 {m in RAW_MATERIALS}:

sum {m in RAW_MATERIALS} fill1*inv_raw5 <= inv_cap1;

constraint pro_inv2 {p in PRODUCTS, k in STAGES}:

sum {p in PRODUCTS} fill2

*inv_pro2[p,k] <= inv_capk;

constraint pro_inv3 {p in PRODUCTS, k in STAGES}:

sum {p in PRODUCTS} fill2

*inv_pro3[p,k] <= inv_capk;

constraint pro_inv4 {p in PRODUCTS, k in STAGES}:

sum {p in PRODUCTS} fill2

*inv_pro4[p,k] <= inv_capk;

constraint pro_inv5 {p in PRODUCTS, k in STAGES}:

sum {p in PRODUCTS} fill2

*inv_pro5[p,k] <= inv_capk;

constraint truck_raw1 {m in RAW_MATERIALS, j in SUPPLIERS, r in TRUCKS}:

sum {m in RAW_MATERIALS} fill1*raw_quantity_1[j,m] <= truck_cap*truck_raw_1[j,r];

constraint truck_raw2 {m in RAW_MATERIALS, j in SUPPLIERS, r in TRUCKS}:

sum {m in RAW_MATERIALS} fill1*raw_quantity_2[j,m] <= truck_cap*truck_raw_2[j,r];

constraint truck_raw3 {m in RAW_MATERIALS, j in SUPPLIERS, r in TRUCKS}:

sum {m in RAW_MATERIALS} fill1*raw_quantity_3[j,m] <= truck_cap*truck_raw_3[j,r];

constraint truck_raw4 {m in RAW_MATERIALS, j in SUPPLIERS, r in TRUCKS}:

sum {m in RAW_MATERIALS} fill1*raw_quantity_4[j,m] <= truck_cap*truck_raw_4[j,r];

constraint truck_raw5 {m in RAW_MATERIALS, j in SUPPLIERS, r in TRUCKS}:

sum {m in RAW_MATERIALS} fill1*raw_quantity_5[j,m] <= truck_cap*truck_raw_5[j,r];

constraint truck_pro2 {p in PRODUCTS, k in STAGES2, r in TRUCKS}:

sum {p in PRODUCTS} fill2

*rep_size_2[p,k] <= sum {r in TRUCKS} truck_cap*truck_pro_2[k,r];

constraint truck_pro3 {p in PRODUCTS, k in STAGES2, r in TRUCKS}:

sum {p in PRODUCTS} fill2

*rep_size_3[p,k] <= sum {r in TRUCKS} truck_cap*truck_pro_3[k,r];

constraint truck_pro4 {p in PRODUCTS, k in STAGES2, r in TRUCKS}:

sum {p in PRODUCTS} fill2

*rep_size_4[p,k] <= sum {r in TRUCKS} truck_cap*truck_pro_4[k,r];

constraint truck_pro5 {p in PRODUCTS, k in STAGES2, r in TRUCKS}:

sum {p in PRODUCTS} fill2

*rep_size_5[p,k] <= sum {r in TRUCKS} truck_cap*truck_pro_5[k,r];

constraint truck_raw_size1 {m in RAW_MATERIALS, j in SUPPLIERS, r in TRUCKS}:

sum {r in TRUCKS} truck_cap*truck_raw_1[j,r] <= sum {m in RAW_MATERIALS} raw_quantity_1[j,m];

constraint truck_raw_size2 {m in RAW_MATERIALS, j in SUPPLIERS, r in TRUCKS}:

sum {r in TRUCKS} truck_cap*truck_raw_2[j,r] <= sum {m in RAW_MATERIALS} raw_quantity_2[j,m];

constraint truck_raw_size3 {m in RAW_MATERIALS, j in SUPPLIERS, r in TRUCKS}:

sum {r in TRUCKS} truck_cap*truck_raw_3[j,r] <= sum {m in RAW_MATERIALS} raw_quantity_3[j,m];

constraint truck_raw_size4 {m in RAW_MATERIALS, j in SUPPLIERS, r in TRUCKS}:

sum {r in TRUCKS} truck_cap*truck_raw_4[j,r] <= sum {m in RAW_MATERIALS} raw_quantity_4[j,m];

constraint truck_raw_size5 {m in RAW_MATERIALS, j in SUPPLIERS, r in TRUCKS}:

sum {r in TRUCKS} truck_cap*truck_raw_5[j,r] <= sum {m in RAW_MATERIALS} raw_quantity_5[j,m];

constraint truck_pro_size2 {p in PRODUCTS, r in TRUCKS, k in STAGES2}:

sum {r in TRUCKS} truck_cap*truck_pro_2[k,r] >= sum {p in PRODUCTS} rep_size_2[p,k];

constraint truck_pro_size3 {p in PRODUCTS, r in TRUCKS, k in STAGES2}:

sum {r in TRUCKS} truck_cap*truck_pro_3[k,r] >= sum {p in PRODUCTS} rep_size_3[p,k];

constraint truck_pro_size4 {p in PRODUCTS, r in TRUCKS, k in STAGES2}:

sum {r in TRUCKS} truck_cap*truck_pro_4[k,r] >= sum {p in PRODUCTS} rep_size_4[p,k];

constraint truck_pro_size5 {p in PRODUCTS, r in TRUCKS, k in STAGES2}:

sum {r in TRUCKS} truck_cap*truck_pro_5[k,r] >= sum {p in PRODUCTS} rep_size_5[p,k];

constraint price_cons1_1 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum {q in PRICE_INTERVALS} raw_quantity1_1[m,q] <= raw_order1_1[m,q]*boundary_quantity[m,q];

constraint price_cons1_2 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum {q in PRICE_INTERVALS} raw_quantity1_2[m,q] <= raw_order1_2[m,q]*boundary_quantity[m,q];

constraint price_cons1_3 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum {q in PRICE_INTERVALS} raw_quantity1_3[m,q] <= raw_order1_3[m,q]*boundary_quantity[m,q];

constraint price_cons1_4 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum {q in PRICE_INTERVALS} raw_quantity1_4[m,q] <= raw_order1_4[m,q]*boundary_quantity[m,q];

constraint price_cons1_5 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum {q in PRICE_INTERVALS} raw_quantity1_5[m,q] <= raw_order1_5[m,q]*boundary_quantity[m,q];

constraint price_cons2_1 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum {q in PRICE_INTERVALS} raw_quantity2_1[m,q] <= raw_order2_1[m,q]*boundary_quantity[m,q];

constraint price_cons2_2 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum {q in PRICE_INTERVALS} raw_quantity2_2[m,q] <= raw_order2_2[m,q]*boundary_quantity[m,q];

constraint price_cons2_3 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum {q in PRICE_INTERVALS} raw_quantity2_3[m,q] <= raw_order2_3[m,q]*boundary_quantity[m,q];

constraint price_cons2_4 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum {q in PRICE_INTERVALS} raw_quantity2_4[m,q] <= raw_order2_4[m,q]*boundary_quantity[m,q];

constraint price_cons3_1 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum {q in PRICE_INTERVALS} raw_quantity3_1[m,q] <= raw_order3_1[m,q]*boundary_quantity[m,q];

constraint price_cons3_2 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum {q in PRICE_INTERVALS} raw_quantity3_2[m,q] <= raw_order3_2[m,q]*boundary_quantity[m,q];

constraint price_cons3_3 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum {q in PRICE_INTERVALS} raw_quantity3_3[m,q] <= raw_order3_3[m,q]*boundary_quantity[m,q];

constraint price_cons3_4 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum {q in PRICE_INTERVALS} raw_quantity3_4[m,q] <= raw_order3_4[m,q]*boundary_quantity[m,q];

constraint binary_price1_1 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum{q in PRICE_INTERVALS} raw_order1_1[m,q] <= 1;

constraint binary_price1_2 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum{q in PRICE_INTERVALS} raw_order1_2[m,q] <= 1;

constraint binary_price1_3 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum{q in PRICE_INTERVALS} raw_order1_3[m,q] <= 1;

constraint binary_price1_4 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum{q in PRICE_INTERVALS} raw_order1_4[m,q] <= 1;

constraint binary_price1_5 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum{q in PRICE_INTERVALS} raw_order1_5[m,q] <= 1;

constraint binary_price2_1 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum{q in PRICE_INTERVALS} raw_order2_1[m,q] <= 1;

constraint binary_price2_2 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum{q in PRICE_INTERVALS} raw_order2_2[m,q] <= 1;

constraint binary_price2_3 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum{q in PRICE_INTERVALS} raw_order2_3[m,q] <= 1;

constraint binary_price2_4 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum{q in PRICE_INTERVALS} raw_order2_4[m,q] <= 1;

constraint binary_price3_1 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum{q in PRICE_INTERVALS} raw_order3_1[m,q] <= 1;

constraint binary_price3_2 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum{q in PRICE_INTERVALS} raw_order3_2[m,q] <= 1;

constraint binary_price3_3 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum{q in PRICE_INTERVALS} raw_order3_3[m,q] <= 1;

constraint binary_price3_4 {m in RAW_MATERIALS, q in PRICE_INTERVALS}:

sum{q in PRICE_INTERVALS} raw_order3_4[m,q] <= 1;

/*To solve the problem*/

solve with milp;

Quit;

SAS Super FREQ

## Re: Error message about Objective Function

Your Major_cost data set has missing values, and these values are used in the first sum in Z.

By the way, in the future, it is probably better to attach a file (see the "Use advanced editor" button) rather than copy and paste.

Looking ahead to the inv_flow* constraints, I see that you have used j as both a constraint index and a summation index within the same constraint.  This does not make sense and will cause errors.

Quartz | Level 8

## Re: Error message about Objective Function

Thank you so much! It is really helpful.

It works now! And I would take care about the code upload next time.

Discussion stats
• 6 replies
• 1521 views
• 4 likes
• 3 in conversation