Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for VectorNonlinearFunction #82

Merged
merged 14 commits into from
Aug 16, 2023
Merged

Add support for VectorNonlinearFunction #82

merged 14 commits into from
Aug 16, 2023

Conversation

odow
Copy link
Collaborator

@odow odow commented Feb 1, 2023

@odow odow marked this pull request as draft February 1, 2023 00:07
@codecov
Copy link

codecov bot commented Feb 1, 2023

Codecov Report

Patch coverage: 96.77% and project coverage change: +0.42% 🎉

Comparison is base (3b5d410) 93.66% compared to head (893cbbc) 94.09%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #82      +/-   ##
==========================================
+ Coverage   93.66%   94.09%   +0.42%     
==========================================
  Files           3        3              
  Lines         379      440      +61     
==========================================
+ Hits          355      414      +59     
- Misses         24       26       +2     
Files Changed Coverage Δ
src/MOI_wrapper.jl 97.87% <96.77%> (-0.56%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@odow
Copy link
Collaborator Author

odow commented Feb 1, 2023

And here's the JuMP demo

julia> using JuMP, PATHSolver

julia> model = Model(PATHSolver.Optimizer)
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: Path 5.0.03

julia> @variable(model, 0 <= x[1:4] <= 10)
4-element Vector{VariableRef}:
 x[1]
 x[2]
 x[3]
 x[4]

julia> @constraints(model, begin
                                -x[3]^2.0 -  x[4]     + 2  x[1]
                                 x[3]^3.0 - 2x[4]^2.0 + 2  x[2]
           x[1]^5.0 -  x[2]   + 2x[3]     - 2x[4]     - 2  x[3]
           x[1]   + 2x[2]^3.0 - 2x[3]     + 4x[4]     - 6  x[4]
       end)
([+(-(*(-1.0, ^(x[3], 2.0)), x[4]), 2.0), x[1]]  MathOptInterface.Complements(2), [+(-(^(x[3], 3.0), *(2.0, ^(x[4], 2.0))), 2.0), x[2]]  MathOptInterface.Complements(2), [-(-(+(-(^(x[1], 5.0), x[2]), 2 x[3]), 2 x[4]), 2.0), x[3]]  MathOptInterface.Complements(2), [-(+(-(+(x[1], *(2.0, ^(x[2], 3.0))), 2 x[3]), 4 x[4]), 6.0), x[4]]  MathOptInterface.Complements(2))

julia> optimize!(model)
Path 5.0.03 (Fri Jun 26 09:58:07 2020)
Written by Todd Munson, Steven Dirkse, Youngdae Kim, and Michael Ferris


Crash Log
major  func  diff  size  residual    step       prox   (label)
    0     0             9.3949e+00             0.0e+00 (f[    4])
    1     4     3     2 7.7898e+00  4.1e-01    0.0e+00 (f[    1])
    2     5     1     3 1.4635e+00  1.0e+00    0.0e+00 (f[    3])
    3     6     0     3 1.1831e+00  1.0e+00    0.0e+00 (f[    3])
pn_search terminated: no basis change.

Major Iteration Log
major minor  func  grad  residual    step  type prox    inorm  (label)
    0     0     7     4 1.1831e+00           I 0.0e+00 1.2e+00 (f[    3])
    1     1     8     5 1.0633e+00  1.0e+00 SO 0.0e+00 1.1e+00 (f[    3])
    2     1     9     6 9.7034e-01  1.0e+00 SO 0.0e+00 9.7e-01 (f[    3])
    3     3    10     7 1.5017e+00  1.0e+00 SO 0.0e+00 1.2e+00 (f[    4])
    4     2    11     8 1.4820e+00  1.0e+00 SO 0.0e+00 1.2e+00 (f[    4])
    5     1    12     9 1.4756e+00  1.0e+00 SO 0.0e+00 1.2e+00 (f[    4])
    6     1    13    10 1.4483e+00  1.0e+00 SO 0.0e+00 1.2e+00 (f[    4])
    7     1    14    11 1.3317e+00  1.0e+00 SO 0.0e+00 1.1e+00 (f[    4])
    8     1    15    12 1.0594e+00  1.0e+00 SO 0.0e+00 1.0e+00 (f[    4])
    9     1    16    13 5.7505e-01  1.0e+00 SO 0.0e+00 5.7e-01 (f[    4])
   10     1    17    14 7.6079e-02  1.0e+00 SO 0.0e+00 7.6e-02 (f[    4])
   11     1    18    15 1.0305e-03  1.0e+00 SO 0.0e+00 1.0e-03 (f[    4])
   12     1    19    16 1.8656e-07  1.0e+00 SO 0.0e+00 1.9e-07 (f[    4])

Major Iterations. . . . 12
Minor Iterations. . . . 15
Restarts. . . . . . . . 0
Crash Iterations. . . . 3
Gradient Steps. . . . . 0
Function Evaluations. . 19
Gradient Evaluations. . 16
Basis Time. . . . . . . 0.000051
Total Time. . . . . . . 0.001205
Residual. . . . . . . . 1.865551e-07

julia> value.(x)
4-element Vector{Float64}:
 1.2847523472583888
 0.972916458993744
 0.909376156748673
 1.173035005537013

@odow odow force-pushed the od/nlp-expr branch 2 times, most recently from 21b68d2 to ca10a15 Compare June 9, 2023 04:02
@odow odow changed the title WIP: add support for VectorNonlinearFunction Add support for VectorNonlinearFunction Jun 9, 2023
@odow odow closed this Jun 23, 2023
@odow odow reopened this Jun 23, 2023
test/runtests.jl Outdated Show resolved Hide resolved
last_col = 0
# We need to zero all entries up front in case some rows do not
# appear in the Jacobian.
len .= Cint(0)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a tricky segfault to track down 😄

@odow odow marked this pull request as ready for review August 16, 2023 07:36
@odow odow merged commit 4333252 into master Aug 16, 2023
@odow odow deleted the od/nlp-expr branch August 16, 2023 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is the redistribution available to solve a nonlinear (mixed) complementarity problem?
1 participant