0% found this document useful (0 votes)
215 views2 pages

Some Sample Inputs For LINGO

This document provides sample inputs for solving linear programs using LINGO software. It includes an example model for production planning over 12 months that minimizes costs subject to constraints. The model includes variables for production, overtime, inventory and hiring/firing costs. It demonstrates some of LINGO's syntax like using sets to define months and commenting lines with !.

Uploaded by

David
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
215 views2 pages

Some Sample Inputs For LINGO

This document provides sample inputs for solving linear programs using LINGO software. It includes an example model for production planning over 12 months that minimizes costs subject to constraints. The model includes variables for production, overtime, inventory and hiring/firing costs. It demonstrates some of LINGO's syntax like using sets to define months and commenting lines with !.

Uploaded by

David
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

30/08/2017 LINDO/LINGO

MATH 441 Section 201


Some sample inputs for LINGO
Online Course Material

Linear Programming has fairly wide applicability and so in a first course it is also nice to see some software that can assist you in solving quite large LP's. The
windows interface is quite friendly (you should have used the old packages!) and you will discover that everything runs extremely quickly. The sensitivity
analysis is readily available and performs many of the standard computations. We get dual variables given to us. You will quickly discover that the value of the
dual prices is not in providing some computational aid to solve some related LP's (which could be done with alarming speed from scratch by LINDO) but to
provide some predictive power and aid analysis of the model.

LINGO is a higher level language from which you can use Linear programming. The LP model is typically formulated in more general terms with access to data
files containing for example, the requirements or availablities of raw materials and sets of variables etc. Examples throught the HELP function may be useful.
Please note that there is some careful syntax to trip you up. Each `line' (say a constraint or the objective function) ends with a semicolon ; and you can embed
comments using !comment here between exclamation and semicolon; Also multiplication is expressely done with * key and is not implicit as in LINDO. Many
other pitfalls as well. Good luck.
MODEL:
!xi=production in month i (not on overtime) so that the number of workers is xi/20;
!yi=overtime production in month i;
!zi=inventory carried forward from month i to month i+1;
!t_i=hiring/firing costs in month i;

Sets:
months / JAN..DEC/: demand, x, y, z, t;
endsets

[objective] Min=@sum( months(j) : 20*y(j)+8*z(j)+t(j) );

[lastyear] xprev=290;
[janbalance] 20*x(1)+y(1)-z(1)=demand(1);
@for(months(j) | j #GE# 2 : [balance] z(j-1)+20*x(j)+y(j)-z(j)=demand(j));
[decinventory] z(12)=0;
@for(months(j) : [overtime] y(j)<6*x(j) );
[hirejan]x(1)-xprev<=40;
@for(months(j) | j #GE# 2: [maxhire] x(j)-x(j-1)<=40 );
[firejan]xprev-x(1)<=40;
@for(months(j) | j #GE# 2: [maxfire] x(j-1)-x(j)<=40 );
[hirecstj]hirecst*x(1)-hirecst*xprev<=t(1);
@for(months(j) | j #GE# 2: [hirecost] hirecst*x(j)-hirecst*x(j-1)-t(j)<=0 );
http://www.math.ubc.ca/~anstee/math441/441LINGOfiles.html 1/2
30/08/2017 LINDO/LINGO

[firecstj]firecst*xprev-firecst*x(1)<=t(1);
@for(months(j) | j #GE# 2: [firecost] firecst*x(j-1)-firecst*x(j)-t(j)<=0 );
@for(months(j) : @gin(x));
@for(months(j) : @gin(y));

Data:
demand = 5300 5100 4400 2800 4100 4800 6000 7100 7300 7800 7600 6400;
hirecst=300;
firecst=6000;
enddata

end

Some of the syntax includes sets: endsets Data: enddata Model MAX= or MIN= Most lines/constraints end in semicolons. This can be a useful tool in
debugging. You can comment out a line merely by putting a ! at the beginning and everything up to the semicolon in that line becomes a comment. I had some
difficulty getting this simple example formulated. It seemed convenient to use the special syntax for months (also works for days) creating the set months
JAN..DEC consisting of all 12 months in 3 character abbreviations. But when I wanted to refer to x(JAN) in the model I had to refer to x(1) where JAN was the
first entry of the set months. I introduced labels to every constraint for convenience while debugging but it helps to read the output.

http://www.math.ubc.ca/~anstee/math441/441LINGOfiles.html 2/2

You might also like