180 likes | 403 Views
An tutorial to AMPL. 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
E N D
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
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?
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
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
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;
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 • ≦ relation is written <=
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
A linear programming model • Figure 1-1 shows the production problem in algebraic notation
AMPL interfaces • Refer to AMPL web site, www.ampl.com, for more up to date information and resources • For GUI • http://www.ampl.com/GUI/expermt.html
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
Connecting CPLEX Server • step 3 執行 ampl model 2.mod; data 2.dat; solve; quit; • Note Cplex Server一次只能一個人進去執行