Skip to content

Commit

Permalink
Merge pull request #57 from chkwon/mcp_update
Browse files Browse the repository at this point in the history
:PATHSolver -> :PATH
  • Loading branch information
chkwon authored Mar 5, 2021
2 parents 60fff70 + b5f959a commit 98ce81e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions MCP.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ items = 1:4

# @variable(m, lb[i] <= x[i in items] <= ub[i])
@variable(m, x[i in items] >= 0)
@mapping(m, F[i in items], sum{M[i,j]*x[j], j in items} + q[i])
@mapping(m, F[i in items], sum(M[i,j]*x[j] for j in items) + q[i])
@complementarity(m, F, x)


status = solveMCP(m, solver=:PATHSolver; convergence_tolerance=1e-8, output="yes", time_limit=3600)
status = solveMCP(m, solver=:PATH, convergence_tolerance=1e-8, output="yes", time_limit=3600)

z = result_value(x)
z = result_value.(x)
````
The result should be `[2.8, 0.0, 0.8, 1.2]`.

Expand All @@ -73,7 +73,7 @@ This line prepares a JuMP Model, just same as in [JuMP.jl](https://github.com/Ju
Defining variables is exactly same as in JuMP.jl. Lower and upper bounds on the variables in the MCP model should be provided here.

```julia
@mapping(m, F[i in items], sum{M[i,j]*x[j], j in items} + q[i])
@mapping(m, F[i in items], sum(M[i,j]*x[j] for j in items) + q[i])
```
This is to define expressions for `F` in MCP. This is merely an alias of `JuMP.@NLexpression`.

Expand All @@ -84,7 +84,7 @@ This macro matches each element of `F` and the complementing element of `x`.


```julia
solveMCP(m; convergence_tolerance=1e-8, output="yes", time_limit=3600)
status = solveMCP(m, solver=:PATH, convergence_tolerance=1e-8, output="yes", time_limit=3600)
```
This solves the MCP and stores the solution inside `m`, which can be accessed by `result_value(x)`.
Keyword arguments are options of the PATH Solver. See the [list of options](http://www.cs.wisc.edu/~ferris/path/options.pdf).
Expand Down
2 changes: 2 additions & 0 deletions src/mcp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ function solveMCP(m::JuMP.Model; solver=:PATH, method=:trust_region, linear=fals
return _solve_path!(m; kwargs...)
elseif solver == :NLsolve
return _solve_nlsolve!(m, method=method)
else
error("Choose :PATH or :NLsolve as the solver for MCP.")
end
end

Expand Down

0 comments on commit 98ce81e

Please sign in to comment.