maximum and minimum value

Problems with modeling
Post Reply
Moin
User
User
Posts: 3
Joined: 6 years ago

maximum and minimum value

Post by Moin »

Hello,

I have problems with my model.

Base case: A farmer delivers between 50m³ and 100m³ of corn to his customer. For example, if the farmer has only 40m³, he has to procure the 10m³ on the corn market to reach the minimum quantity (50m³). If the farmer has more than 100m³, he can sell the surplus on the corn market.

I have defined the following conditions:

Farmer_Corn(d) + Market_Corn_purchase_quantity(d) = g = minimum_delivery
Farmer_Corn(d) - Market_Corn_sale_quantity(d) = l = maximum_delivery

I have set the condition that the farmer only buy or sell on the corn market when his deliver quantity is below or above the delivery limit.

But I have a erroror message: Model has an unbounded ray.

I would be happy for help. Tomorrow, I can upload the complete code.

(Sorry for my english)

With best regards
Steffen
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: maximum and minimum value

Post by Renger »

Hi Steffen

This is hard to answer as you don't provide the code that produces the error (see the "Rules" of this forum.

Cheers

Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Moin
User
User
Posts: 3
Joined: 6 years ago

Re: maximum and minimum value

Post by Moin »

Hello Renger,

thank you for your answer. I fixed my mistake. But now I have another problem :D

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;
User avatar
dirkse
Moderator
Moderator
Posts: 214
Joined: 7 years ago
Location: Fairfax, VA

Re: maximum and minimum value

Post by dirkse »

Steffen,

In your model you will always have non-unique solutions. For any solution, you can just add some arbitrary positive amount to both Market_Purchase_Quantity and Market_Sell_Quantity and you'll also get a solution.

What is perhaps unique about the solution is the difference between these two: MarketQuantity = Market_Purchase_Quantity - Market_Sell_Quantity. As long as the purchase and selling price is the same, you can just replace the difference Market_Purchase_Quantity - Market_Sell_Quantity in your model with the free variable MarketQuantity. If you like, you can create parameters Market_Purchase_Quantity and Market_Sell_Quantity and set them after the solve to be the positive and negative parts of MarketQuantity.

I'm not really sure what your question or problem or issue was. Hopefully the comments above help address it.

-Steve
Post Reply