A collection of linear programming models discussed in OR course, written in AMPL
Be sure to download one of the AMPL solvers and to add the correct path in the right place. Once you open a model you may run into errors like
ampl: model model.mod
ampl: solve;
Cannot find "cplex"
Panic you may not.
ampl
cannot find the solver specified in your machine: just specify the full path to the solver you wish to use. For example
option solver "/bin/ampl-solvers/cbc-linux64/cbc";
Once you downloaded all necessary software
- simply
$ cd `folder where model is .. e.g models/contadino/`
$ ampl
ampl: model model.mod
ampl: solve;
CBC 2.9.9 optimal, objective 44000
2 iterations
ampl: display x_lattuga, x_patata, resa;
x_lattuga = 8
x_patata = 4
resa = 44000
- in case the model comes with a
data file
(like this one), then you should
$ cd `folder where model is .. e.g models/frigoriferi/`
$ ampl
ampl: model frigoriferi.mod
ampl: data frigoriferi.dat
ampl: solve;
CPLEX 12.7.1.0: optimal solution; objective 420
7 dual simplex iterations (0 in phase I)
ampl: display x, moving_cost;
x :=
A '1' 0
A '2' 0
A '3' 10
A '4' 40
B '1' 0
B '2' 50
B '3' 20
B '4' 0
C '1' 10
C '2' 10
C '3' 0
C '4' 0
;
moving_cost = 420
- finally, if there is also a
run file
(like this one), just
$ cd `folder where model is .. e.g models/contadino/`
$ ampl
ampl: include telecomandi.run;
CPLEX 12.6.3.0: optimal integer solution; objective 34
3 MIP simplex iterations
0 branch-and-bound nodes
No basis.
x [*] :=
A 6
B 2
;
total_gain = 34
name | category | solution | cost/optimum |
---|---|---|---|
Contadino | mix-ottimo di produzione |
x_patata = 4, x_lattuga = 8 |
44000 |
Telecomandi | mix-ottimo di produzione |
x_A = 6, x_B = 2 |
34 |
Produzione forza lavoro | mix-ottimo di produzione |
x_1 = 430, x_2 = 200, x_3 = 508 |
42300 |
Produzione capacità eccedente | mix-ottimo di produzione |
factory_1 = 500, factory_2 = 600, factory_3 = 300 |
14900 |
Raffineria | mix-ottimo di produzione |
1 super = 857.143, 1 verde = 571.429, 2 super = 2571.43, 2 verde = 5142.86 |
1200000 |
Dieta | copertura di costo minimo |
x_verdura = 5, x_carne = 0, x_frutta = 0 |
20 |
Indagine di mercato | copertura di costo minimo |
x_mattino = 1, x_sera = 666 |
1066.7 |
Turni in ospedale | copertura di costo minimo |
fri = 3, mon = 4, sat = 4, sun = 3, thu = 4, tue = 3, wed = 3 |
24 |
Localizzazione di servizi | copertura di costo minimo |
2, 4 |
2 |
Frigoriferi | trasporti (bilanciato) |
x_A3 = 10, x_A4 = 40, x_B2 = 50, x_B3 = 20, x_C1 = 10, x_C2 = 10 |
420 |
Piani di investimento | multi-periodale |
x_A1 = 10000, x_A3 = 14000, x_D5 = 19600 |
25480 |
Produzione su più linee | min-max |
x_13 = 20, x_23 = 30, x_32 = 16, x_41 = 20 |
86 |
Scheduling just-in-time | min-abs |
start_1 = 26, start_2 = 31, start_3 = 38, start_4 = 45, start_5 = 52 |
4500 |
Localizzazione con costi fissi | logico |
dnf |
dnf |
Portfolio optimization | logico |
A = 22727.3, C = 70454.5, E = 6818.18 |
39538.6 |
Assunzione multiperiodale di personale | logico |
1 = 14, 2 = 13 |
198500 |
Remember to add a semicolon at the end of mostly all commands ..
The github issue tracker is only for bug reports and feature requests.
Fork | Patch | Push | Pull request
Apache License Version 2.0, January 2004