Monday, June 3, 2013

Optimization Solver Benchmarks

These days I use a lot of optimization in my research. The optimization method called Sum-of-Squares of polynomials (SOS) programming is the essential backbone of my research topic. Two years ago I started to play with Prof. Megretski's spot (Systems Polynomial Optimization Tools), which is in Matlab and based on Sturm's Sedumi (and sadly just notice Dr. Sturm has passed away since 2003). This spot/Sedumi combination worked fine most of the time, but for more print-out information and options, I followed Prof. Parrilo's suggestion for Yalmip, which has better up-to-date support for SOS. (Interestingly SOS and its first tool SOSTOOLS was created by Parrilo and I was suggested away from his software.) Since then, I have been using Yalmip/Sedumi for most of my work for a while.

However, there are still hiccups for this combination. Sedumi sometimes reports possible bad quality solutions or stops iterations. Yalmip may kindly warn me to check, for example, whether the SOS decomposition is fine. However, that seems not a permanent solution. Therefore, I start to look around for other solvers. Most of optimization problem formulators by default at least support Sedumi and SDPT3. Luckily, Yalmip supports various types of solvers as its own backends. That makes my porting work between solvers much simpler.

So here comes the problem: how to choose between solvers? People argues several criteria, such as solution quality, solution feasibility, speed for certain problems, and more. This note gives some ideas.

And for speed, here is a well-compiled benchmark list, by Prof. Mittelmann at Arizona State University.


Saturday, September 17, 2011

Emacs for LaTeX on Windows and on Ubuntu

Want to use Emacs to type up your LaTeX document? Here is the article for you. Setting up Emacs on Ubuntu is a lot easier than on Windows. For Ubuntu (at least on 10.04), simply type
  • sudo apt-get install emacs
You may also like to install some other emacs-lisp scripts to help your editing work, for instance, color-theme to give you a better mood while editing and Aspell to enable the on-the-fly spell check in flyspell-mode:
  • sudo apt-get install emacs-goodies-el
Although the emacs in the Ubuntu repository is bundled with a simple TeX mode, you may want to use an advanced version: AUCTeX:
  • sudo apt-get install auctex
That's all for Ubuntu. Of course here we have assumed that you have had latex installed on your Ubuntu computer.

For Windows, things are trickier. There is no such an automatic installation repository. You have to put things together piece by piece. First of all, you have to find the compatible Emacs version with AUCTeX on Windows. The current supported Emacs version is 23.3. You can find version 24.1 on line, but it is better to install 23.3 just because we prefer AUCTeX for our LaTeX editing work.
Here is the link for Emacs 23.3:
There is actually no installation procedure for Emacs: just download it, decompress it, put the decompressed folder to your preferred location, and make a shortcut so that you can easily launch it. Fr a better mood for editing, you can find color themes here:
Just decompress the file you download and put the folder into your preferred location. In order to let Emacs find the color themes, we have to add the folder into the load list. You can do that by modifying the customized Emacs setup file: .emacs, which is located in ~/AppData/Roaming/ for Windows 7. Note that the file .emacs should be in parallel with the folder emacs.d. If there is no such a file, you should create it yourself. Add the following line in the .emacs file to help Emacs find the folder:
  • (setq load-path (append load-path (list "../../el/color-theme-6.6.0")))
We use the relative path here. The current entry of Emacs on load should be the folder bin where Emacs is launched. We create a folder el to place all installed emacs-lisp files in parallel with the folder emacs-23.3. You can choose your preferred location and modify the path being added accordingly. Then you need to link the command so that you can call color-theme by M-x:
  • (require 'color-theme)
To link all commands to all themes (a command in color-theme):

  • (color-theme-initialize)
And set up the default color theme:
  • (color-theme-robin-hood)
which is one of my favor. The theme color-theme-charcoal-black is also pretty good. Restart Emacs in order to see the effect. If the selected theme does not appear, check here for a detailed setup procedure:

Next, we are going to install Aspell and the dictionaries. Aspell is the spell-checking program which is newer than ispell. Anyway, to simply put it, if you need auto-spell checking capability when you are typing in Emacs, you need to install it. You can download it here
You need to install the program before installing each dictionary. The Aspell version 0.5.3 will not add itself to the path. You can try this command
  • aspell -a
to see if the Aspell command is in the path. If not, you have to add it to the path. Once it is in the path, you can use M-x flyspell-mode to check spelling every time when you type a word.

Last, you will need to install AUCTeX. You can find it here:
Installing AUCTeX is relatively easy: just decompress the .zip file, and copy&paste the decompressed folders to overwrite your original Emacs software. Here you have to make sure the AUCTeX version is compatible with the Emacs being overwritten. That's all for Windows!

Enjoy LaTeXing in Emacs!

Friday, September 16, 2011

Embed Fonts in PDF

Got complaints from your publisher about missing fonts? Here we compile a set of commands that you can embed and check whether your file has included everything.

The source is here
http://www.grassbook.org/neteler/highres_pdf.html
 
  • ps2pdf -dEmbedAllFonts=true main.ps main2.pdf
If you don't have the .ps file with you, try to convert the .pdf file to .ps first
  • pdf2ps main.pdf
You can check whether every font is included by
  • pdffonts main.pdf
That's all!
Please consult with the 2nd link above for the limitation of ps2pdf. In my case, ps2pdf generates high-resolution bitmapped fonts rather than the original outlined fonts. The bitmapped fonts make the resulting .pdf file pretty ugly on the screen though the print-out is fine.

Any solution for that?

Saturday, October 30, 2010

Run MPI Programs in Eclipse with 1-Click

  1. Click on the project name in Project Explorer.
  2. Right click and choose "Properties"
  3. Choose "Run/Debug Settings"
  4. Edit one of the launch configurations or create a new one.
  5. Under the tab "Main", change C/C++ Application to be "/usr/local/bin/mpirun"
  6. Go to the tab "Arguments", change the program arguments to be "-np 4 ${workspace_loc:project_name}/Debug/project_name"
Then you can press "Ctrl+F11" to run your MPI program in Eclipse.

Open MPI Installation

In Ubuntu, key in the following command:

 In order to test if your setup is correct, download this sample open MPI file
Then execute the following commands:
where the parameter -np specifies the number of cores you would like to run the test file.

Tuesday, September 7, 2010

How to Use OpenGL with Qt4 in Ubuntu 10.04

When opening an example about OpenGL in Qt Creator, compiling it and running it, you may encounter several errors regarding missing files, such as gl.h and glu.h. They are OpenGL headers. To install the corresponding libraries and headers in Ubuntu 10.04, type the following commands:
  • sudo apt-get install libgl1-mesa-dev 
  • sudo apt-get install libglu1-mesa-dev
The information about Mesa can be found here:
Although the above two commands only request for two libraries, the whole mesa system will be installed as well.

Mesa3D is one of the implementation of OpenGL API. For others, see

Tuesday, June 8, 2010

How to Use Fortran Code in C++

Declare the Fortran function first:

extern "C"{
    // double precision dot product:
    double ddot_(
            const int*        n,      // dimension
            const double*     dx,     // []vector x
            const int*        incx,   // index increment of each access of x
            const double*     dy,     // []vector y
            const int*        incy    // index increment of each access of y
    );
}

Then use it.