JuliaOpt/KNITRO.jl — pull request #15 by yeesian (2014-12-18 12:27:50+00:00)
Title: add support for MINLP through JuMP

The test example ``jump_minlp.jl`` (occasionally) throws the following error when run from the commandline:
```bash
yeesian$ julia jump_minlp.jl
ERROR: `log` has no method matching log(::GenericAffExpr{Float64,Variable})
in include at /Applications/Julia-0.3.3.app/Contents/Resources/julia/lib/julia/sys.dylib
in include_from_node1 at loading.jl:128
in process_options at /Applications/Julia-0.3.3.app/Contents/Resources/julia/lib/julia/sys.dylib
in _start at /Applications/Julia-0.3.3.app/Contents/Resources/julia/lib/julia/sys.dylib (repeats 2 times)
while loading /Users/yeesian/.julia/v0.3/KNITRO/examples/jump_minlp.jl, in expression starting on line 143
```
but runs fine in the REPL:

```julia
| | |_| | | | (_| | | Version 0.3.3 (2014-11-23 20:19 UTC)
_/ |\__'_|_|_|\__'_| | 'Official http://julialang.org/ release'
|__/ | x86_64-apple-darwin13.3.0

julia> using KNITRO, JuMP #, Base.Test

julia> m = Model(solver=KnitroSolver(mip_method = KTR_MIP_METHOD_BB,
algorithm = KTR_ALG_ACT_CG,
outmode = KTR_OUTMODE_SCREEN,
KTR_PARAM_OUTLEV = KTR_OUTLEV_ALL,
KTR_PARAM_MIP_OUTINTERVAL = 1,
KTR_PARAM_MIP_MAXNODES = 10000,
KTR_PARAM_HESSIAN_NO_F = KTR_HESSIAN_NO_F_ALLOW))
Feasibility problem with:
* 0 linear constraints
* 0 variables
Solver set to Knitro

julia> x_U = [2,2,1]
3-element Array{Int64,1}:
2
2
1

julia> @defVar(m, x_U[i] >= x[i=1:3] >= 0)
0 ≤ x[i] ≤ .. for all i in {1,2,3}

julia> @defVar(m, y[4:6], Bin)
y[i] in {0,1} for all i in {4,5,6}

julia> @setNLObjective(m, Min, 10 + 10*x[1] - 7*x[3] + 5*y[4] + 6*y[5] + 8*y[6] - 18*log(x[2]+1) - 19.2*log(x[1]-x[2]+1))

julia> @addNLConstraint(m, 0.8*log(x[2] + 1) + 0.96*log(x[1] - x[2] + 1) - 0.8*x[3] >= 0)

julia> @addNLConstraint(m, log(x[2] + 1) + 1.2*log(x[1] - x[2] + 1) - x[3] - 2*y[6] >= -2)

julia> @addNLConstraint(m, x[2] - x[1] <= 0)

julia> @addNLConstraint(m, x[2] - 2*y[4] <= 0)

julia> @addNLConstraint(m, x[1] - x[2] - 2*y[5] <= 0)

julia> @addNLConstraint(m, y[4] + y[5] <= 1)

julia> solve(m)

======================================
Commercial Ziena License
KNITRO 9.0.1
Ziena Optimization
======================================

mip_maxnodes: 10000
mip_method: 1
mip_outinterval: 1
KNITRO changing mip_rootalg from AUTO to 1.
KNITRO changing mip_lpalg from AUTO to 3.
KNITRO changing mip_branchrule from AUTO to 2.
KNITRO changing mip_selectrule from AUTO to 2.
KNITRO changing mip_rounding from AUTO to 3.
KNITRO changing mip_heuristic from AUTO to 1.
KNITRO changing mip_pseudoinit from AUTO to 1.

Problem Characteristics
-----------------------
Objective goal: Minimize
Number of variables: 6
bounded below: 0
bounded above: 0
bounded below and above: 6
fixed: 0
free: 0
Number of binary variables: 3
Number of integer variables: 0
Number of constraints: 6
linear equalities: 0
nonlinear equalities: 0
linear inequalities: 0
nonlinear inequalities: 6
range: 0
Number of nonzeros in Jacobian: 16
Number of nonzeros in Hessian: 7

KNITRO detected 0 GUB constraints
KNITRO derived 0 knapsack covers after examining 0 constraints
KNITRO solving root node relaxation
KNITRO MIP using Branch and Bound method

Node Left Iinf Objective Best Relaxatn Best Incumbent
------ ------ ------ -------------- -------------- --------------
1 0 2 7.592844e-01 7.592844e-01 1.000000e+01
2 1 1 5.171320e+00 7.592844e-01 1.000000e+01
* 2 1 r 7.671320e+00
* 3 2 0 6.009759e+00 f 5.171320e+00 6.009759e+00
4 1 1.000000e+01 pr 5.171320e+00 6.009759e+00
5 0 7.092732e+00 pr 6.009759e+00 6.009759e+00

EXIT: Optimal solution found.

Final Statistics for MIP
------------------------
Final objective value = 6.00975890892825e+00
Final integrality gap (abs / rel) = 0.00e+00 / 0.00e+00 ( 0.00%)
# of nodes processed = 5
# of subproblems processed = 6
Total program time (secs) = 0.04106 ( 0.041 CPU time)
Time spent in evaluations (secs) = 0.03291

Solution Vector
---------------
x[ 0] = 1.30097589089e+00
x[ 1] = 0.00000000000e+00
x[ 2] = 1.00000000000e+00
x[ 3] = 0.00000000000e+00 (binary variable)
x[ 4] = 1.00000000000e+00 (binary variable)
x[ 5] = 0.00000000000e+00 (binary variable)

===========================================================================

:Optimal
```

Any idea why that's the case?

@mlubin