Skip to content

Fixes in the APIs - #1099

Open
cvanaret wants to merge 9 commits into
mainfrom
fix_apis
Open

cvanaret wants to merge 9 commits into
mainfrom
fix_apis

Conversation

@cvanaret

@cvanaret cvanaret commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner
  • The model and solver were both void*, so uno_optimize(model, solver) compiled silently. They are now distinct incomplete struct types; the getters take a const uno_solver*. The ABI is unchanged, C code still compiles (implicit void* conversions), and the Julia/Fortran wrappers are unchanged (Ptr{Cvoid} / type(c_ptr)): wrapper_julia.jl maps the handles to Ptr{Cvoid}. C++ callers need the typed handles.

  • The model setters returned bool (true upon success), unlike the options, result and optimize functions, and contrary to the README (0 upon success). They now return UNO_MODEL_SUCCESS (0), UNO_MODEL_INVALID_ARGUMENT, UNO_MODEL_INVALID_INDEX, UNO_MODEL_INVALID_VALUE or UNO_MODEL_ERROR; uno_set_solver_callbacks returns UNO_SOLVER_SUCCESS/INVALID_ARGUMENT/ERROR. A NULL array passed to a bound or initial-iterate setter is now consistently UNO_MODEL_INVALID_ARGUMENT (it was a silent success for the bounds).

  • In C, a static const object is not an integer constant expression: the status codes could not be used as case labels. The integer constants are now enumerators, grouped in named enums; the functions still take and return uno_int. The version numbers are preprocessor macros, so that code can be written for both Uno 2.9 and 2.10 (#if UNO_VERSION_MINOR >= 10).
    The Python constants are cast (pybind11 cannot convert unregistered enums), the C API guard deduces its return type from the function, wrapper_julia.jl ignores the enum tags and version macros (constants still come from the prologue), and wrapper_fortran.jl reads the version from the macros.

  • uno_set_logger_stream_callback and uno_reset_logger_stream set a process-wide stream (and left a dangling global stream object), and uno_optimize set the global logger level from its options for the rest of the program. The stream is now stored in the solver (uno_set_logger_stream_callback(solver, ...), uno_reset_logger_stream(solver), UNO_SOLVER_* codes), and uno_optimize installs the stream and level of the solver for the duration of the optimization and restores the previous ones afterwards (RAII, also on exceptions). The logger of the core is still process-wide: concurrent optimizations in several threads remain unsupported (documented).

  • the Jacobian callback receives number_constraints (after number_variables), like the constraint, Hessian and operator callbacks.

  • every evaluation callback receives a flag new_x right after x (as in IPOPT): true if x differs from the point of the previous evaluation (of any function, during the current optimization), so that users can cache the quantities that depend only on x. UnoModel keeps a copy of the previous point and compares it exactly ($O(n)$ per evaluation). The evaluate_at_x flag of the Jacobian, transposed Jacobian and Hessian operator callbacks is removed (Uno always passed true).
    Updated: callers in the C API, the C/Fortran examples and tests, the CUTEst driver (new_x unused; got_j/got_h = .FALSE., as before), the Fortran abstract interfaces (prologue and uno_c.f90), the C README and the Julia C wrapper (new_x is ignored; the Julia-level eval_Jv, eval_Jtv and eval_Hv functions keep their signature and receive true for evaluate_at_x).

cc @amontoison

@cvanaret cvanaret self-assigned this Nov 25, 2026
@cvanaret cvanaret added bug Something isn't working interfaces labels Nov 25, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working interfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant