Skip to content

Instantly share code, notes, and snippets.

@TOTON95
Last active May 18, 2021 18:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save TOTON95/e246babce1aea2df809509b4f5568956 to your computer and use it in GitHub Desktop.
Save TOTON95/e246babce1aea2df809509b4f5568956 to your computer and use it in GitHub Desktop.
Guide to install CVX into Octave / Ubuntu (16.10 & 18.04)

Guide to install CVX into Octave / Ubuntu (16.10 & 18.04)

This guide was made using different solutions shared at the CVX forums and experimentation, to successfuly install the CVX tools into Octave running in Ubuntu 16.10 and 18.04.


Dependencies:

OpenBLAS

$ sudo apt-get install libopenblas-dev

Terminal

1. Create a directory for the Octave tools and move into it

$ mkdir ~/your/path/to/Octave_dir/ && cd ~/your/path/to/Octave_dir/

2. Clone the CVX tools (rework branch)

$ git clone -b rework https://github.com/cvxr/CVX.git/

3. Move into the CVX directory

$ cd CVX

4. The "git clone..." command will not copy the content in directories sedumi and sdpt3, since they are a link, they should be deleted

$ rmdir sedumi sdpt3

5. Place the solvers into the Tool's directory

$ git clone https://github.com/sqlp/sdpt3.git

$ git clone https://github.com/sqlp/sedumi.git

OCTAVE

Using the Octave's Command Window:

1. Move to the CVX directory in Octave

 cd ~/your/path/to/Octave_dir/CVX

1.5 (After Octave 5.0)

Change the function octave_config_info by _octave_config_info_ at cvx_version (line 50). Octave Ref

2. Run the CVX compiler

 cvx_compile

NOTE: If there are problems with the compilation just add the parameter '-rebuild'

3. Move to the sdpt3 directory in Octave and install the solver

 cd ~/your/path/to/Octave_dir/CVX/sdpt3
 install_sdpt3 -nopath

NOTE: If there are problems with the compilation just add the parameter '-rebuild'

4. Move to the sedumi directory in Octave and install the solver

 cd ~/your/path/to/Octave_dir/CVX/sedumi
 install_sedumi -nopath

NOTE: It may be posible that this solver will be unable to compile due to the f77blas.h file, jump to ALTERNATIVE METHODS section and rebuild (add parameter '-rebuild')

 install_sedumi -nopath -rebuild

5. Move to the CVX directory and run cvx_setup

 cd ~/your/path/to/Octave_dir/CVX
 cvx_setup

The CVX is installed!


Alternative Methods

If you are having problems with the f77blas.h file try the following:

(A) Open the file blksdp.h at ~/your/path/to/Octave_dir/CVX/sedumi and replace the line:

#include <f77blas.h>

For

#include <openblas/f77blas.h>

Rebuild and continue with step 5.

 install_sedumi -nopath -rebuild

(B) Open the file blksdp.h at ~/your/path/to/Octave_dir/CVX/sedumi and replace the line:

#include <f77blas.h>

For

#include "cblas.h"

Also

#define FORT(x) BLASFUNC(x)

For

#define FORT(x) cblas_ ## x

Finally add this line next to the line mentioned above

typedef int blasint;

You may need to modify other files like sdmauxScalarmul.c at the same directory, pay attention to the compiler's messages.

Remove ampersand from functions like:

FORT(dscal)(&n,&alpha,x,&one);

to become

FORT(dscal)(n,alpha,x,one);

Rebuild and continue with step 5.

 install_sedumi -nopath -rebuild

These are the solutions by the moment. Feel free to ask anything about this procedure to the forum or to me. Best wishes and good luck!

References:

[1] http://ask.cvxr.com/t/cvx-on-octave-discussion/975/34

[2] http://ask.cvxr.com/t/cvx-on-octave-discussion/975/16

@matiasiescobar
Copy link

Hi, in the step 1.5 (octave) shoud said __octave_config_info__ (two _ at the beginning and end).

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