Skip to content

Commit

Permalink
Prepare release 0.5.0 (#16)
Browse files Browse the repository at this point in the history
* Manage visibility, remove #[no_mangle]

* Cleanup

* BUmp 0.5.0

* Update CHANGELOG
  • Loading branch information
relf committed Oct 13, 2023
1 parent 721eb25 commit f5fb66c
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 128 deletions.
5 changes: 0 additions & 5 deletions .vscode/settings.json

This file was deleted.

6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

## [Unreleased]

## [0.5.0] - 2023-10-13

* Remove `fmin_cobyla` implementation as `nlopt_cobyla` now renamed `minimize` based on NLopt implementation is more powerful
Nevertheless Cobyla argmin solver is still based on initial implementation, not on NLopt one.
* Remove gradient from `ObjFn` trait which is now renamed `Func`
* `minimize` API rework to make it more Rusty
* `minimize` API rework to make it more Rusty.
* Not all options of NLopt version are managed. Currently `cobyla::minimize` handles `xinit`, `bounds`, `max_eval`, `ftol_rel`,
`ftol_abs`, `xtol_rel`, `xtol_abs` and only inequality contraints (like c >= 0). See documentation for further details.

## [0.4.0] - 2023-10-06

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["Remi Lafage <[email protected]>"]
name = "cobyla"
version = "0.5.0-alpha.1"
version = "0.5.0"
edition = "2021"
license-file = "LICENSE.md"
description = "COBYLA optimizer for Rust"
Expand Down
48 changes: 24 additions & 24 deletions src/cobyla.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use std::convert::TryFrom;

#[repr(C)]
pub enum CobylaStatus {
pub(crate) enum CobylaStatus {
COBYLA_INITIAL_ITERATE = 2,
COBYLA_ITERATE = 1,
COBYLA_SUCCESS = 0,
Expand All @@ -44,9 +44,9 @@ pub enum CobylaStatus {
// // static mut stderr: *mut FILE;
// // fn fprintf(_: *mut FILE, _: *const libc::c_char, _: ...) -> libc::c_int;
// }
pub type size_t = libc::c_ulong;
pub type __off_t = libc::c_long;
pub type __off64_t = libc::c_long;
pub(crate) type size_t = libc::c_ulong;
pub(crate) type __off_t = libc::c_long;
pub(crate) type __off64_t = libc::c_long;
// #[derive(Copy, Clone)]
// #[repr(C)]
// pub struct _IO_FILE {
Expand Down Expand Up @@ -82,7 +82,7 @@ pub type __off64_t = libc::c_long;
// }
// pub type _IO_lock_t = ();
// pub type FILE = _IO_FILE;
pub type cobyla_calcfc = unsafe fn(
pub(crate) type cobyla_calcfc = unsafe fn(
libc::c_long,
libc::c_long,
*const libc::c_double,
Expand Down Expand Up @@ -162,7 +162,7 @@ impl Default for cobyla_context_t {
}

#[allow(clippy::too_many_arguments)]
pub unsafe fn raw_cobyla(
pub(crate) unsafe fn raw_cobyla(
mut n: libc::c_long,
mut m: libc::c_long,
mut calcfc: Option<cobyla_calcfc>,
Expand Down Expand Up @@ -209,8 +209,8 @@ pub unsafe fn raw_cobyla(
iact,
);
}
#[no_mangle]
pub unsafe fn cobyla_create(

pub(crate) unsafe fn cobyla_create(
mut n: libc::c_long,
mut m: libc::c_long,
mut rhobeg: libc::c_double,
Expand Down Expand Up @@ -305,14 +305,14 @@ pub unsafe fn cobyla_create(
*fresh10 = ((*ctx).dx).offset(n as isize);
return ctx;
}
#[no_mangle]
pub unsafe fn cobyla_delete(mut ctx: *mut cobyla_context_t) {

pub(crate) unsafe fn cobyla_delete(mut ctx: *mut cobyla_context_t) {
if !ctx.is_null() {
let _ = Box::from_raw(ctx);
}
}
#[no_mangle]
pub unsafe fn cobyla_restart(mut ctx: *mut cobyla_context_t) -> libc::c_int {

pub(crate) unsafe fn cobyla_restart(mut ctx: *mut cobyla_context_t) -> libc::c_int {
if ctx.is_null() {
// *__errno_location() = 14 as libc::c_int;
return -(3 as libc::c_int);
Expand All @@ -321,40 +321,40 @@ pub unsafe fn cobyla_restart(mut ctx: *mut cobyla_context_t) -> libc::c_int {
(*ctx).status = 1 as libc::c_int;
return (*ctx).status;
}
#[no_mangle]
pub unsafe fn cobyla_get_status(mut ctx: *const cobyla_context_t) -> libc::c_int {

pub(crate) unsafe fn cobyla_get_status(mut ctx: *const cobyla_context_t) -> libc::c_int {
if ctx.is_null() {
// *__errno_location() = 14 as libc::c_int;
return -(3 as libc::c_int);
}
return (*ctx).status;
}
#[no_mangle]
pub unsafe fn cobyla_get_nevals(mut ctx: *const cobyla_context_t) -> libc::c_long {

pub(crate) unsafe fn cobyla_get_nevals(mut ctx: *const cobyla_context_t) -> libc::c_long {
if ctx.is_null() {
// *__errno_location() = 14 as libc::c_int;
return -(1 as libc::c_int) as libc::c_long;
}
return (*ctx).nfvals;
}
#[no_mangle]
pub unsafe fn cobyla_get_rho(mut ctx: *const cobyla_context_t) -> libc::c_double {

pub(crate) unsafe fn cobyla_get_rho(mut ctx: *const cobyla_context_t) -> libc::c_double {
if ctx.is_null() {
// *__errno_location() = 14 as libc::c_int;
return -(1 as libc::c_int) as libc::c_double;
}
return (*ctx).rho;
}
#[no_mangle]
pub unsafe fn cobyla_get_last_f(mut ctx: *const cobyla_context_t) -> libc::c_double {

pub(crate) unsafe fn cobyla_get_last_f(mut ctx: *const cobyla_context_t) -> libc::c_double {
if ctx.is_null() {
// *__errno_location() = 14 as libc::c_int;
return -(1 as libc::c_int) as libc::c_double;
}
return (*ctx).f;
}
#[no_mangle]
pub unsafe fn cobyla_iterate(

pub(crate) unsafe fn cobyla_iterate(
mut ctx: *mut cobyla_context_t,
mut f: libc::c_double,
mut x: *mut libc::c_double,
Expand Down Expand Up @@ -3453,8 +3453,8 @@ unsafe fn trstlp(
}
}
}
#[no_mangle]
pub unsafe fn cobyla_reason(mut status: libc::c_int) -> *const libc::c_char {

pub(crate) unsafe fn cobyla_reason(mut status: libc::c_int) -> *const libc::c_char {
match status {
1 => {
return b"user requested to compute F(X) and C(X)\0" as *const u8
Expand Down
Loading

0 comments on commit f5fb66c

Please sign in to comment.