首页 > 学院 > 开发设计 > 正文

How to use lingo...

2019-11-06 07:32:41
字体:
来源:转载
供稿:网友

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:-)


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表