`CUTEst`

is the latest evolution of CUTE, *the constrained and unconstrained testing environment for numerical optimization* . Detailed instruction can be found at CUTEst wiki, CUTEst_1 and CUSTst_2 by `Nicholas I. M. Gould, etc.`

. Currently, there are $1285$ problems including $372$ unconstrained problems in the set, with function evaluation (objective value, gradient, hessian) available.

It takes me a while to install all the stuff and here I’m going to show how to create the Matlab and Python interface for `CUTEst`

. I’m installing on **macOS High Sierra, Version 10.13.2**, **Matlab 2017b**, **python2.7.10**, and **Xcode 9.3**, it should be similar to other setting as well. If you’d like to work on linux, linux-cutest would be what you’re looking for.

### CUTEst Installation

You could go over CUTEst wiki and install problem sets: cutest, mastsif, sifdecode, and archdefs, separately. However, I would recommend you to install cutest basis with homebrew-cutest. There is no need to `git clone`

the repository, as long as you have `homebrew`

installed, just go with

1 | brew tap optimizers/cutest # downloading problem sets (sifdecode, archdefs and cutest) |

After install all the dependencies for cutest, run

1 | for f in "archdefs" "mastsif" "sifdecode" "cutest"; do \ |

This will add path scripts as following to your bash file (usually at `~/.bashrc`

, otherwise add the following to your configuration correspondingly)

1 | . /usr/local/opt/archdefs/archdefs.bashrc |

You would also need specify the executable command of sifdecode and cutest by adding the follows

1 | export PATH="${SIFDECODE}/bin:${PATH}" |

### Matlab Interface

You need also compile cutest problems using C or Fortran and interactive with matlab mex. To do this, one could follow cutest-mirror, README.osx, which suggest you have Xcode or at least xcode command-line installed. The matlab path should be provide as well

1

2

3

4

5export MYARCH="mac64.osx.gfo"

export MYMATLABARCH="mac64.osx.gfo"

export MYMATLAB="/Applications/MATLAB_R2017b.app"

export MATLABPATH=$CUTEST/src/matlab:$MATLABPATHYou need also copy clang_maci64.xml to your matlab version.

1

sudo cp clang_maci64.xml /Applications/MATLAB_R2017b.app/bin/maci64/mexopts/

Then you need to make sure

`.mex`

files can be compiled by C for Fortran for matlab usage.First, check whether the compiler path is wrong by

1

/Applications/MATLAB_R2017b.app/bin/mex -setup -v

If everything goes right, you are lucky and can move forwards. Otherwise, with errors like

1

No supported compiler or SDK was found. For options, visit https://www.mathworks.com/support/compilers.

You will need to do the following: at first, try to locate your SDK in Xcode, in may case, it is

1

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs

It shows the SDK version for my Xcode is

**MacOSX10.13.sdk**in my case. Then you need to modify your**clang_maci64.xml**file to make sure the Xcode C compiler can be founded, i.e. you should add these two lines in both*ISYSROOT*and*SDKVER*blocks (at around the end of the file)1

2<dirExists name="$$/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk" />

<cmdReturns name="find $$ -name MacOSX10.13.sdk" />After that, it should be good to setup the Xcode C compiler for matlab by

1

2

3

4/Applications/MATLAB_R2017b.app/bin/mex -setup C

# or please try

# /Applications/MATLAB_R2017b.app/bin/mex C++

# /Applications/MATLAB_R2017b.app/bin/mex FORTRANNote that each time if you upgrade matlab or Xcode, you may need to reconfigure the SDK path.

Next please refer to cutest-mirror/src/matlab/README.matlab. To run the test problem including problem decoding and function evaluation with given problem name (the problem name can be found in mastsif or cutest), run from bash as following

1

cutest2matlab_osx PROBLEM_NAME

this should generate a set of files like

1

2

3

4AUTOMAT.d EXTER.o RANGE.f mcutest.o

ELFUN.f GROUP.f RANGE.o

ELFUN.o GROUP.o libROSENBR.dylib*

EXTER.f OUTSDIF.d mcutest.mexmaci64*Open matlab in the same folder of those generated files, you could then do

1

2

3>> cutest_terminate

>> prob = cutest_setup()

>> [f, g] = cutest_obj(prob.x)A collection of usable functions for the problems can be found at CUSTst paper. as well as

`$CUTEST/src/matlab`

. To list a few1

2

3

4

5

6

7

8

9

10

11README.matlab cutest_ihess.m cutest_slagjac.m

ctools.F cutest_isphess.m cutest_sobj.m

cutest.m cutest_jprod.m cutest_sphess.m

cutest_connames.m cutest_jtprod.m cutest_terminate.m

cutest_cons.m cutest_lag.m cutest_varnames.m

cutest_dims.m cutest_lagjac.m gtools.F

cutest_grad.m cutest_obj.m makemaster

cutest_gradhess.m cutest_objcons.m mcutest.c

cutest_gradsphess.m cutest_scons.m test_cutest.m

cutest_hess.m cutest_setup.m utools.F

cutest_hprod.m cutest_sgrad.m

### Python Interface

I tried to install everything on `python3`

but no lucky. Here I’m showing the installation over `python2.7.10`

You need two module to start the installation, CUTEST.py and it’s necessary dependency NLP.py. Follow the installation instruction.

If you encounter error regarding compiling the original

`.sif`

problem data file (as I have the error). Try to modify`CUTEST.py/cutest/tools/compile.py`

and add fortran compiling option [“-lfgfortran”] at line $111$.As long as you have

`CUSTst`

installed correctly, you should able to following the similar steps as in`Matlab interface installation`

to add necessary path.The usage is quite simple, just go with

1

2

3

4

5>>> from cutest.model.cutestmodel import CUTEstModel

>>> model = CUTEstModel('ROSENBR')

>>> f = model.obj(model.x0)

>>> g = model.grad(model.x0)

>>> H = model.hess(model.x0)A collection of usable function for the problem can be found at cutestmodel.py.

Enjoy!