Send Close Add comments: (status displays here)
Got it!  This site "robinsnyder.com" uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.  Note: This appears on each machine/browser from which this site is accessed.
Using Lindo
by RS  admin@robinsnyder.com : 1024 x 640


1. Using Lindo
There are many commercial linear programming packages that can be used to solve linear programming problems. Lindo is one such package. If the special command
//+L

is included in an "LPSolves" program, then Lindo compatible output is generated in the "Trace" output window. The following is the Lindo output generated by "LPSolves" for the house construction problem.
! (clear the lindo screen) ! This is a batch lindo program ! DOS command: lindo.exe < cbars-01.lpi > cbars-01.lpo ! where: cbars-01.lpi is the input file ! cbars-01.lpo is the output file ! (do not forget the paths for the files) PAGE 0 ! (do not pause after each screen) ! Title: Chocolate bars ! Author: Robin Snyder ! Source: Robin Snyder ! Generated: 1997/11/22 10:20 ! Variables: ! x1 = "Galaxy bars (lots)" ! x2 = "Continental bars (lots)" MAX 2 x1 + 3 x2 ! z = "profit ($)" SUBJECT TO ! "milk (tons)" 2) 3 x1 + x2 < 18 ! "cocoa (tons)" 3) x1 + 2 x2 < 12 ! "sugar (tons)" 4) 3 x1 + 3 x2 < 21 END GO SOLUTION RANGE QUIT

This can be run through Lindo in batch mode with the following DOS command-line command which, for convenience, is provided as part of the "LPSolves" output.
lindo.exe < cbars-01.lpi > cbars-01.lpo

The "<" is the input redirection specifier and ">" is the output redirection specifier. In this case, input is taken from file cbars-01.lpi and output is generated to file cbars-01.lpo. The output file cbars-01.lpo appears as follows.
LINDO/PC 5.01 (27 JULY 91) COPYRIGHT (C) 1991 LINDO SYSTEMS INC, CHICAGO, IL. LICENSED MATERIAL, ALL RIGHTS RESERVED. COPYING EXCEPT AS AUTHORIZED IS PROHIBITED. STUDENT VERSION - FOR EDUCATIONAL USE ONLY DISTRIBUTED BY WEST PUBLISHING COMPANY LP OPTIMUM FOUND AT STEP 2 OBJECTIVE FUNCTION VALUE 1) 19.000000 VARIABLE VALUE REDUCED COST X1 2.000000 .000000 X2 5.000000 .000000 ROW SLACK OR SURPLUS DUAL PRICES 2) 7.000000 .000000 3) .000000 1.000000 4) .000000 .333333 NO. ITERATIONS= 2 DO RANGE(SENSITIVITY) ANALYSIS? ? : RANGES IN WHICH THE BASIS IS UNCHANGED: OBJ COEFFICIENT RANGES VARIABLE CURRENT ALLOWABLE ALLOWABLE COEF INCREASE DECREASE X1 2.000000 1.000000 .500000 X2 3.000000 1.000000 1.000000 RIGHTHAND SIDE RANGES ROW CURRENT ALLOWABLE ALLOWABLE RHS INCREASE DECREASE 2 18.000000 INFINITY 7.000000 3 12.000000 2.000000 3.500000 4 21.000000 4.200000 3.000000

Note the following. Stripped of comments, the minimal Lindo batch program to solve the problem is as follows.
PAGE 0 MAX 2 x1 + 3 x2 SUBJECT TO 2) 3 x1 + x2 < 18 3) x1 + 2 x2 < 12 4) 3 x1 + 3 x2 < 21 END GO SOLUTION RANGE QUIT

Which is easier and/or better? It depends on your needs, resources, etc.

by RS  admin@robinsnyder.com : 1024 x 640