chkwon / PATHSolver.jl

provides a Julia wrapper for the PATH Solver for solving mixed complementarity problems
http://pages.cs.wisc.edu/%7Eferris/path.html
MIT License
50 stars 15 forks source link

Add support for VectorNonlinearFunction #82

Closed odow closed 1 year ago

odow commented 1 year ago

Closes #87

codecov[bot] commented 1 year ago

Codecov Report

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

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

Additional details and impacted files ```diff @@ 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](https://app.codecov.io/gh/chkwon/PATHSolver.jl/pull/82?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Changhyun+Kwon) | Coverage Δ | | |---|---|---| | [src/MOI\_wrapper.jl](https://app.codecov.io/gh/chkwon/PATHSolver.jl/pull/82?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Changhyun+Kwon#diff-c3JjL01PSV93cmFwcGVyLmps) | `97.87% <96.77%> (-0.56%)` | :arrow_down: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

odow commented 1 year ago

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