Skip to content

Commit

Permalink
Merge pull request #54 from oxfordcontrol/release-v0.6
Browse files Browse the repository at this point in the history
Release v0.6
  • Loading branch information
goulart-paul authored Sep 20, 2023
2 parents 84bb63f + 2b794ec commit 2c2f96e
Show file tree
Hide file tree
Showing 48 changed files with 2,120 additions and 890 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

Version numbering in this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). We aim to keep the core solver functionality and minor releases in sync between the Rust/Python and Julia implementations. Small fixes that affect one implementation only may result in the patch release versions differing.


## [0.6.0] - 2023-20-09
### Changed

This version introduces support for the generalized power cone and implements stability and speed improvements for SOC problems. SOCs with
dimension less than or equal to 4 are now treated as special cases with dense Hessian blocks.

- Introduces support for the generalized power cone.
- Implements stability and speed improvements for SOC problems. SOCs with dimension less than or equal to 4 are now treated as special cases with dense Hessian blocks.
- Fixes bad initialization point for non-quadratic objectives
- Improved convergence speed for QPs with no constraints or only ZeroCone constraints.
- Internal code restructuring for cones with sparsifiable Hessian blocks.

### Rust specific changes
- Added additional documentation and utilities [#43](https://github.com/oxfordcontrol/Clarabel.rs/issues/43),[#46](https://github.com/oxfordcontrol/Clarabel.rs/issues/46).
- Allow printing of internal timers through Julia wrappers in ClarabelRs [#44](https://github.com/oxfordcontrol/Clarabel.rs/issues/44)
- Updated keywords for crates.io [#45](https://github.com/oxfordcontrol/Clarabel.rs/issues/45)
- Better error reporting from internal QDLDL factor methods. Fixes [#49](https://github.com/oxfordcontrol/Clarabel.rs/issues/49)


## [0.5.1] - 2023-02-06
### Changed
Fixes convergence edge case in KKT direct solve iterative refinement.
Expand Down Expand Up @@ -79,6 +99,7 @@ offline against the Julia-based benchmark problem suite, but this will not appea
- Ported all documentation to the common site [here](https://github.com/oxfordcontrol/ClarabelDocs)


[0.6.0]: https://github.com/oxfordcontrol/Clarabel.rs/compare/v0.5.1...v0.6.0
[0.5.1]: https://github.com/oxfordcontrol/Clarabel.rs/compare/v0.5.0...v0.5.1
[0.5.0]: https://github.com/oxfordcontrol/Clarabel.rs/compare/v0.4.1...v0.5.0
[0.4.1]: https://github.com/oxfordcontrol/Clarabel.rs/compare/v0.4.0...v0.4.1
Expand Down
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "clarabel"
version = "0.5.1"
version = "0.6.0"
authors = ["Paul Goulart <[email protected]>"]
edition = "2021"
rust-version = "1.60"
license = "Apache-2.0"
description = "Clarabel Conic Interior Point Solver for Rust / Python"
readme = "README.md"
repository = "https://github.com/oxfordcontrol/Clarabel.rs"
keywords = ["convex", "optimization", "QP", "SOCP", "SDP"]
keywords = ["convex", "optimization", "conic", "solver", "linear-programming"]
categories = ["mathematics"]

#required for openssl to work on git actions
Expand All @@ -22,6 +22,7 @@ enum_dispatch = "0.3.8"
amd = "0.2.2"
thiserror = "1.0"
cfg-if = "1.0"
itertools = "0.11"

# -------------------------------
# features
Expand Down
13 changes: 1 addition & 12 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,7 @@

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2022 University of Oxford Control Group

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Interior Point Conic Optimization for Rust and Python
<a href="https://codecov.io/gh/oxfordcontrol/Clarabel.rs"><img src="https://codecov.io/gh/oxfordcontrol/Clarabel.rs/branch/main/graph/badge.svg"></a>
<a href="https://oxfordcontrol.github.io/ClarabelDocs/stable"><img src="https://img.shields.io/badge/Documentation-stable-purple.svg"></a>
<a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a>
<a href="https://github.com/oxfordcontrol/Clarabel.rs/releases"><img src="https://img.shields.io/badge/Release-v0.5.1-blue.svg"></a>
<a href="https://github.com/oxfordcontrol/Clarabel.rs/releases"><img src="https://img.shields.io/badge/Release-v0.6.0-blue.svg"></a>
</p>

<p align="center">
Expand Down Expand Up @@ -47,7 +47,7 @@ Clarabel is also available in a Julia implementation. See [here](https://github

## Features

* __Versatile__: Clarabel.rs solves linear programs (LPs), quadratic programs (QPs), second-order cone programs (SOCPs) and semidefinite programs (SDPs). It also solves problems with exponential and power cone constraints.
* __Versatile__: Clarabel.rs solves linear programs (LPs), quadratic programs (QPs), second-order cone programs (SOCPs) and semidefinite programs (SDPs). It also solves problems with exponential, power cone and generalized power cone constraints.
* __Quadratic objectives__: Unlike interior point solvers based on the standard homogeneous self-dual embedding (HSDE), Clarabel.rs handles quadratic objectives without requiring any epigraphical reformulation of the objective. It can therefore be significantly faster than other HSDE-based solvers for problems with quadratic objective functions.
* __Infeasibility detection__: Infeasible problems are detected using a homogeneous embedding technique.
* __Open Source__: Our code is available on [GitHub](https://github.com/oxfordcontrol/Clarabel.rs) and distributed under the Apache 2.0 License
Expand Down
79 changes: 72 additions & 7 deletions src/algebra/csc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use std::iter::zip;
/// [2. 0. 6.]
/// [0. 4. 7.]
/// ```
///
/// ```no_run
/// use clarabel::algebra::CscMatrix;
///
Expand Down Expand Up @@ -70,20 +69,18 @@ where
J: IntoIterator<Item = &'a T>,
T: FloatT,
{
#[allow(clippy::needless_range_loop)]
fn from(rows: I) -> CscMatrix<T> {
let rows: Vec<Vec<T>> = rows
.into_iter()
.map(|r| r.into_iter().map(|&v| v).collect())
.map(|r| r.into_iter().copied().collect())
.collect();

let m = rows.len();
let n = rows.iter().map(|r| r.len()).next().unwrap_or(0);

assert!(rows.iter().all(|r| r.len() == n));
let nnz = rows
.iter()
.flat_map(|r| r)
.filter(|&&v| v != T::zero())
.count();
let nnz = rows.iter().flatten().filter(|&&v| v != T::zero()).count();

let mut colptr = Vec::with_capacity(n + 1);
let mut rowval = Vec::with_capacity(nnz);
Expand Down Expand Up @@ -363,6 +360,53 @@ impl<T> ShapedMatrix for CscMatrix<T> {
}
}

/// Make a concrete [CscMatrix] from its [Adjoint]. This operation will
/// allocate a new matrix and copy the data from the adjoint.
///
/// __Example usage__ : To construct the transpose of a 3 x 3 matrix:
/// ```text
/// A = [1., 0., 0.]
/// [2., 4., 0.]
/// [3., 5., 6.]
///```
/// ```no_run
/// use clarabel::algebra::CscMatrix;
///
/// let A : CscMatrix = (&[
/// [1., 0., 0.], //
/// [2., 4., 0.], //
/// [3., 5., 6.],
/// ]).into();
///
/// let At = A.t(); //Adjoint form. Does not copy anything.
///
/// let B : CscMatrix = At.into(); //Concrete form. Allocates and copies.
///
/// assert_eq!(A, B);
///
/// ```
impl<'a, T> From<Adjoint<'a, CscMatrix<T>>> for CscMatrix<T>
where
T: FloatT,
{
fn from(M: Adjoint<'a, CscMatrix<T>>) -> CscMatrix<T> {
let src = M.src;

let (m, n) = (src.n, src.m);
let mut A = CscMatrix::spalloc((m, n), src.nnz());

//make dummy mapping indices since we don't care
//where the entries go
let mut amap = vec![0usize; src.nnz()];

A.colcount_block(src, 0, MatrixShape::T);
A.colcount_to_colptr();
A.fill_block(src, &mut amap, 0, 0, MatrixShape::T);
A.backshift_colptrs();
A
}
}

#[test]
fn test_csc_from_slice_of_arrays() {
let A = CscMatrix::new(
Expand Down Expand Up @@ -418,3 +462,24 @@ fn test_csc_get_entry() {
assert_eq!(A.get_entry((4, 3)), None);
assert_eq!(A.get_entry((3, 4)), None);
}

#[test]
fn test_adjoint_into() {
let A: CscMatrix = (&[
[1., 0., 0.], //
[2., 4., 0.], //
[3., 5., 6.],
])
.into();

let T: CscMatrix = (&[
[1., 2., 3.], //
[0., 4., 5.], //
[0., 0., 6.],
])
.into();

let B: CscMatrix = A.t().into(); //Concrete form. Allocates and copies.

assert_eq!(B, T);
}
3 changes: 2 additions & 1 deletion src/algebra/dense/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub struct Matrix<T = f64> {
/// [0.0, 4.0]]);
// ```
//
#[allow(clippy::needless_range_loop)]
impl<'a, I, J, T> From<I> for Matrix<T>
where
I: IntoIterator<Item = J>,
Expand All @@ -51,7 +52,7 @@ where
fn from(rows: I) -> Matrix<T> {
let rows: Vec<Vec<T>> = rows
.into_iter()
.map(|r| r.into_iter().map(|&v| v).collect())
.map(|r| r.into_iter().copied().collect())
.collect();

let m = rows.len();
Expand Down
3 changes: 1 addition & 2 deletions src/algebra/floats.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_snake_case)]
use num_traits::{Float, FloatConst, FromPrimitive, NumAssign};
use std::fmt::{Debug, Display, LowerExp};

Expand Down Expand Up @@ -79,8 +80,6 @@ cfg_if::cfg_if! {
// NB: `AsFloatT` is a convenience trait for f32/64 and u32/64
// so that we can do things like (2.0).as_T() everywhere on
// constants, rather than the awful T::from_f32(2.0).unwrap()

#[allow(non_snake_case)]
pub trait AsFloatT<T>: 'static {
fn as_T(&self) -> T;
}
Expand Down
5 changes: 4 additions & 1 deletion src/algebra/math_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ pub trait VectorMath {
/// Standard Euclidian or 2-norm distance from `self` to `y`
fn dist(&self, y: &Self) -> Self::T;

/// Sum of elements squared.
/// Sum of elements.
fn sum(&self) -> Self::T;

/// Sum of squares of the elements.
fn sumsq(&self) -> Self::T;

/// 2-norm
Expand Down
7 changes: 6 additions & 1 deletion src/algebra/vecmath.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::{FloatT, ScalarMath, VectorMath};
use itertools::izip;
use std::iter::zip;

impl<T: FloatT> VectorMath for [T] {
Expand Down Expand Up @@ -88,7 +89,7 @@ impl<T: FloatT> VectorMath for [T] {
assert_eq!(s.len(), ds.len());

let mut out = T::zero();
for ((&s, &ds), (&z, &dz)) in zip(zip(s, ds), zip(z, dz)) {
for (&s, &ds, &z, &dz) in izip!(s, ds, z, dz) {
let si = s + α * ds;
let zi = z + α * dz;
out += si * zi;
Expand All @@ -101,6 +102,10 @@ impl<T: FloatT> VectorMath for [T] {
T::sqrt(dist2)
}

fn sum(&self) -> T {
self.iter().fold(T::zero(), |acc, &x| acc + x)
}

fn sumsq(&self) -> T {
self.dot(self)
}
Expand Down
4 changes: 2 additions & 2 deletions src/julia/ClarabelRs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ClarabelRs"
uuid = "a0c58a0a-712c-48b7-9fd4-64369ecb2011"
authors = ["Paul Goulart <[email protected]>"]
version = "0.5.1"
version = "0.6.0"

[deps]
Clarabel = "61c947e1-3e6d-4ee4-985a-eec8c727bd6e"
Expand All @@ -11,4 +11,4 @@ Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[compat]
Clarabel = "0.5.1"
Clarabel = "0.6.0"
Loading

0 comments on commit 2c2f96e

Please sign in to comment.