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

Upgrade PRIMA.jl for the future PRIMA v0.8.0 #29

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions .appveyor.yml

This file was deleted.

64 changes: 32 additions & 32 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,32 +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
# 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
6 changes: 3 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ jobs:
fail-fast: false
matrix:
version:
- '1.6'
# - '1.6'
- '1'
- 'nightly'
os:
- ubuntu-latest
- windows-latest
# - windows-latest
arch:
- x64
- x86
# - x86
steps:
- uses: actions/checkout@v3
- uses: julia-actions/setup-julia@v1
Expand Down
96 changes: 96 additions & 0 deletions Manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.10.2"
manifest_format = "2.0"
project_hash = "953606c6b35d60e283a724a797a2707a6e266039"

[[deps.Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"

[[deps.CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
Dismissed Show dismissed Hide dismissed
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
version = "1.1.0+0"

[[deps.Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[[deps.JLLWrappers]]
deps = ["Artifacts", "Preferences"]
git-tree-sha1 = "7e5d6779a1e09a36db2a7b6cff50942a0a7d0fca"
Dismissed Show dismissed Hide dismissed
Dismissed Show dismissed Hide dismissed
Dismissed Show dismissed Hide dismissed
Dismissed Show dismissed Hide dismissed
uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
version = "1.5.0"

[[deps.Libdl]]
Dismissed Show dismissed Hide dismissed
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

[[deps.LinearAlgebra]]
deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"]
Dismissed Show dismissed Hide dismissed
Dismissed Show dismissed Hide dismissed
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[[deps.OpenBLAS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
Dismissed Show dismissed Hide dismissed
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
version = "0.3.23+4"

[[deps.PRIMA_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl"]
Dismissed Show dismissed Hide dismissed
git-tree-sha1 = "b4263b50aa12adb9ff6954a18e474ae091ba8d37"
Dismissed Show dismissed Hide dismissed
repo-rev = "main"
repo-url = "https://github.com/amontoison/PRIMA_jll.jl"
uuid = "eead6e0c-2d5b-5641-a95c-b722de96d551"
version = "0.8.0+0"

[[deps.Preferences]]
deps = ["TOML"]
git-tree-sha1 = "9306f6085165d270f7e3db02af26a400d580f5c6"
uuid = "21216c6a-2e73-6563-6e65-726566657250"
version = "1.4.3"

[[deps.Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[deps.Random]]
deps = ["SHA"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[deps.Requires]]
deps = ["UUIDs"]
git-tree-sha1 = "838a3a4188e2ded87a4f9f184b4b0d78a1e91cb7"
Dismissed Show dismissed Hide dismissed
uuid = "ae029012-a4dd-5104-9daa-d747884805df"
version = "1.3.0"

[[deps.SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
version = "0.7.0"

[[deps.TOML]]
deps = ["Dates"]
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
version = "1.0.3"

[[deps.TypeUtils]]
deps = ["Requires"]
git-tree-sha1 = "bdd88868eb3fb29aff042a1f50619b5d0b94a5ea"
Dismissed Show dismissed Hide dismissed
uuid = "c3b1956e-8857-4d84-9b79-890df85b1e67"
version = "0.3.7"

[deps.TypeUtils.extensions]
TypeUtilsTwoDimensionalExt = "TwoDimensional"

[deps.TypeUtils.weakdeps]
TwoDimensional = "1907e7ba-7586-4310-a2ba-dd01462aeb50"

[[deps.UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[[deps.Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[[deps.libblastrampoline_jll]]
Dismissed Show dismissed Hide dismissed
deps = ["Artifacts", "Libdl"]
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
version = "5.8.0+1"
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ PRIMANLPModelsExt = "NLPModels"
[compat]
CUTEst = "0.13"
NLPModels = "0.20"
PRIMA_jll = "0.7.1"
PRIMA_jll = "0.8.0"
Requires = "1"
TypeUtils = "0.3"
julia = "1.6"
Expand Down
117 changes: 75 additions & 42 deletions src/wrappers.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
@enum Message::Cint begin
@enum prima_algorithm_t::Cint begin
UOBYQA = 0
NEWUOA = 1
BOBYQA = 2
LINCOA = 3
COBYLA = 4
end

@enum prima_message_t::Cint begin
MSG_NONE = 0
MSG_EXIT = 1
MSG_RHO = 2
MSG_FEVL = 3
end

@enum Status::Cint begin
@enum prima_rc_t::Cint begin
SMALL_TR_RADIUS = 0
FTARGET_ACHIEVED = 1
TRSUBP_FAILED = 2
Expand All @@ -17,63 +25,88 @@ end
NO_SPACE_BETWEEN_BOUNDS = 6
DAMAGING_ROUNDING = 7
ZERO_LINEAR_CONSTRAINT = 8
CALLBACK_TERMINATE = 30
INVALID_INPUT = 100
ASSERTION_FAILS = 101
VALIDATION_FAILS = 102
MEMORY_ALLOCATION_FAILS = 103
NULL_OPTIONS = 110
NULL_PROBLEM = 111
NULL_X0 = 112
NULL_RESULT = 113
NULL_FUNCTION = 114
PROBLEM_SOLVER_MISMATCH_NONLINEAR_CONSTRAINTS = 115
PROBLEM_SOLVER_MISMATCH_LINEAR_CONSTRAINTS = 116
PROBLEM_SOLVER_MISMATCH_BOUNDS = 117
end

function prima_get_rc_string(rc)
@ccall libprimac.prima_get_rc_string(rc::Cint)::Cstring
@ccall libprimac.prima_get_rc_string(rc::prima_rc_t)::Cstring
end

# typedef void ( * prima_obj ) ( const double x [ ] , double * f )
const prima_obj = Ptr{Cvoid}
# typedef void ( * prima_obj_t ) ( const double x [ ] , double * const f , const void * data )
const prima_obj_t = Ptr{Cvoid}

# typedef void ( * prima_objcon_t ) ( const double x [ ] , double * const f , double constr [ ] , const void * data )
const prima_objcon_t = Ptr{Cvoid}

# typedef void ( * prima_callback_t ) ( const int n , const double x [ ] , const double f , const int nf , const int tr , const double cstrv , const int m_nlcon , const double nlconstr [ ] , bool * const terminate )
const prima_callback_t = Ptr{Cvoid}

# typedef void ( * prima_objcon ) ( const double x [ ] , double * f , double constr [ ] )
const prima_objcon = Ptr{Cvoid}
struct prima_problem_t
n::Cint
calfun::prima_obj_t
calcfc::prima_objcon_t
x0::Ptr{Cdouble}
xl::Ptr{Cdouble}
xu::Ptr{Cdouble}
m_ineq::Cint
Aineq::Ptr{Cdouble}
bineq::Ptr{Cdouble}
m_eq::Cint
Aeq::Ptr{Cdouble}
beq::Ptr{Cdouble}
m_nlcon::Cint
f0::Cdouble
nlconstr0::Ptr{Cdouble}
end

function prima_init_problem(problem, n)
@ccall libprimac.prima_init_problem(problem::Ptr{prima_problem_t}, n::Cint)::Status
end

function prima_bobyqa(calfun, n, x, f, xl, xu, nf, rhobeg, rhoend, ftarget, maxfun, npt,
iprint)
@ccall libprimac.prima_bobyqa(calfun::prima_obj, n::Cint, x::Ptr{Cdouble},
f::Ptr{Cdouble}, xl::Ptr{Cdouble}, xu::Ptr{Cdouble},
nf::Ptr{Cint}, rhobeg::Cdouble, rhoend::Cdouble,
ftarget::Cdouble, maxfun::Cint, npt::Cint,
iprint::Cint)::Status
struct prima_options_t
rhobeg::Cdouble
rhoend::Cdouble
maxfun::Cint
iprint::Cint
ftarget::Cdouble
npt::Cint
ctol::Cdouble
data::Ptr{Cvoid}
callback::prima_callback_t
end

function prima_newuoa(calfun, n, x, f, nf, rhobeg, rhoend, ftarget, maxfun, npt, iprint)
@ccall libprimac.prima_newuoa(calfun::prima_obj, n::Cint, x::Ptr{Cdouble},
f::Ptr{Cdouble}, nf::Ptr{Cint}, rhobeg::Cdouble,
rhoend::Cdouble, ftarget::Cdouble, maxfun::Cint,
npt::Cint, iprint::Cint)::Status
function prima_init_options(options)
@ccall libprimac.prima_init_options(options::Ptr{prima_options_t})::Status
end

function prima_uobyqa(calfun, n, x, f, nf, rhobeg, rhoend, ftarget, maxfun, iprint)
@ccall libprimac.prima_uobyqa(calfun::prima_obj, n::Cint, x::Ptr{Cdouble},
f::Ptr{Cdouble}, nf::Ptr{Cint}, rhobeg::Cdouble,
rhoend::Cdouble, ftarget::Cdouble, maxfun::Cint,
iprint::Cint)::Status
struct prima_result_t
x::Ptr{Cdouble}
f::Cdouble
cstrv::Cdouble
nlconstr::Ptr{Cdouble}
nf::Cint
status::Cint
message::Cstring
end

function prima_cobyla(m_nlcon, calcfc, n, x, f, cstrv, nlconstr, m_ineq, Aineq, bineq, m_eq,
Aeq, beq, xl, xu, nf, rhobeg, rhoend, ftarget, maxfun, iprint)
@ccall libprimac.prima_cobyla(m_nlcon::Cint, calcfc::prima_objcon, n::Cint,
x::Ptr{Cdouble}, f::Ptr{Cdouble}, cstrv::Ptr{Cdouble},
nlconstr::Ptr{Cdouble}, m_ineq::Cint, Aineq::Ptr{Cdouble},
bineq::Ptr{Cdouble}, m_eq::Cint, Aeq::Ptr{Cdouble},
beq::Ptr{Cdouble}, xl::Ptr{Cdouble}, xu::Ptr{Cdouble},
nf::Ptr{Cint}, rhobeg::Cdouble, rhoend::Cdouble,
ftarget::Cdouble, maxfun::Cint, iprint::Cint)::Status
function prima_free_result(result)
@ccall libprimac.prima_free_result(result::Ptr{prima_result_t})::Status
end

function prima_lincoa(calfun, n, x, f, cstrv, m_ineq, Aineq, bineq, m_eq, Aeq, beq, xl, xu,
nf, rhobeg, rhoend, ftarget, maxfun, npt, iprint)
@ccall libprimac.prima_lincoa(calfun::prima_obj, n::Cint, x::Ptr{Cdouble},
f::Ptr{Cdouble}, cstrv::Ptr{Cdouble}, m_ineq::Cint,
Aineq::Ptr{Cdouble}, bineq::Ptr{Cdouble}, m_eq::Cint,
Aeq::Ptr{Cdouble}, beq::Ptr{Cdouble}, xl::Ptr{Cdouble},
xu::Ptr{Cdouble}, nf::Ptr{Cint}, rhobeg::Cdouble,
rhoend::Cdouble, ftarget::Cdouble, maxfun::Cint,
npt::Cint, iprint::Cint)::Status
function prima_minimize(algorithm, problem, options, result)
@ccall libprimac.prima_minimize(algorithm::prima_algorithm_t, problem::prima_problem_t,
options::prima_options_t,
result::Ptr{prima_result_t})::Status
end
Loading