Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 An tutorial to AMPL. 2 Introduction Mathematical programming is a technique for solving certain kinds of problems --- notably maximizing profits and.

Similar presentations


Presentation on theme: "1 An tutorial to AMPL. 2 Introduction Mathematical programming is a technique for solving certain kinds of problems --- notably maximizing profits and."— Presentation transcript:

1 1 An tutorial to AMPL

2 2 Introduction Mathematical programming is a technique for solving certain kinds of problems --- notably maximizing profits and minimizing costs --- subject to constraints on resources, capacities, supplies, demands, and the like AMPL is a language for specifying such optimization problems

3 3 A two-variable linear program Tons per hour : Bands 200 Coils 140 Profit per ton : Bands $25 Coils $30 Maximum tons : Bands 6000 Coils 4000 If 40 hours of production time are available, how many tons of bands and how many tons of coils should be produced to bring in the greatest total profit?

4 4 A two-variable linear program X : the number of tons of bands to be produced Y : the number of tons of coils to be produced Maximize 25X+30Y Subject to : 0=<X<=6000 0=<Y<=4000 (X/200)+(Y/140)<=40

5 5 The two-variable linear program in AMPL Var X; Var Y; maximize Profit : 25*X+30*Y; subject to Time : (1/200)*X+(1/140)*Y<=40 subject to X_limit : 0<=X<=6000 subject to Y_limit : 0<=Y<=4000 The file – call it prod0.mod

6 6 The two-variable linear program in AMPL Solve prod0.mod ampl : model prod0.mod; ampl : solve; MINOS 5.5 : optimal solution found. 2 iterations, objective 192000 ampl : display X, Y; X=6000 Y=1400 ampl : quit;

7 7 The two-variable linear program in AMPL Each variable is named in a var statement Each constraint by a statement that begins with subject to and a name like X_limit or Time for the constraint Multiplication requires an explicit * operator ≦ rel ation is written <=

8 8 The two-variable linear program in AMPL model : reads the file into AMPL solve : to have AMPL translate your linear program, sends it to a linear program solver, and then return the answer MINOS 5.5 : indicates that AMPL uses version 5.5 of a solver called MINOS Often there is more than one solution that achieves the optimal objectives, however, in which case different solvers may report different optimal values for the variables

9 9 A linear programming model Figure 1-1 shows the production problem in algebraic notation

10 10 The linear programming model in AMPL

11 11 The linear programming model in AMPL

12 12 AMPL interfaces Refer to AMPL web site, www.ampl.com, for more up to date information and resourceswww.ampl.com For GUI – http://www.ampl.com/GUI/expermt.html http://www.ampl.com/GUI/expermt.html

13 13 Connecting CPLEX Server Step 1 連線 用 Putty 的 SSH 或者 在有裝 linux 的機器上執行 ssh -l scc 140.116.247.232 step 2 設定路徑 然後在自己家目錄下的.bash_profile 檔案裡 在 PATH=$PATH:$HOME/bin 這一行之後加入以下四行 ILOG_LICENSE_FILE=/ILOG/ilm/access.ilm export ILOG_LICENSE_FILE PATH=$PATH:/ILOG/ampl2002 PATH=$PATH:/ILOG/ilm

14 14 Connecting CPLEX Server step 3 執行 ampl model 2.mod; data 2.dat; solve; quit; Note Cplex Server 一次只能一個人進去執行


Download ppt "1 An tutorial to AMPL. 2 Introduction Mathematical programming is a technique for solving certain kinds of problems --- notably maximizing profits and."

Similar presentations


Ads by Google