**THIS CODE WAS WRITTEN FOR THE CONSTRAINT-BASED MODELING WORKSHOP J.REED (1/2008)
*Consider two variables A and B, which are the amount of toy cars and trucks you can produce.
*Do to resource limitations you can make no more than 60 cars a day and no more than 50 trucks a day.
* 0 <= cars <= 60
* 0 <= trucks <= 50
*You are also limited by shipping such that the number of cars plus twice the number of trucks must be less than 150.
* cars + 2*trucks <= 150
*You can sell the toys at $20/car and $30/truck your earnings (Z) are given by:
* profit = 20*cars + 30*trucks
variables
cars
trucks
profit;
equations
constraint1
constraint2
constraint3
earnings;
constraint1.. cars=l=60;
constraint2.. trucks=l=50;
constraint3.. cars+2*trucks=l=150;
earnings.. profit=e=20*cars+30*trucks;
cars.lo=0;
trucks.lo=0;
model production /all/;
solve production using lp maximizing profit;