Skip to content

Commit

Permalink
Simplify enum names and fix arg names in low-level calls
Browse files Browse the repository at this point in the history
  • Loading branch information
emmt committed Sep 22, 2023
1 parent 4dab2a9 commit cc5afd3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
16 changes: 8 additions & 8 deletions src/PRIMA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ function bobyqa!(f, x::DenseVector{Cdouble};
fp = _push_wrapper(fw) # pointer to C-callable function
try
# Call low-level optimizer.
rc = prima_bobyqa(calfun, n, x, f, xl, xu, nf, rhobeg, rhoend, ftarget, maxfun, npt, iprint)
rc = prima_bobyqa(fp, n, x, fx, xl, xu, nf, rhobeg, rhoend, ftarget, maxfun, npt, iprint)
return (fx[], Int(nf[]), rc)
finally
_pop_wrapper(fw)
Expand Down Expand Up @@ -321,7 +321,7 @@ function newuoa!(f, x::DenseVector{Cdouble};
fp = _push_wrapper(fw) # pointer to C-callable function
try
# Call low-level optimizer.
rc = prima_newuoa(calfun, n, x, f, nf, rhobeg, rhoend, ftarget, maxfun, npt, iprint)
rc = prima_newuoa(fp, n, x, fx, nf, rhobeg, rhoend, ftarget, maxfun, npt, iprint)
return (fx[], Int(nf[]), rc)
finally
_pop_wrapper(fw)
Expand Down Expand Up @@ -352,7 +352,7 @@ function uobyqa!(f, x::DenseVector{Cdouble};
fp = _push_wrapper(fw) # pointer to C-callable function
try
# Call low-level optimizer.
rc = prima_uobyqa(calfun, n, x, f, nf, rhobeg, rhoend, ftarget, maxfun, iprint)
rc = prima_uobyqa(fp, n, x, fx, nf, rhobeg, rhoend, ftarget, maxfun, iprint)
return (fx[], Int(nf[]), rc)
finally
_pop_wrapper(fw)
Expand Down Expand Up @@ -398,9 +398,9 @@ function cobyla!(f, x::DenseVector{Cdouble};

try
# Call low-level optimizer.
rc = GC.@preserve nlconstr ineqconstr eqconstr 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)
rc = GC.@preserve nlconstr ineqconstr eqconstr prima_cobyla(m_nlcon, fp,
n, x, fx, cstrv, nlcon_ptr, m_ineq, A_ineq, b_ineq, m_eq, A_eq, b_eq,
xl, xu, nf, rhobeg, rhoend, ftarget, maxfun, iprint)
return (fx[], Int(nf[]), rc, cstrv[])
finally
_pop_wrapper(fw)
Expand Down Expand Up @@ -443,8 +443,8 @@ function lincoa!(f, x::DenseVector{Cdouble};
fp = _push_wrapper(fw) # pointer to C-callable function
try
# Call low-level optimizer.
rc = GC.@preserve ineqconstr eqconstr prima_lincoa(calfun, n, x, f,
cstrv, m_ineq, Aineq, bineq, m_eq, Aeq, beq, xl, xu, nf,
rc = GC.@preserve ineqconstr eqconstr prima_lincoa(fp, n, x, fx,
cstrv, m_ineq, A_ineq, b_ineq, m_eq, A_eq, b_eq, xl, xu, nf,
rhobeg, rhoend, ftarget, maxfun, npt, iprint)
return (fx[], Int(nf[]), rc, cstrv[])
finally
Expand Down
42 changes: 21 additions & 21 deletions src/wrappers.jl
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
@enum prima_message::UInt32 begin
PRIMA_MSG_NONE = 0
PRIMA_MSG_EXIT = 1
PRIMA_MSG_RHO = 2
PRIMA_MSG_FEVL = 3
@enum Message::Int32 begin
MSG_NONE = 0
MSG_EXIT = 1
MSG_RHO = 2
MSG_FEVL = 3
end

@enum prima_rc::Int32 begin
PRIMA_SMALL_TR_RADIUS = 0
PRIMA_FTARGET_ACHIEVED = 1
PRIMA_TRSUBP_FAILED = 2
PRIMA_MAXFUN_REACHED = 3
PRIMA_MAXTR_REACHED = 20
PRIMA_NAN_INF_X = -1
PRIMA_NAN_INF_F = -2
PRIMA_NAN_INF_MODEL = -3
PRIMA_NO_SPACE_BETWEEN_BOUNDS = 6
PRIMA_DAMAGING_ROUNDING = 7
PRIMA_ZERO_LINEAR_CONSTRAINT = 8
PRIMA_INVALID_INPUT = 100
PRIMA_ASSERTION_FAILS = 101
PRIMA_VALIDATION_FAILS = 102
PRIMA_MEMORY_ALLOCATION_FAILS = 103
@enum Status::Int32 begin
SMALL_TR_RADIUS = 0
FTARGET_ACHIEVED = 1
TRSUBP_FAILED = 2
MAXFUN_REACHED = 3
MAXTR_REACHED = 20
NAN_INF_X = -1
NAN_INF_F = -2
NAN_INF_MODEL = -3
NO_SPACE_BETWEEN_BOUNDS = 6
DAMAGING_ROUNDING = 7
ZERO_LINEAR_CONSTRAINT = 8
INVALID_INPUT = 100
ASSERTION_FAILS = 101
VALIDATION_FAILS = 102
MEMORY_ALLOCATION_FAILS = 103
end

function prima_get_rc_string(rc)
Expand Down

0 comments on commit cc5afd3

Please sign in to comment.