How to use lingo...

What is lingo

LINGO is a mathematical modeling language designed for formulating and solving optimization problems, including linear, integer, and nonlinear programming problems. It is small but powerful.

What is this tutorial

This tutorial is a sample introduction to how to use lingo to solve some basic optimization problems. And this is the first essay of it.

What we need

Of course, we need lingo. But I just find lingo13 for Linux, so this tutorial is based on it…Click here to download
After you download it, you can extract the gz file and the Readme.pdf will tell you how to install lingo13 in you computer.

First program in lingo

Create an empty document in the folder lingo13, and type:

MODEL:
TITLE LP;
[OBJ] MAX=2*x+3*y;
[c1] 4*x+3*y<10;
[c2] 3*x+5*y<12;
END

then save it as sam.lng . Open the terminal in the folder lingo13 and type $ bin/linux64/lingo13 to launch lingo13, then use$ take sam.lng and$ goto execute the sam.lng.
And the program will solve the LP and give you the answer:

  Compiling model ...
  Structural analysis, pass 1 ...
  Scalarizing model ...
  Generating nonzero matrix ...
  Solving...

      Iters     Status     Objective        Suminf
          2    NUM_ERR      7.45          0.00
          2    UNKNOWN      7.45          0.00


  Global optimal solution found.
  Objective value:                              7.454545
  Infeasibilities:                              0.000000
  Total solver iterations:                             2

  Model Class:                                        LP

  Total variables:                      2
  Nonlinear variables:                  0
  Integer variables:                    0

  Total constraints:                    3
  Nonlinear constraints:                0

  Total nonzeros:                       6
  Nonlinear nonzeros:                   0


  Model Title: LP

                                Variable           Value        Reduced Cost
                                       X        1.272727            0.000000
                                       Y        1.636364            0.000000

                                     Row    Slack or Surplus      Dual Price
                                     OBJ        7.454545            1.000000
                                      C1        0.000000           0.9090909E-01
                                      C2        0.000000           0.5454545

when you see these lines, it means lingo have solved the problem. Model Class: LP tells you that this is a Linear Programing problem,and Objective value: 7.454545 gives you the optimal value of objective function. Variable and Value show exactly the optimal solution.

End of class 1

Congratulations! You achieve the most difficult part of the tutorial. Hope you can enjoy lingo13 and see you next time:-)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值