Showing posts with label AMPL. Show all posts
Showing posts with label AMPL. Show all posts

Friday, July 29, 2011

Software development and Customer support position @ AMPL

AMPL Optimization is looking for an optimization expert to join
http://www.ampl.com/OPENINGS/2011July.html
Specific responsibilities will include the following:
  • Create and solver interfaces, database handlers, and other AMPL-related software
  • Supervise systems for software distribution, licensing, and invoicing, with activities including design, implementation, maintenance, and customer support
  • Manage and develop AMPL's online availability through repositories & servers such as netlib, COIN-OR, NEOS, and future "cloud" offerings
  • Assist in support of AMPL users and specific customer projects
  • Participate in internal discussions on AMPL's development and marketing strategy
Qualified applicants will have the following preparation:
  • Study of optimization and related topics in an MS, PhD, or comparable advanced degree program
  • Experience carrying out research in optimization or pursuing applications of optimization to real problems
  • Proficiency in software design and development using a variety of languages and platforms, with a willingness and ability to pick up new systems quickly
  • Ability to communicate effectively (in person, over the phone, and in writing) with a variety of optimization users and customer representatives
  • Interest in helping to run a business and in working independently



Wednesday, March 9, 2011

dump/restore function in AMPL by Bob Fourer

Sometimes solving a mathematical programming problem is a quite time consuming. So we need to store the solution in the file and hope to restore it next time when we load the model and data. Hopefully AMPL is capable of doing that:

If you give the command of the form

  write bfilename;

before the solve command, then the solution file that the solver sends back
to AMPL will be a permanent file "filename.sol" rather than a temporary
file.  Then if you leave AMPL and later return, you can read back the model
and data files -- and whatever else you need to do to return the current
problem to the state it was in at the previous solve -- and then read back
the previous solution with the command

  solution filename.sol;

There is not a facility to dump the entire state of AMPL at a certain point,
however.

Bob Fourer
4er@ampl.com

Sunday, March 6, 2011

rounding in AMPL

precision(x,n) rounds x to n significant digits
round(x,n) rounds x to n decimal places

How to Model x[k,i] != x[k,j] in AMPL

> > subject to riga {k in ELEMENTI,i in ELEMENTI,j in ELEMENTI: j != i} :
> > x[k,i] != x[k,j] ;

This is not correct

>
> The != is a logical relational operator, not a constraint relation.
> Put another way, constraints in a math program are limited to =, <=
> and >= (unless the model is going to a constraint solver, but I don't
> think AMPL supports constraint solvers yet).  So AMPL saw this as a
> logical constraint, tried to convert it to an indicator constraint (if
> logical condition then algebraic relation), failed and burped up the
> error message.
>
> Since x is integer in {0, ..., n}, you can enforce x[k, i] != x[k, j]
> by introducing a binary variable z[k, i, j] and adding constraints
>
> x[k, i] <= x[k, j] - 1 + (n + 1)*z[k, i, j]
> x[k, j] <= x[k, i] - 1 + (n + 1)*(1 - z[k, i, j])
>

AMPL:Tutorial

Installing AMPL

Windows users:
  1. Download the package amplcml.zip (this link is from the AMPL home page).
  2. Unzip the file amplcml.zip (double-click it).
  3. The unzipped amplcml/ folder contains, among others:
    • sw.exe: a command line interface;
    • ampl.exe: the true AMPL modeler;
    • cplex.exe: a solver for Linear and Integer Programming problems;
    • minos.exe: a solver for Nonlinear Programming problems.
  4. Create a new folder C:\Programs\AMPL (you may instead create the AMPL folder on the desktop, depending on your preference or if C:\Programs is read-only), and move all the files (the four above AND all the others) into the newly created AMPL folder.
  5. For your convenience, create a link to sw.exe and place it on your desktop.
  6. Double-click on sw.exe (either the link or the real file).
  7. A window appears with a prompt "sw:". Type "ampl". The AMPL prompt appears.
You can now enter your optimization model. Note: When using AMPL, the working directory is C:\Programs\AMPL or wherever you placed the sw.exe file. This means that, if you are using model files, you should place ALL these files in the same folder where sw.exe is located, otherwise you would have to specify the full path (e.g. model "C:\Documents and settings\pietro\Desktop\tin-can.mod").

Using AMPL

You can also create model files and data files with your favorite text editor (Notepad, WinEDT, etc.) and use the ampl prompt simply to specify model and data before solving the problem. Examples:
Notice: clicking on these .mod files may suggest Windows that these are music files. You may want to right-click on them and select "Save link as..." instead. In order to solve these models, start AMPL and type, at the prompt:
 ampl: model tin-can.mod;
Then set the proper solver for each problem (Minos for tin-can.mod and all Nonlinear Programming problems, Cplex for all Linear and Integer Programming problems).
 ampl: option solver minos;
(notice the ";" at the end of each command). Finally, give the "solve;" command to solve it:
 ampl: solve;
At this point, AMPL calls the Minos solver, and when Minos is done you will see again the AMPL prompt. At this point, if the solver did not encounter errors, you should be able to visualize the value of the variables:
 ampl: display radius, height;
http://coral.ie.lehigh.edu/~belotti/teaching/ampl/ampl.html

ampl: include branch_and_bound.run
reset

AMPL update

1.  AMPL Solver Library
     www.netlib.org/ampl/solvers.tar

2. AMPL FILE FORMAT

 If it would help to take a look at a solver output file, give a command like
"write gTEST;" before "solve;". Then a text version of the output file will
be written to TEST.sol. (Normally this ".sol" file is deleted after AMPL
reads its contents, but the "write" command causes it to be saved.)

3. piecewise linear for minimizing concave
Minimizing a concave piecewise linear function can be done using
binary variables.  Perhaps the second half of
http://orinanobworld.blogspot.com/2010/10/piecewise-linear-functions-in-math.html
(dealing with economies of scale) will shed some light.  If your
piecewise linear function is discontinuous, see
http://orinanobworld.blogspot.com/2010/12/modeling-all-units-discount.html.

4. variable relaxation in AMPL

You can use the ".relax" suffix documented in the AMPL book (section 11.4
under "Relaxing integrality"):
   var anr {i in 1..m} integer >= nrmin[i] <= nrmax[i];
   let {i in 2..m} anr[i].relax := 1;
Note that you can relax an integer variable but you can't "unrelax" a
variable that hasn't been declared as integer (or binary).
One refinement not mentioned in the book is that if you set .relax of a
variable to 2, then the variable will be treated as integer by AMPL's
presolve phase, after which it will be sent as a relaxed variable to the
solver.



Tuesday, March 1, 2011

Generate mps file for the optimization problem with data

http://www.ampl.com/FAQ/#HowdoIwriteanMPSfileformyproblem

ampl: model diet.mod;
 ampl: data diet2a.dat;

ampl: option auxfiles rc; (generating auxiliary files for rows and columns)

ampl: write mdiet2;

Friday, February 25, 2011

Finding multiple optimal solutions of a BILP

It's possible to get CPLEX to return more than one optimal objective value,
using the "solution pool" feature described on page 71 of the CPLEX-for-AMPL
user guide, www.ampl.com/BOOKLETS/amplcplex121userguide.pdf.  By default
CPLEX gives you the incumbent feasible solutions that it found, however,
only one of which is optimal.  I have found the following settings useful
for generating multiple solutions all having the optimal objective value:

  option cplex_options 'poolstub=solfile populate=1 poolintensity=4
poolagap=0';

You might want to experiment with other settings as well.  As explained in
the user guide, you will need to write an AMPL "for" loop to retrieve the
different solutions one by one for display or processing.