KNITRO AMPL syntax?

215 views
Skip to first unread message

TowerG...@gmail.com

unread,
Jul 28, 2008, 10:47:43 AM7/28/08
to AMPL Modeling Language
Hi,

I am testing KNITRO solver on NEOS remote server. Should I use the
syntax of standard AMPL or the one like the example in the KNITRO
package?

Now my mod file is like. It can be used by other solver such as MINOS:

var x {j in 0..15443};
minimize obj: sum {j in 0..15443} x[j]*log(x[j]);
subject to daxbnd0: 1e-13 <= x[0] <= 0.000033154300013;
subject to daxbnd1: 1e-13 <= x[1] <= 0.000033154300013;
subject to daxbnd2: 1e-13 <= x[2] <= 0.000033154300013;
subject to daxbnd3: 1e-13 <= x[3] <= 0.000033154300013;
......

The running command is like:
reset;
option solver knitroampl;
solve;
display x;
display obj;

But the output is no variable.

Executing /home/neosotc/neos-5-solvers/knitro-ampl/knitro-driver.py
File exists
You are using the solver knitro.
Executing AMPL.
processing data.
processing commands.
Error:
No variables declared.
Error: amplin, line 47949 (offset 16623075):
Error (512) in /home/neosotc/neos-bin/ampl -Rw amplin
Error: x is not defined
Error: context: display >>> x; <<<

Could you please give me some help? Thanks.

Tower

Suleyman Demirel

unread,
Jul 28, 2008, 10:59:56 AM7/28/08
to am...@googlegroups.com
I am not sure what the problem is. But, you need to include everything in a single file. You can't have a model file and a running file separately. Keep everything in a solid single file.

This may solve your problem.
--
______________________________________________
Suleyman Demirel - Office: +1 734 615 9503

PhD Candidate in Operations Management
Stephen M. Ross School of Business
University of Michigan, Ann Arbor
Web: http://www.umich.edu/~sdemirel
______________________________________________

Michael A. Saunders

unread,
Jul 28, 2008, 12:36:00 PM7/28/08
to AMPL Modeling Language, TowerG...@gmail.com
Tower,

If all your variables are in the range 1e-13 to 3e-5,
you may find that general-purpose solvers like KNITRO
and MINOS will have trouble distinguishing them from
noise. The Feasibility tolerance in MINOS is 1e-6.
This means that MINOS is willing to let the variables
go *negative* by as much as 1e-13 - 1e-6 (that is,
by almost 1e-6). Conceivably it could help to scale
your variables up by a large factor like 1e+8, but
this may cause trouble elsewhere.

Sometimes special functions need special solvers.
In case your problem has only linear constraints
(and bounds on x), you could look at the PDCO solver
here, implemented in Matlab:

http://www.stanford.edu/group/SOL/software.html

It happens to work remarkably well with the entropy
objective function. It uses an interior method that
keeps the variables strictly within their bounds,
so you can specify the lower bounds to be 0.0 rather
than 1e-13.

Good luck,
Michael

Michael A. Saunders

unread,
Jul 28, 2008, 12:47:12 PM7/28/08
to AMPL Modeling Language, TowerG...@gmail.com
Tower,

I should have mentioned that KNITRO uses an interior
method also, so may already avoid the difficulty I
had in mind. (Sorry for this oversight.) Also,
you can reset the Feasibility tolerance in MINOS
to 1e-13 if you really want to, though it may cause
trouble elsewhere.

Not to say that numerical optimization is a minefield(!).
But it doesn't hurt to be conscious of scaling, tolerances,
etc.

Michael

Robert Fourer

unread,
Jul 28, 2008, 11:20:48 PM7/28/08
to am...@googlegroups.com, TowerG...@gmail.com

Are you using the web interface to AMPL/KNITRO (at
http://neos.mcs.anl.gov/neos/solvers/cp:KNITRO/AMPL.html)? Then you can
specify a model file and if desired a separate data file and commands file.
Your commands file could be

solve;
display x;
display obj;

Do not include "reset;" or "option solver ...;" in the commands file,
though; NEOS takes care of these things.

Bob Fourer
4...@ampl.com

mail mail

unread,
Jul 29, 2008, 10:30:30 AM7/29/08
to Michael A. Saunders, AMPL Modeling Language
Dear Michael,

Thank you very much for the useful information.

You are quite right. I am encountering the problem you described. I
plan to scale
the variables up by a large factor like 1e+8 or larger.

As you mentioned, SOL can solve the entropy object function well. But the
constraints in my problem also has non-linear ones such as some sum {
x[i]*log(x[i]) }.
Can SOL also handle this well?

I tried KNITRO/AMPL yesterday. The problem characteristics is:

Number of variables: 8510
bounded below: 0
bounded above: 0
bounded below and above: 8510
fixed: 0
free: 0
Number of constraints: 6438
linear equalities: 5411
nonlinear equalities: 0
linear inequalities: 0
nonlinear inequalities: 1027
range: 0
Number of nonzeros in Jacobian: 198410
Number of nonzeros in Hessian: 17607844

All the nonlinear inequalities contains something like x[i]*log(x[i]).
What kind of solver
do you think is suitable for problem like this?

Thanks in advance!

Regards,
Tower

Tower

unread,
Jul 29, 2008, 10:36:22 AM7/29/08
to 4...@ampl.com, am...@googlegroups.com
Thanks Robert.

I have done as you said. Unfortunately, there is memory limitation. It
can't perform the computation. :(

Regards,
Tower

Suleyman Demirel

unread,
Jul 29, 2008, 6:49:47 AM7/29/08
to am...@googlegroups.com
You may also try Kestrel, which allows Ampl to communicate with Neos Servers rather than you upload your file. This way, you can have multiple files.

Follow the link below.

http://www-neos.mcs.anl.gov/neos/kestrel.html

And one more thing. Why don't you try option solver knitro rather than option solver knitroampl;?

On Mon, Jul 28, 2008 at 11:20 PM, Robert Fourer <4...@ampl.com> wrote:

Tower

unread,
Jul 30, 2008, 12:46:37 PM7/30/08
to am...@googlegroups.com
Hi,

In KNITRO 5.2 manual, I am told to use knitroampl rather than knitro.

Now I can run it locally. Is there any different between local running
and Kestrel?

Regards,
Tower

Suleyman Demirel

unread,
Jul 30, 2008, 12:56:37 PM7/30/08
to am...@googlegroups.com
I don't think there should be a difference. Kestrel allows you to use solvers that you don't own locally. But you need to incur the waiting cost, which is usually an additional 5 minutes on top of your solution time.

Robert Fourer

unread,
Jul 30, 2008, 5:04:35 PM7/30/08
to am...@googlegroups.com

What kind of memory limitation? You will have to explain what happened and
report all of the messages you received, in order for anyone to help you
with such a problem.

Tower

unread,
Jul 31, 2008, 5:43:46 PM7/31/08
to am...@googlegroups.com
I forgot the save the screen. The limitation is that I can't use more
memory than available.
Now I am using local machine with 4GB memory and it works now.

Thanks, Robert.

Reply all
Reply to author
Forward
0 new messages