Convex Optimization with Octave: Status Check 2022
Octave is a fantastic open-source alternative to Matlab. It provides more-or-less compatible core functionality to Matlab by Mathworks. This is great for those who like the hassle-free approach that Matlab provides for numerical computation, but do not want to or can't buy an expensive license for it.
The Octave team release a new major update 7.1.0 in April 2022 with many great improvements. Given the new releases on our hands, we become curious on how what is the current state of convex optimization using Octave.
There are two major convex optimization libraries for Matlab: CVX and YALMIP. We will have a look at the current status of these libraries and their support for octave.
CVX
CVX is a very popular award-winning optimization library for Matlab. It originates from the famous Stanford Optimization Group. It provides an easy-to-use interface for convex optimization with support for various free and commercial solvers.
Here is an example from the official CVX documentation for solving a simple least-squares problem.
% Input data
m = 16; n = 8;
A = randn(m,n);
b = randn(m,1);
% Matlab version
x_ls = A \ b;
% cvx version
cvx_begin
variable x(n)
minimize( norm(A*x-b) )
cvx_end
Octave support
The stable release branch (version 2.x) does not provide support for Octave. This has been the case since the beginning. However, there is a beta branch (version 3.x) that provides some initial steps for supporting Octave.
Unfortunately, it seems that the development for the 3.x branch has stopped in 2017, and has not received any updates since. The version of Octave that was initially supported was 4.x. Since then, there have been a lot of internal changes. These changes make even the 3.x branch non-functional on Octave.
Taking also into account that there have not been any major updates in two years for the stable branch. I am not too hopeful with the CVX support for Octave. This is a shame, since CVX is used extensively in the academy, and in many cases, it may prevent students and researchers from using Octave in their work.
Recent versions of Octave are not supported in any way by CVX.
YALMIP
YALMIP is also a long-standing convex optimization framework. It has been around for a long time and It has not achieved as much fame as the CVX, but it is fully comparable in practice.
YALMIP provides a feature-rich interface with support for a lot of solvers. It is quite intuitive to use. It usually takes minimal effort to translate a problem from paper to Matlab/Octave implementation.
Here is the same least-squares problem that we presented for CVX modeled in YALMIP.
% Input data
m = 16; n = 8;
A = randn(m,n);
b = randn(m,1);
% Matlab version
x_ls = A \ b;
% yalmip version
x = sdpvar(n, 1);
obj = norm(A*x - b);
optimize([], obj);
You can see that the interface is very much similar to CVX.
One benefit of YALMIP is that it is written fully in Matlab. This means that there are no quirks caused by natively compiled libraries.
One thing you need to keep in mind when using YALMIP is that it does not come bundled with any generic compilers. So you need to install the required compilers yourself. This is usually not a problem. At least, Sedumi (SDP compliant solver) was easy to install on Arch Linux.
YALMIP is under active development, which means that bugs are being fixed and new features added consistently. You can follow the latest advancements directly from their Github account.
Octave support
Check the video below on our experiment of running version R20210331 on Octave 7.1.0.
The good news is that YALMIP does have support for Octave and it still works with the latest version.
YALMIP has working support for Octave.
Summary
At the moment, if you want to use Octave with a general convex optimization, there is really only one choice: YALMIP. It works pretty much as expected. It has great documentation with lots of examples. You do need to be careful with the solver as they need to be separately installed.