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.
!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;

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

[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) );
@for(months(j) | j #GE# 2: [maxhire] x(j)-x(j-1)<=40 );
@for(months(j) | j #GE# 2: [maxfire] x(j-1)-x(j)<=40 );
@for(months(j) | j #GE# 2: [hirecost] hirecst*x(j)-hirecst*x(j-1)-t(j)<=0 );
@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));

demand = 5300 5100 4400 2800 4100 4800 6000 7100 7300 7800 7600 6400;


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.