MINLP

281 views
Skip to first unread message

nadir

unread,
Apr 4, 2010, 7:20:08 AM4/4/10
to AMPL Modeling Language
How to install MINLP on Linux or Windows?
I use ampl.

Hans Mittelmann

unread,
Apr 4, 2010, 8:52:33 PM4/4/10
to AMPL Modeling Language
It is not clear what you mean with MINLP. If you mean a free MINLP
solver with AMPL
interface then there are
BONMIN http://www.coin-or.org/projects/Bonmin.xml for convex
problems and
COUENNE http://www.coin-or.org/projects/Couenne.xml for nonconvex
problems.
You can try them at NEOS or download and install them under Linux.

nadir

unread,
Apr 5, 2010, 9:22:03 AM4/5/10
to AMPL Modeling Language
I can not run BONMIN
I open archive Bonmin-1.3.2.tgz. in folder Bonmin-1.3.2
Then

2. cd Bonmin-1.3.2
3. ./configure -C
4. make
5. make test
6. make install
Everything went fine, but it was the following error
"configure: WARNING: Failed to find a Fortran compiler!"

Maybe you need to install Fortran?


I wanted to compile separately Bonmin
Go to folder Bonmin
2. cd Bonmin
3. ./configure -C
4. make
But make file not found
"make: *** No targets specified and not found make-file. Stop."

nadir

unread,
Apr 5, 2010, 9:27:59 AM4/5/10
to AMPL Modeling Language
If you are ready binaries. For AMPL?

Robert Fourer

unread,
Apr 5, 2010, 11:04:25 AM4/5/10
to am...@googlegroups.com, nadir
If you're just interested in running the COIN-OR MINLP solvers under Windows
or Linux, then you do not need to bother with compilers, as there are
binaries available from COIN-OR. You can download the binaries from

www.coin-or.org/download/binary/Bonmin
www.coin-or.org/download/binary/Couenne

These binaries contain AMPL interfaces, so they can be used from AMPL by
putting them in your search path and setting "option solver bonmin;" or
"option solver couenne;".

Bonmin is designed for convex MINLPs, though it will try to find a good
solution for nonconvex ones. Couenne is designed to find optimal solutions
even to nonconvex MINLPs. Of course as with all very hard problems, success
is not guaranteed, and some experimentation with formulations and
algorithmic options may be necessary. Problems should be reported to the
appropriate COIN-OR project managers; see the project home pages at
www.coin-or.org for details.

Bob Fourer
4...@ampl.com

nadir

unread,
Apr 5, 2010, 11:41:47 AM4/5/10
to AMPL Modeling Language
Thanks
All turned out.
I solve the problem of reservation of seats in the hotel.

set P; #numbers in hotel
set N;

param dn {j in P};
param dk {j in P};
param dn1 {j in P};
param dk1 {j in P};

var zakaz {j in P} binary;
var daz {j in P} integer;
var dav {j in P} integer;

#param k {j in P} = dz[j]-dv[j]+1;

maximize Total_Profit: sum {j in P} (dav[j]-daz[j]+1+1) * zakaz[j];


#subject to Time: sum {j in P} (dav[j]-daz[j]+1) * zakaz[j] <= b;
#subject to Limit {j in P}: 0 <= zakaz[j] <= dv[j];
#subject to Limit: zakaz[1]*dz[1]<=zakaz[2]*dz[2];

subject to Limit {j in P}: dn[j] <= daz[j] <= dk[j];
subject to Limit1 {j in P}: dn1[j] <= dav[j] <= dk1[j];


subject to stp {i in N}: dav[i]*zakaz[i] <= daz[i+1]*zakaz[i+1] ;

#subject: zakaz[1]=1;
####################### DАТА #########################
data;

set P := 1 2 3 4;
set N := 1 2 3 ;
param: dn dk dn1 dk1 :=
1 1 1 7 7
2 5 5 8 8
3 7 9 9 9
4 9 9 10 10;

nadir

unread,
Apr 6, 2010, 2:39:50 PM4/6/10
to AMPL Modeling Language
i CAN'T RUN Couenne

eRROR:
bonmin:
ANALYSIS TEST: <BREAK>
*** Error: ifnl not implemented
exit code 255

Pietro Belotti

unread,
Apr 6, 2010, 2:47:18 PM4/6/10
to am...@googlegroups.com
Does your model contain an expression of the form:

if (a) then b else c

where b and c are expressions and a is a condition? Couenne cannot
read (yet) a conditional expression (defined by the nonlinear AMPL
operator "ifnl"). If there is a way to define that expression that
does not require an "if" (for instance because the "if" is used to
define an absolute value), Couenne should be able to handle it.

Pietro Belotti

> --
> You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
> To post to this group, send email to am...@googlegroups.com.
> To unsubscribe from this group, send email to ampl+uns...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/ampl?hl=en.

nadir

unread,
Apr 6, 2010, 4:19:21 PM4/6/10
to AMPL Modeling Language
I corrected:

subject to hL_Ss1 {i in P, j in P: i<>j}:
zakaz[i,j]=ifnl dav[i]<=daz[j] then daz[j]-dav[i] else dav[i]-daz[j];

but but anyway error:

ifnl is not defined
context: ifnl >>> dav[ <<< i]<=daz[j] then daz[j]-dav[i] else dav[i]-
daz[j];
command returned 2

Pietro Belotti

unread,
Apr 6, 2010, 4:29:26 PM4/6/10
to am...@googlegroups.com
Try the following:

subject to hL_Ss1 {i in P, j in P: i<>j}:

zakaz [i,j] = abs (dav [i] - daz [j]);

The right-hand side of your constraint is indeed the definition of the
absolute value of daz[j]-dav[i].

Pietro

nadir

unread,
Apr 6, 2010, 4:46:38 PM4/6/10
to AMPL Modeling Language
Thanks
Message has been deleted

nadir

unread,
Apr 7, 2010, 6:28:56 AM4/7/10
to AMPL Modeling Language
How to make a strict inequality?
for example:

subject to stp {i in N}: dav[i]*zakaz[i] < daz[i+1]*zakaz[i+1] ;

Pietro Belotti

unread,
Apr 7, 2010, 12:02:39 PM4/7/10
to am...@googlegroups.com
I suggest

param epsilon > 0 default 1e-5;

subject to stp {i in N}: dav[i]*zakaz[i] <= daz[i+1]*zakaz[i+1] - epsilon;

However, if, for your particular problem, the product of dav and zakaz
is known to be an integer or a multiple of k, you can safely set
epsilon to k.

Pietro

nadir

unread,
Apr 7, 2010, 3:33:07 PM4/7/10
to AMPL Modeling Language
However, if, for your particular problem, the product of dav and zakaz
is known to be an integer or a multiple of k, you can safely set
epsilon to k.

k????


set P;


param epsilon > 0 default 1e-5;

param dn {j in P} integer;
param dk {j in P} integer;
param dn1 {j in P} integer;
param dk1 {j in P} integer;
var zakaz {i in P, j in P} integer;
var zakaz1 {i in P, j in P} binary;
var zakaz2 {i in P, j in P} binary;


var daz {j in P} integer;
var dav {j in P} integer;

maximize Total_Profit {i in P, j in P :i<>j}: (zakaz1[i,j]
+zakaz2[i,j]);
maximize Total_Profit2 {i in P}: dav[i]-daz[i];
minimize Total_Profit3 {i in P, j in P :i<>j}: zakaz[i,j];

#minimize Total_Profit4 {i in P}: daz[i];

subject to Limit {j in P}: dn[j] <= daz[j] <= dk[j];
subject to Limit1 {j in P}: dn1[j] <= dav[j] <= dk1[j];

subject to hL_Ss1 {i in P, j in P: i<>j}:


zakaz [i,j] = abs (dav [i] - daz [j]);

subject to hL_Ss {i in P, j in P: i<>j}:
dav[i]*zakaz1[i,j]<=daz[j]*zakaz2[i,j]+epsilon;

####################### DАТА #########################
data;
set P := 1 2 3;


param: dn dk dn1 dk1 :=

1 11 13 20 22
2 1 6 5 5
3 4 8 7 12
;

Pietro Belotti

unread,
Apr 7, 2010, 4:55:57 PM4/7/10
to am...@googlegroups.com
OK, your variables are indeed integer. In this case k=1, so you can write

subject to stp {i in N}: dav[i]*zakaz[i] <= daz[i+1]*zakaz[i+1] - 1;

Notice the minus sign. It needs to be minus and not plus as you write
in your model (before epsilon). Also, your model has many objective
functions. Couenne, if you still plan to use it, only works with one
objective function.

Pietro

nadir

unread,
Apr 8, 2010, 4:17:28 AM4/8/10
to AMPL Modeling Language
This model booking rooms at the hotel.
daz-arrival date
dav-the date of departure from the room.
zakaz-appropriate application
Therefore dav [i] <daz [i +1]

I use Couenne solver
He gives very good results.


This restriction does not help.
subject to stp (i in N): dav [i] * zakaz [i] <= daz [i +1] * zakaz [i
+1] - 1;
In some cases, dav [i] = daz [i +1]

Pietro Belotti

unread,
Apr 8, 2010, 8:15:11 AM4/8/10
to am...@googlegroups.com
Then I guess you should add the constraint

subject to stp2 (i in N): dav [i] <= daz [i +1] - 1;

Pietro

nadir

unread,
Apr 8, 2010, 12:23:18 PM4/8/10
to AMPL Modeling Language
Error (:
Warning, could not install cutoff - negative objective index

Pietro Belotti

unread,
Apr 8, 2010, 2:08:20 PM4/8/10
to am...@googlegroups.com
Please give more information. First of all, it's a *warning*, not an
error, so it won't make Couenne stop. Second, it is probably caused by
the way the objective function is written, but we need to know a
little more.

Pietro

On Thu, Apr 8, 2010 at 12:23 PM, nadir <nadir.a...@googlemail.com> wrote:
> Error (:
> Warning, could not install cutoff - negative objective index
>

nadir

unread,
Apr 12, 2010, 5:18:02 AM4/12/10
to AMPL Modeling Language
If I pick up such data is Ampl an error
"
presolve, variable dav[2]:
impossible deduced bounds: lower = 10, upper = 9;
difference = 1
command returned 0
"

set P;


param dn {j in P} integer;
param dk {j in P} integer;
param dn1 {j in P} integer;
param dk1 {j in P} integer;

var zakaz {i in P, j in P} integer;

var daz {j in P} integer;
var dav {j in P} integer;

minimize Total_Profit: sum {i in P, j in P:i<j} zakaz[i,j];

subject to Limit {j in P}: dn[j] <= daz[j] <= dk[j];
subject to Limit1 {j in P}: dn1[j] <= dav[j] <= dk1[j];

subject to hL_Ss1 {i in P, j in P: i<j}:
zakaz [i,j] = abs (dav [i] - daz [j]);

subject to hL_Ss2 {i in P: i<>4}:
dav [i] <= (daz [i+1]-1);

####################### DАТА #########################

data;
set P := 1 2 3 4;


param: dn dk dn1 dk1 :=

1 1 2 4 5
2 4 8 10 12
3 10 10 18 22
4 20 23 26 28
;

nadir

unread,
Apr 12, 2010, 5:20:53 AM4/12/10
to AMPL Modeling Language
How to make non-binding subject?

Robert Fourer

unread,
Apr 12, 2010, 2:32:21 PM4/12/10
to am...@googlegroups.com, nadir
AMPL's presolve phase has deduced that your constraints imply a lower bound of 10 and an upper bound of 9 on variable dav[2], which means no feasible solution is possible. Here's an example of how one finds the cause of such an error. First I looked to see what constraints dav[2] appears in:

ampl: expand dav[2];
Coefficients of dav[2]:
Limit1[2] 1
hL_Ss1[2,3] 0 + nonlinear
hL_Ss1[2,4] 0 + nonlinear
hL_Ss2[2] 1

Since presolve only works on linear constraints, I asked to look at the two constraints that involve dav[2] and that do not have any nonlinear terms:

ampl: expand Limit1[2];
subject to Limit1[2]:
10 <= dav[2] <= 12;

ampl: expand hL_Ss2[2];
subject to hL_Ss2[2]:
-daz[3] + dav[2] <= -1;

A little further investigation showed that daz[3] is bounded by constraint Limit[3]:

ampl: expand Limit[3];
subject to Limit[3]:
daz[3] = 10;

So it is seen that while Limit1[2] requires dav[2] >= 10, hL_Ss2[2] implies dav[2] <= daz[3] - 1 = 9.

If you want to solve this problem efficiently then it would be well to replace the nonlinear constraint

zakaz[i,j] = abs (dav[i] - daz[j])

by the two linear constraints

zakaz[i,j] >= dav[i] - daz[j]
zakaz[i,j] >= daz[j] - dav[i]

Bob Fourer
4...@ampl.com


> -----Original Message-----
> From: am...@googlegroups.com [mailto:am...@googlegroups.com]
> On Behalf Of nadir [nadir.a...@googlemail.com]
> Sent: Monday, April 12, 2010 4:18 AM
> To: AMPL Modeling Language

nadir

unread,
Apr 12, 2010, 5:12:56 PM4/12/10
to AMPL Modeling Language
how you can apply the following restriction

subject to hL_Ss2 {i in P, j in P: j<>3, i<j}:

dav[i]*zakaz[i,j+1] <= (daz [j+1]-1)*zakaz1[i,j+1];

nadir

unread,
Apr 27, 2010, 1:50:06 PM4/27/10
to AMPL Modeling Language

Can I use AMPL with dates?
Example
2010-04-27<=daz<=2010-04-30

And date dif function?

Robert Fourer

unread,
Apr 29, 2010, 4:14:40 PM4/29/10
to am...@googlegroups.com, nadir
AMPL does not have a "date" data type.

Bob Fourer
4...@ampl.com


> -----Original Message-----
> From: am...@googlegroups.com [mailto:am...@googlegroups.com]
> On Behalf Of nadir [nadir.a...@googlemail.com]
> Sent: Tuesday, April 27, 2010 12:50 PM
> To: AMPL Modeling Language
Reply all
Reply to author
Forward
0 new messages