Changes

Jump to navigation Jump to search
1,531 bytes added ,  08:41, 28 September 2018
no edit summary
Line 6: Line 6:     
==Examples==
 
==Examples==
'''ExampleS1: Chocolate Problem<br>'''
+
'''ExampleLP1: Chocolate Problem<br>'''
 
Shannon's Chocolates produces semisweet chocolate chips and milk chocolate chips at its plants in
 
Shannon's Chocolates produces semisweet chocolate chips and milk chocolate chips at its plants in
 
Wichita, KS and Moore, OK. The Wichita plant produces 3000 pounds of semisweet chips and 2000
 
Wichita, KS and Moore, OK. The Wichita plant produces 3000 pounds of semisweet chips and 2000
Line 56: Line 56:       −
'''ExampleS2: Coffee Problem<br>'''
+
'''ExampleLP2: Coffee Problem<br>'''
 
Fred's Coffee sells two blends of beans: Yusip Blend and Exotic Blend. Yusip Blend is one-half
 
Fred's Coffee sells two blends of beans: Yusip Blend and Exotic Blend. Yusip Blend is one-half
 
Costa Rican beans and one-half Ethiopian beans. Exotic Blend is one-quarter Costa Rican beans and
 
Costa Rican beans and one-half Ethiopian beans. Exotic Blend is one-quarter Costa Rican beans and
Line 102: Line 102:  
   yusip: 270,
 
   yusip: 270,
 
   exotic: 260 }</source>
 
   exotic: 260 }</source>
 +
 +
 +
'''ExampleLP3: Farmer Problem<br>'''
 +
Fred's Coffee sells two blends of beans: Yusip Blend and Exotic Blend. Yusip Blend is one-half
 +
Costa Rican beans and one-half Ethiopian beans. Exotic Blend is one-quarter Costa Rican beans and
 +
three-quarters Ethiopian beans. Profit on the Yusip Blend is $3.50 per pound, while profit on the Exotic
 +
Blend is $4.00 per pound. Each day Fred receives a shipment of 200 pounds of Costa Rican beans and
 +
330 pounds of Ethiopian beans to use for the two blends. How many pounds of each blend should be
 +
prepared each day to maximize profit? What is the maximum profit?<br>
 +
 +
<div id="z3lp3" style="font-size:16px">'''z3 code: Farmer Problem'''</div>
 +
<source lang="cpp">
 +
var solver = require('javascript-lp-solver'),
 +
    results,
 +
    model = {
 +
    "name": "farmer Problem",
 +
    "optimize": "profit",
 +
    "opType": "max",
 +
    "constraints": {
 +
        "storage": {
 +
            "max": 15000
 +
        },
 +
        "expense": {
 +
            "max": 4000
 +
        },
 +
"plant": {
 +
            "max": 75
 +
        }
 +
    },
 +
    "variables": {
 +
        "wheat": {
 +
            "storage": 120,
 +
            "expense": 110,
 +
"plant": 1,
 +
            "profit": 143
 +
        },
 +
        "barley": {
 +
            "storage": 210,
 +
            "expense": 30,
 +
"plant": 1,
 +
            "profit": 60
 +
        }
 +
    }
 +
};
 +
console.log(solver.Solve(model));</source>
 +
 +
<div style="font-size:18px">'''Solution:'''</div>
 +
<source lang="cpp">
 +
{ feasible: true,
 +
  result: 6315.625,
 +
  bounded: true,
 +
  wheat: 21.875,
 +
  barley: 53.125 }</source>
writer
1,835

edits

Navigation menu