Skip to content

Commit

Permalink
Add an MOI wrapper (#83)
Browse files Browse the repository at this point in the history
* Add an MOI wrapper

* Deal with ScalarAffine constraints

* Deal with MOI objectives

* Add ScalarQuadraticFunction

* Add comments

* Test on linear and gradratic MOI tests

* Update wrapper

* Update show

* Add MINLPTests as a build stage

* Add JuMP master to MINLPTests

* Add Ipopt to MINLPTests project

* Put all MINLPTests in testset

* Bump MINLPTests version

* Update run_minlptests.jl

* Doh; exclude the right test
  • Loading branch information
odow authored Feb 10, 2019
1 parent 9e09d04 commit b03be7f
Show file tree
Hide file tree
Showing 9 changed files with 830 additions and 14 deletions.
14 changes: 9 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
language: julia
os:
- linux
- osx
julia:
- 0.6
- 0.7
- 1.0
- nightly
matrix:
allow_failures:
- julia: nightly
- 1.1
branches:
only:
- master
Expand All @@ -27,3 +23,11 @@ before_cache:
- cp -R $HOME/.julia/*/Ipopt/deps/usr $HOME
after_success:
- julia -e 'if VERSION >= v"0.7-"; using Pkg; else; cd(Pkg.dir("AmplNLWriter")); end; Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())'
jobs:
include:
- stage: "MINLPTests"
julia: 1.0
os: linux
script:
- julia --project=test/MINLPTests -e 'using Pkg; Pkg.instantiate(); Pkg.add(PackageSpec(path=pwd()))'
- julia --project=test/MINLPTests --color=yes test/MINLPTests/run_minlptests.jl
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
julia 0.6
Compat 1.0
MathProgBase 0.5 0.8
MathOptInterface 0.8.1 0.9
23 changes: 14 additions & 9 deletions src/AmplNLWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,19 @@ function SolverInterface.loadproblem!(outer::AmplNLNonlinearModel, nvar::Integer

# Process objective
m.obj = obj_expr(m.d)
if length(m.obj.args) < 2
m.obj = 0
else
# Convert non-linear expression to non-linear, linear and constant
m.obj, constant, m.objlinearity = process_expression!(
m.obj, m.lin_obj, m.varlinearities_obj)
if typeof(m.obj) <: Expr
if length(m.obj.args) < 2
# TODO(odow): what does this case mean?
m.obj = 0
else
# Convert non-linear expression to non-linear, linear and constant
m.obj, constant, m.objlinearity = process_expression!(
m.obj, m.lin_obj, m.varlinearities_obj)

# Add constant back into non-linear expression
if constant != 0
m.obj = add_constant(m.obj, constant)
# Add constant back into non-linear expression
if constant != 0
m.obj = add_constant(m.obj, constant)
end
end
end
m
Expand Down Expand Up @@ -791,4 +794,6 @@ function clean_solverdata()
end
end

include("MOI_wrapper.jl")

end
Loading

0 comments on commit b03be7f

Please sign in to comment.