diff --git a/src/PRIMA.jl b/src/PRIMA.jl index 7681fcd..e7a9034 100644 --- a/src/PRIMA.jl +++ b/src/PRIMA.jl @@ -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) @@ -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) @@ -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) @@ -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) @@ -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 diff --git a/src/wrappers.jl b/src/wrappers.jl index d9e2ace..dd42b7b 100644 --- a/src/wrappers.jl +++ b/src/wrappers.jl @@ -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)