Skip to content

Commit

Permalink
Update to 0.6.0 and add CirrusCI
Browse files Browse the repository at this point in the history
  • Loading branch information
abelsiqueira committed Jun 16, 2024
1 parent 306017e commit 6b3de17
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 70 deletions.
32 changes: 32 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
task:
matrix:
- name: FreeBSD
freebsd_instance:
image_family: freebsd-13-2
env:
matrix:
- JULIA_VERSION: 1.6
- JULIA_VERSION: 1
- name: MacOS M1
macos_instance:
image: ghcr.io/cirruslabs/macos-monterey-base:latest
env:
- JULIA_VERSION: 1
install_script: |
URL="https://raw.githubusercontent.com/ararslan/CirrusCI.jl/master/bin/install.sh"
set -x
if [ "$(uname -s)" = "Linux" ] && command -v apt; then
apt update
apt install -y curl
fi
if command -v curl; then
sh -c "$(curl ${URL})"
elif command -v wget; then
sh -c "$(wget ${URL} -q -O-)"
elif command -v fetch; then
sh -c "$(fetch ${URL} -o -)"
fi
build_script:
- cirrusjl build
test_script:
- cirrusjl test
15 changes: 13 additions & 2 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
# Changes here will be overwritten by Copier
AnswerStrategy: recommended
AddAllcontributors: true
AddCodeOfConduct: true
AddCopierCI: false
AddGitHubTemplates: true
AddMacToCI: true
AddPrecommit: true
AddWinToCI: true
AnswerStrategy: ask
AuthorEmail: [email protected]
AuthorName: Tangi Migot
Indentation: 2
JuliaMinVersion: '1.6'
License: MPL-2.0
PackageName: JSOSuite
PackageOwner: JuliaSmoothOptimizers
PackageUUID: ed6ae0be-a024-11e9-2788-05dbf8cd15d9
_commit: v0.5.3
RunJuliaNightlyOnCI: false
SimplifiedPRTest: true
UseCirrusCI: true
_commit: v0.6.0
_src_path: https://github.com/abelsiqueira/COPIERTemplate.jl
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ If you use JSOSuite.jl in your work, please cite using the reference given in [C

If you want to make contributions of any kind, please first that a look into our [contributing guide directly on GitHub](docs/src/90-contributing.md) or the [contributing page on the website](https://JuliaSmoothOptimizers.github.io/JSOSuite.jl/dev/contributing/).

---

### Contributors

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
Expand All @@ -30,7 +32,3 @@ If you want to make contributions of any kind, please first that a look into our
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

---

This repo was created with the [COPIERTemplate.jl](https://github.com/abelsiqueira/COPIERTemplate.jl) package.
8 changes: 1 addition & 7 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ using Documenter

DocMeta.setdocmeta!(JSOSuite, :DocTestSetup, :(using JSOSuite); recursive = true)

const page_rename = Dict(
"developer.md" => "Developer docs",
"nls.md" => "Nonlinear Least Squares",
"qp.md" => "Quadratic models with linear constraints",
"resolve.md" => "Re-solve and in-place solve",
"speed-up.md" => "Speed up Solvers Tips",
) # Without the numbers
const page_rename = Dict("developer.md" => "Developer docs") # Without the numbers

function nice_name(file)
file = replace(file, r"^[0-9]*-" => "")
Expand Down
2 changes: 1 addition & 1 deletion docs/src/90-contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ Otherwise, say what your proposed solution is and wait for a discussion around i
!!! tip
Feel free to ping us after a few days if there are no responses.

If your solution involves code (or something that requires running the package locally), check the [developer documentation](90-developer.md).
If your solution involves code (or something that requires running the package locally), check the [developer documentation](91-developer.md).
Otherwise, you can use the GitHub interface directly to create your pull request.
File renamed without changes.
4 changes: 2 additions & 2 deletions docs/src/90-reference.md → docs/src/95-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
## Contents

```@contents
Pages = ["90-reference.md"]
Pages = ["95-reference.md"]
```

## Index

```@index
Pages = ["90-reference.md"]
Pages = ["95-reference.md"]
```

```@autodocs
Expand Down
108 changes: 54 additions & 54 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ using SolverBenchmark
meta = OptimizationProblems.meta

function test_in_place_solve(nlp, solver_name)
pkg_name = JSOSuite.optimizers[JSOSuite.optimizers.name_solver.==solver_name, :name_pkg][1]
pkg_name = JSOSuite.optimizers[JSOSuite.optimizers.name_solver .== solver_name, :name_pkg][1]
pkg_name = replace(pkg_name, ".jl" => "")
solver = eval(Meta.parse(pkg_name * ".$solver_name"))(nlp)
stats = solve!(solver, nlp)
Expand All @@ -46,7 +46,7 @@ end

function test_in_place_solve(model::JuMP.Model, solver_name)
nlp = MathOptNLPModel(model)
pkg_name = JSOSuite.optimizers[JSOSuite.optimizers.name_solver.==solver_name, :name_pkg][1]
pkg_name = JSOSuite.optimizers[JSOSuite.optimizers.name_solver .== solver_name, :name_pkg][1]
pkg_name = replace(pkg_name, ".jl" => "")
solver = eval(Meta.parse(pkg_name * ".$solver_name"))(nlp)
stats = solve!(solver, model)
Expand All @@ -64,16 +64,16 @@ end
solver_name == :DCIWorkspace && continue
solver_name == :RipQPSolver && continue
is_available =
JSOSuite.optimizers[JSOSuite.optimizers.name_solver.==solver_name, :is_available]
JSOSuite.optimizers[JSOSuite.optimizers.name_solver .== solver_name, :is_available]
can_solve_nlp =
JSOSuite.optimizers[JSOSuite.optimizers.name_solver.==solver_name, :can_solve_nlp]
JSOSuite.optimizers[JSOSuite.optimizers.name_solver .== solver_name, :can_solve_nlp]
spec_nls =
JSOSuite.optimizers[JSOSuite.optimizers.name_solver.==solver_name, :specialized_nls]
JSOSuite.optimizers[JSOSuite.optimizers.name_solver .== solver_name, :specialized_nls]
if is_available[1] && can_solve_nlp[1]
test_in_place_solve(nlp, solver_name)
test_in_place_solve(model, solver_name)
elseif is_available[1] && spec_nls[1] # NLS
nls = OptimizationProblems.ADNLPProblems.arglina(; use_nls=true)
nls = OptimizationProblems.ADNLPProblems.arglina(; use_nls = true)
test_in_place_solve(nls, solver_name)
elseif is_available[1] # RipQP
nlp_qm = QuadraticModel(nlp, nlp.meta.x0)
Expand All @@ -85,15 +85,15 @@ end
include("qp_tests.jl")

@testset "Test `Float32`" begin
nlp = OptimizationProblems.ADNLPProblems.genrose(; type=Float32)
nlp = OptimizationProblems.ADNLPProblems.genrose(; type = Float32)
atol, rtol = eps(Float32), eps(Float32)
for solver in eachrow(JSOSuite.select_optimizers(nlp))
if solver.nonlinear_obj
minimize(solver.name, nlp; verbose=0, atol=atol, rtol=rtol)
minimize(solver.name, nlp; verbose = 0, atol = atol, rtol = rtol)
@test true
else
nlp_qm = QuadraticModel(nlp, nlp.meta.x0)
minimize(solver.name, nlp_qm; verbose=0, atol=atol, rtol=rtol)
minimize(solver.name, nlp_qm; verbose = 0, atol = atol, rtol = rtol)
@test true
end
end
Expand All @@ -104,47 +104,47 @@ end
jum = MathOptNLPModel(model)
@test JSOSuite.select_optimizers(model) == JSOSuite.select_optimizers(jum)
for solver in eachrow(JSOSuite.select_optimizers(model))
minimize(solver.name, model; verbose=0)
minimize(solver.name, model; verbose = 0)
@test true
end
end

@testset "Benchmark on unconstrained problems" begin
ad_problems = [
OptimizationProblems.ADNLPProblems.eval(Meta.parse(problem))() for problem in
first(meta[(5 .<= meta.nvar .<= 10).&(meta.ncon.==0).&(.!meta.has_bounds), :name], 5)
first(meta[(5 .<= meta.nvar .<= 10) .& (meta.ncon .== 0) .& (.!meta.has_bounds), :name], 5)
]
select = JSOSuite.optimizers[
JSOSuite.optimizers.can_solve_nlp.&JSOSuite.optimizers.is_available,
JSOSuite.optimizers.can_solve_nlp .& JSOSuite.optimizers.is_available,
:name,
]
stats = bmark_solvers(ad_problems, select; atol=1e-3, max_time=10.0, verbose=0)
stats = bmark_solvers(ad_problems, select; atol = 1e-3, max_time = 10.0, verbose = 0)
@test true # just test that it runs
end

@testset "Basic solve tests" begin
f = x -> 100 * (x[2] - x[1]^2)^2 + (x[1] - 1)^2
stats = minimize(f, [-1.2; 1.0]; verbose=0)
stats = minimize(f, [-1.2; 1.0]; verbose = 0)
@test stats.status_reliable && (stats.status == :first_order)

stats = minimize("DCISolver", f, [-1.2; 1.0]; verbose=0)
stats = minimize("DCISolver", f, [-1.2; 1.0]; verbose = 0)
@test stats.status_reliable && (stats.status == :first_order)

F = x -> [10 * (x[2] - x[1]^2); x[1] - 1]
stats = minimize(F, [-1.2; 1.0], 2; verbose=0)
stats = minimize(F, [-1.2; 1.0], 2; verbose = 0)
@test stats.status_reliable && (stats.status == :first_order)

stats = minimize("DCISolver", F, [-1.2; 1.0], 2; verbose=0)
stats = minimize("DCISolver", F, [-1.2; 1.0], 2; verbose = 0)
@test stats.status_reliable && (stats.status == :first_order)
end

@testset "Test solve OptimizationProblems: $name" for name in first(meta[meta.nvar.<10, :name], 5)
@testset "Test solve OptimizationProblems: $name" for name in first(meta[meta.nvar .< 10, :name], 5)
name in ["bennett5", "channel", "hs253", "hs73", "misra1c"] && continue
nlp = OptimizationProblems.ADNLPProblems.eval(Meta.parse(name))()
minimize(nlp; verbose=0)
minimize(nlp; verbose = 0)
@test true
model = OptimizationProblems.PureJuMP.eval(Meta.parse(name))()
minimize(model; verbose=0)
minimize(model; verbose = 0)
@test true
end

Expand All @@ -165,23 +165,23 @@ for solver in eachrow(JSOSuite.optimizers)
minimize(
solver.name,
nlp;
atol=1e-5,
rtol=1e-5,
max_time=12.0,
max_eval=10,
verbose=0,
atol = 1e-5,
rtol = 1e-5,
max_time = 12.0,
max_eval = 10,
verbose = 0,
)
@test true
else
nlp_qm = QuadraticModel(nlp, nlp.meta.x0)
minimize(
solver.name,
nlp_qm;
atol=1e-5,
rtol=1e-5,
max_time=12.0,
max_eval=10,
verbose=0,
atol = 1e-5,
rtol = 1e-5,
max_time = 12.0,
max_eval = 10,
verbose = 0,
)
@test true
end
Expand All @@ -191,7 +191,7 @@ end

@testset "Test kwargs in optimizers on $model" for model in (:arglina, :hs6)
nlp = OptimizationProblems.ADNLPProblems.eval(model)()
nls = OptimizationProblems.ADNLPProblems.eval(model)(; use_nls=true)
nls = OptimizationProblems.ADNLPProblems.eval(model)(; use_nls = true)
callback = (args...) -> nothing
for solver in eachrow(JSOSuite.optimizers)
@testset "Test options in $(solver.name)" begin
Expand All @@ -202,42 +202,42 @@ end
minimize(
solver.name,
nlp;
atol=1e-5,
rtol=1e-5,
max_time=12.0,
max_iter=100,
max_eval=10,
callback=callback,
verbose=0,
atol = 1e-5,
rtol = 1e-5,
max_time = 12.0,
max_iter = 100,
max_eval = 10,
callback = callback,
verbose = 0,
)
@test true
elseif solver.specialized_nls
minimize(
solver.name,
nls;
atol=1e-5,
rtol=1e-5,
Fatol=1e-5,
Frtol=1e-5,
max_time=12.0,
max_iter=100,
max_eval=10,
callback=callback,
verbose=0,
atol = 1e-5,
rtol = 1e-5,
Fatol = 1e-5,
Frtol = 1e-5,
max_time = 12.0,
max_iter = 100,
max_eval = 10,
callback = callback,
verbose = 0,
)
@test true
else # RipQP
nlp_qm = QuadraticModel(nlp, nlp.meta.x0)
minimize(
solver.name,
nlp_qm;
atol=1e-5,
rtol=1e-5,
max_time=12.0,
max_iter=100,
max_eval=10,
callback=callback,
verbose=0,
atol = 1e-5,
rtol = 1e-5,
max_time = 12.0,
max_iter = 100,
max_eval = 10,
callback = callback,
verbose = 0,
)
@test true
end
Expand Down

0 comments on commit 6b3de17

Please sign in to comment.