AMPL round function with couenne package?

126 views
Skip to first unread message

Mahmut Tutam

unread,
Aug 25, 2017, 3:04:53 PM8/25/17
to am...@googlegroups.com
Hello,

I am using Couenne open source software with AMPL to solve my nonlinear-integer optimization problem. I do not know how to tell AMPL to round a function depending on the variable. For example, the following function is one of the constraints in my optimization problem such as n is variable; and a and nk are parameters. t[i] = round((i * a * n) / (a * (nk + 1));. I know I can use ceil function with CPLEX, but CPLEX can not solve a nonlinear-integer optimization problem. If I use ceil function in Couenne, it says ceil is not implemented. Would you please share me if there is a way to deal with this problem? or should I use another software package to solve my problem?

Sincerely,
Mahmut

Pietro Belotti

unread,
Aug 27, 2017, 9:01:06 AM8/27/17
to AMPL Modeling Language, mtu...@email.uark.edu
Suppose we want the variable t[i] to be equal to the ceiling of a variable x[i]. The ceiling function is indeed not implemented in Couenne, but it suffices to declare t[i] as integer and then add the two constraints

eps + t[i] >= x[i]
eps + t[i] - 1 <= x[i]

where eps is a small-enough constant, say 1e-5. A nonzero eps allows for unicity of t[i] (in case x[i] is itself integer), although x[i] 3.000009 will result in t[i] = 3. There are simpler implementations in case you only require t[i] >= ceil (x[i]) or t[i] <= ceil (x[i]).

Hope this helps,
Pietro

Pietro Belotti

unread,
Aug 27, 2017, 10:06:03 PM8/27/17
to AMPL Modeling Language, mtu...@email.uark.edu
In response to your original question about round (as opposed to ceil/floor), note that

round (a) = floor (a + 0.5) = ceil (a - 0.5)

so that obtaining the rounded value only requires a small change to the posted constraints.
Reply all
Reply to author
Forward
0 new messages