Skip to content

Commit f2549a9

Browse files
committed
Version 0.8.0
1 parent a3abb7b commit f2549a9

File tree

8 files changed

+224
-19
lines changed

8 files changed

+224
-19
lines changed

CHANGELOG.md

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,43 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
## argmin-math [Unreleased]
1111

12+
## argmin [argmin v0.8.0] 2023-01-28
13+
14+
### Added
15+
16+
* Added a `full` feature which enables all features (@stefan-k)
17+
* Added a particle swarm optimization example using the `nalgebra` math backend (@stefan-k)
18+
* Added a L-BFGS example using the `nalgebra` math backend (@stefan-k)
19+
20+
### Changed
21+
22+
* Improved termination handling (@relf, #305)
23+
- Introduced `TerminationStatus` which can either be `Terminated(TerminationReason)` or `NotTerminated`
24+
- The fields of the `TerminationReason` enum were reduced to cases potentially relevant to any solver. Solver-specific cases can be handled with `SolverExit(String)`.
25+
- Added new `TerminationReason::KeyboardInterrupt` and `TerminationReason::Converged`
26+
* Changes to KV store used to get values from the solver to observers (@stefan-k)
27+
- KV store is now typed (via `KvValue`), which means that observers can now use the actual numbers (in the past those values were only `dyn Display` and as such could only be printed)
28+
- `make_kv!` renamed to `kv!`
29+
* Solver does not need to be `Serialize` anymore when `serde1` feature is enabled. This was an oversight reported by @relf and fixed by @stefan-k
30+
* Better calculation of elapsed time inside `Executor` (@TheIronBorn)
31+
* The check whether the target cost is reached is now based on the current best cost function value rather than the current cost function value (@relf)
32+
33+
34+
## argmin-math [argmin-math v0.3.0] 2023-01-28
35+
36+
### Added
37+
38+
* Added support for `nalgebra` 0.32
39+
40+
### Changed
41+
42+
* All math backends now implement all math related traits (apart from the `Vec` backend which does not implement `ArgminInv`). Therefore (almost) all solvers work with all backends. (@hypotrochoid, @stefan-k)
43+
* More primitive and complex types are now covered as well (@stefan-k)
44+
* Reached 100% test coverage (@stefan-k)
45+
* `InverseError` is not `Clone` anymore (@stefan-k)
46+
* Upgraded `ndarray-linalg` to version 0.16 for the `ndarray` 0.15 backend
47+
48+
1249
## [argmin-math v0.2.1] 2022-09-09
1350

1451
### Added
@@ -186,9 +223,11 @@ This is a rather large release with many (breaking) changes.
186223

187224
For older versions please see the Git history.
188225

189-
[Unreleased]: https://github.com/argmin-rs/argmin/compare/v0.6.0...HEAD
226+
[Unreleased]: https://github.com/argmin-rs/argmin/compare/argmin-v0.8.0...HEAD
227+
[argmin v0.8.0]: https://github.com/argmin-rs/argmin/compare/argmin-v0.7.0...argmin-v0.8.0
228+
[argmin v0.7.0]: https://github.com/argmin-rs/argmin/compare/argmin-v0.6.0...argmin-v0.7.0
190229
[argmin v0.6.0]: https://github.com/argmin-rs/argmin/compare/v0.5.1...argmin-v0.6.0
191-
[argmin-math v0.1.0]: https://github.com/argmin-rs/argmin/compare/v0.5.1...argmin-v0.6.0
192-
[argmin v0.6.0]: https://github.com/argmin-rs/argmin/compare/argmin-v0.6.0...argmin-v0.7.0
193-
[argmin-math v0.2.0]: https://github.com/argmin-rs/argmin/compare/argmin-v0.6.0...argmin-v0.7.0
194-
[argmin-math v0.2.1]: https://github.com/argmin-rs/argmin/compare/argmin-v0.7.0...argmin-math-v0.2.1
230+
[argmin-math v0.3.0]: https://github.com/argmin-rs/argmin/compare/argmin-math-v0.2.1...argmin-math-v0.3.0
231+
[argmin-math v0.2.1]: https://github.com/argmin-rs/argmin/compare/argmin-math-v0.2.0...argmin-math-v0.2.1
232+
[argmin-math v0.2.0]: https://github.com/argmin-rs/argmin/compare/argmin-math-v0.1.0...argmin-math-v0.2.0
233+
[argmin-math v0.1.0]: https://github.com/argmin-rs/argmin/compare/v0.5.1...argmin-math-v0.1.0

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
</p>
1010

1111
<p align="center">
12-
<a href="http://argmin-rs.org">Website</a>
12+
<a href="https://argmin-rs.org">Website</a>
1313
|
14-
<a href="http://argmin-rs.org/book/">Book</a>
14+
<a href="https://argmin-rs.org/book/">Book</a>
1515
|
1616
<a href="https://docs.rs/argmin">Docs (latest release)</a>
1717
|
@@ -24,12 +24,12 @@
2424

2525
<p align="center">
2626
<!--
27-
<a href="http://argmin-rs.org"
27+
<a href="https://argmin-rs.org"
2828
><img
2929
src="https://img.shields.io/website?down_message=offline&style=flat-square&up_message=argmin-rs.org&url=http%3A%2F%2Fargmin-rs.org"
3030
alt="Website"
3131
/></a>
32-
<a href="http://argmin-rs.org/book/"
32+
<a href="https://argmin-rs.org/book/"
3333
><img
3434
src="https://img.shields.io/website?label=book&style=flat-square&url=http%3A%2F%2Fargmin-rs.org%2Fbook%2F"
3535
alt="Website"

argmin-math/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
22
name = "argmin-math"
3-
version = "0.2.1"
3+
version = "0.3.0"
44
authors = ["Stefan Kroboth <[email protected]>"]
55
edition = "2021"
66
license = "MIT OR Apache-2.0"
77
description = "argmin math abstractions"
88
documentation = "https://docs.rs/argmin-math/"
9-
homepage = "http://argmin-rs.org"
9+
homepage = "https://argmin-rs.org"
1010
repository = "https://github.com/argmin-rs/argmin"
1111
readme = "README.md"
1212
keywords = ["optimization", "math", "science"]

argmin-math/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
</p>
1010

1111
<p align="center">
12-
<a href="http://argmin-rs.org">Website</a>
12+
<a href="https://argmin-rs.org">Website</a>
1313
|
14-
<a href="http://argmin-rs.org/book/">Book</a>
14+
<a href="https://argmin-rs.org/book/">Book</a>
1515
|
1616
<a href="https://docs.rs/argmin-math">Docs (latest release)</a>
1717
|
@@ -41,7 +41,7 @@
4141
</p>
4242

4343

44-
This create provides a abstractions for mathematical operations needed in [argmin](http://argmin-rs.org).
44+
This create provides a abstractions for mathematical operations needed in [argmin](https://argmin-rs.org).
4545
The supported math backends so far are basic `Vec`s, `ndarray` and `nalgebra`.
4646
Please consult the documentation for details.
4747

argmin-math/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! argmin.
1212
//!
1313
//! For an introduction on how to use argmin, please also have a look at the
14-
//! [book](http://www.argmin-rs.org/book/).
14+
//! [book](https://www.argmin-rs.org/book/).
1515
//!
1616
//! # Usage
1717
//!

argmin/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
22
name = "argmin"
3-
version = "0.7.0"
3+
version = "0.8.0"
44
authors = ["Stefan Kroboth <[email protected]>"]
55
edition = "2021"
66
license = "MIT OR Apache-2.0"
77
description = "Mathematical optimization in pure Rust"
88
documentation = "https://docs.rs/argmin/"
9-
homepage = "http://argmin-rs.org"
9+
homepage = "https://argmin-rs.org"
1010
repository = "https://github.com/argmin-rs/argmin"
1111
readme = "../README.md"
1212
keywords = ["optimization", "math", "science"]
@@ -22,7 +22,7 @@ num-traits = { version = "0.2" }
2222
rand = { version = "0.8.5" }
2323
rand_xoshiro = { version = "0.6.0" }
2424
thiserror = "1.0"
25-
argmin-math = { path = "../argmin-math", version = "0.2", default-features = false, features = ["primitives"] }
25+
argmin-math = { path = "../argmin-math", version = "0.3", default-features = false, features = ["primitives"] }
2626
# optional
2727
bincode = { version = "1.3.3", optional = true }
2828
ctrlc = { version = "3.1.2", optional = true }

argmin/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
//! and Hessians is taken care of by the library.
2727
//!
2828
//! For an introduction on how to use argmin, please also have a look at the
29-
//! [book](http://www.argmin-rs.org/book/).
29+
//! [book](https://www.argmin-rs.org/book/).
3030
//!
3131
//! # Highlights
3232
//!
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
+++
2+
title = "argmin 0.8.0 and argmin-math 0.3.0 released"
3+
description = ""
4+
date = 2023-01-28T00:00:00+00:00
5+
updated = 2023-01-28T00:00:00+00:00
6+
draft = false
7+
template = "blog/page.html"
8+
9+
[taxonomies]
10+
authors = ["Stefan Kroboth"]
11+
12+
[extra]
13+
+++
14+
15+
<b>argmin</b> is a Rust library which offers a range of numerical optimization methods and a framework for
16+
developing optimization algorithms. <b>argmin-math</b> is a trait-based abstraction layer for mathematical operations,
17+
which makes argmin compatible with various math backends such as [ndarray](https://crates.io/crates/ndarray) and
18+
[nalgebra](https://crates.io/crates/nalgebra) (or your own backend).
19+
For details about the design of argmin and its features I suggest having a look at
20+
[the website](https://argmin-rs.org),
21+
[the book](https://argmin-rs.org/book),
22+
[Github](https://github.com/argmin-rs/argmin),
23+
[crates.io](https://crates.io/crates/argmin) and
24+
[lib.rs](https://lib.rs/crates/argmin).
25+
26+
This is a short summary of the changes in argmin 0.8.0 and argmin-math 0.3.0.
27+
Both releases include breaking API changes; however upgrading from the previous versions should hopefully be fairly smooth.
28+
Don't hesitate [to get in touch](https://github.com/argmin-rs/argmin/issues) in case you run into problems during upgrading.
29+
30+
## argmin 0.8.0
31+
32+
#### Improved termination handling
33+
34+
The solver state contains a `TerminationReason` enum which indicates why the solver terminated.
35+
The enum variants offered in previous versions of argmin were either applicable to all solvers or were solver-specific.
36+
[@relf](https://github.com/relf) [rightfully pointed out](https://github.com/argmin-rs/argmin/issues/305) that these variants weren't ideal:
37+
For instance, it included an awkward variant `NotTerminated` and a couple of variants could be summarized as `Converged`.
38+
Whenever a `Ctrl+C` was intercepted, the reason would be `Aborted`, which is suboptimal because a solver could also abort
39+
due to other reasons.
40+
In the discussion we decided to change the `TerminationReason` enum to the following:
41+
42+
```rust
43+
pub enum TerminationReason {
44+
/// Reached maximum number of iterations
45+
MaxItersReached,
46+
/// Reached target cost function value
47+
TargetCostReached,
48+
/// Algorithm manually interrupted with Ctrl+C
49+
KeyboardInterrupt,
50+
/// Converged
51+
SolverConverged,
52+
/// Solver exit with given reason
53+
SolverExit(String),
54+
}
55+
```
56+
57+
The first two are potential outcomes of two checks performed by the `Executor` for every solver.
58+
`KeyboardInterrupt` replaces `Aborted` and is only used for `Ctrl+C`.
59+
`SolverConverged` indicates a successful optimization run and `SolverExit(String)` is used for
60+
cases where the solver stopped for a solver-specific reason specified by a string.
61+
62+
The awkward `NotTerminated` was dropped and instead a new enum `TerminationStatus` is introduced:
63+
64+
```rust
65+
enum TerminationStatus {
66+
NotTerminated,
67+
Terminated(TerminationReason)
68+
}
69+
```
70+
71+
This enum is stored in the state instead of `TerminationReason`.
72+
It can be obtained from an `OptimizationResult` via the solver state:
73+
74+
```rust
75+
// of type &TerminationStatus
76+
let status = result.state().get_termination_status();
77+
78+
// ... or ...
79+
80+
// of type Option<&TerminationReason>
81+
let reason = result.state().get_termination_reason();
82+
```
83+
84+
Both methods are part of the `State` trait and as such available for all available states.
85+
86+
Note that this is a breaking change and as such you may have to adapt your code, in particular if you use the returned
87+
termination reason.
88+
89+
Huge thanks to [@relf](https://github.com/relf) for the fruitful discussion and for doing all the heavy lifting!
90+
91+
92+
#### Changes to the observer interface
93+
94+
In the past, values sent to the observers were only `dyn Display`, which means they could effectively only be turned into strings.
95+
To get the actual value one had to parse the strings into a given type, which isn't great (to put it mildly).
96+
97+
Therefore I decided [to make the values sent to the observers typed](https://github.com/argmin-rs/argmin/pull/269) and
98+
added support for 64bit floats, signed and unsigned 64bit integer, Booleans and Strings via the `KvValue` enum:
99+
100+
```rust
101+
pub enum KvValue {
102+
Float(f64),
103+
Int(i64),
104+
Uint(u64),
105+
Bool(bool),
106+
Str(String),
107+
}
108+
```
109+
110+
The actual values can be retrieved via the getters `get_float`, `get_int`, `get_uint`, `get_bool` and `get_string`,
111+
which return `Some(<inner_value>)` if the `KvValue` is of the appropriate type and `None` otherwise.
112+
113+
The `make_kv!` macro used in solvers to construct the Key-Value store was renamed to `kv!`.
114+
115+
These changes will only affect you if you wrote an observer or solver yourself.
116+
All observers shipped with argmin should continue to work as before.
117+
118+
#### Other
119+
120+
* Implementing the `Solver` trait for a solver does not require anymore that the solver implements `serde::Serialize` when the `serde1` feature is enabled.
121+
This was a remnant of an earlier design of the `Solver` trait found by [@relf](https://github.com/relf).
122+
Note that checkpointing requires solvers to be serializable!
123+
Therefore, despite lifting this requirement, it is still recommended that solvers are (de)serializable if possible.
124+
* The check whether an optional target cost is reached is now based on the best cost function value so far rather than the current cost function value ([@relf](https://github.com/relf))
125+
* Added a `full` feature which activates all features.
126+
* Added a particle swarm optimization and L-BFGS example using the nalgebra backend.
127+
* Elapsed time is now computed using `as_secs_f64` ([@TheIronBorn](https://github.com/TheIronBorn))
128+
* Internally uses argmin-math 0.3.0, so make sure to update both!
129+
130+
## argmin-math 0.3.0
131+
132+
With this release all backends finally implement all math-related traits, meaning that every backend now works with every solver.
133+
The only exception to this is the `vec` backend, which does not implement `ArgminInv` and as such does not
134+
work with (Gauss-)Newton methods.
135+
I've spent multiple days tediously implementing all missing traits and adding tests for every implementation
136+
(eventually reaching 100% test coverage).
137+
[@hypotrochoid](https://github.com/hypotrochoid) implemented the `ArgminRandom` trait for the ndarray backend
138+
and with that kicked off this entire endeavour. Thanks!
139+
140+
Apart from that support for nalgebra 0.32 was added and ndarray-linalg was updated from version 0.14 to 0.16 for
141+
the ndarray v0.15 backend.
142+
Therefore you may have to update ndarray-linalg as well.
143+
144+
Upgrading to version 0.3.0 of argmin-math should be smooth for most cases.
145+
146+
## Other news
147+
148+
argmin is not only a collection of optimization algorithms but also aims to be a framework which facilitates
149+
the development of optimization algorithms.
150+
Solvers implemented using argmin get features such as checkpointing, observers and support for various math backends for free.
151+
152+
However, I have not seen any use of this feature outside of argmin itself up until recently, when [@relf](https://github.com/relf)
153+
made his [egobox-ego solver](https://crates.io/crates/egobox-ego)
154+
[compatible with argmin](https://github.com/relf/egobox/pull/67).
155+
This is very exciting for me as this led to valuable feedback on the design of argmin and I hope that others will follow
156+
that example and make their solvers compatible with argmin.
157+
158+
159+
<br>
160+
<script async defer src="https://buttons.github.io/buttons.js"></script>
161+
<p align="center">
162+
<a class="github-button" href="https://github.com/argmin-rs/argmin" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star argmin-rs/argmin on GitHub">Star</a>
163+
<a class="github-button" href="https://github.com/argmin-rs/argmin/subscription" data-icon="octicon-eye" data-size="large" data-show-count="true" aria-label="Watch argmin-rs/argmin on GitHub">Watch</a>
164+
<a class="github-button" href="https://github.com/argmin-rs/argmin/fork" data-icon="octicon-repo-forked" data-size="large" data-show-count="true" aria-label="Fork argmin-rs/argmin on GitHub">Fork</a>
165+
<a class="github-button" href="https://github.com/sponsors/stefan-k" data-icon="octicon-heart" data-size="large" aria-label="Sponsor @stefan-k on GitHub">Sponsor</a>
166+
</p>

0 commit comments

Comments
 (0)