Hello Renger,
thank you for your answer. I fixed my mistake. But now I have another problem
For example on the second day the market price is 10€ and the customer fixed price is 5€. The farmer could deliver 60 quantities to the customer, but the customer only delivers 55 quantities (minimum delivery).
Target scenario: The farmer should deliver the complete 60 quantities, since this quantity is in the value range (min delivery: 55 and max delivery: 65). Quantities should only be purchased if the delivery is below the minimum delivery. However, the minimum delivery must not be exceeded. Consequently, quantities may only be sold if the maximum delivery is exceeded. However, the maximum quantity may not be undercut at the time of sale.
This is my program code:
set
days /1, 2, 3/
Parameter
Farmer_Corn_Quantity(days) /1 50, 2 60, 3 70/
Market_price(days) /1 20, 2 10, 3 15/
Scalar
Min_delivery /55/
Max_delivery /65/
Customer_price /5/
;
Free Variable
costs
;
positive Variable
Market_Sell_Quantity(days)
Market_Purchase_Quantity(days)
Market_Expenses(days)
Market_Revenue(days)
Customer_Revenue (days)
Customer_delivery (days)
;
equations
NB_Balance
NB_Min_delivery
NB_Max_delivery
NB_Market_Expenses
NB_Market_Revenue
NB_Customer_Revenue
;
NB_Balance(days)… Farmer_Corn_Quantity(days) + Market_Purchase_Quantity(days) - Market_Sell_Quantity(days) =e= Customer_delivery(days);
NB_Min_delivery(days)… Customer_delivery(days) =g= Min_delivery;
NB_Max_delivery(days)… Customer_delivery(days) =l= Max_delivery;
NB_Market_Expenses(days)… Market_Expenses(days) =e= Market_Purchase_Quantity(days) * Market_price(days);
NB_Market_Revenue(days)… Market_Revenue(days) =e= Market_Sell_Quantity(days) * Market_price(days);
NB_Customer_Revenue(days)… Customer_Revenue(days) =e= Customer_price * Customer_delivery(days);
equations
targetfunction costs;
targetfunction… costs =e= sum(days,Market_Expenses(days)) - sum(days,Market_Revenue(days)) - sum(days,Customer_Revenue(days));
Model Corn /all/;
solve Corn using lp min costs;