Version 7 (modified by frankeye, 8 years ago) (diff)

--

# Hints and Tricks

On this page, Ipopt users can share their experience with the Ipopt algorithm and software. For example, if you noticed that a particular choice of algorithmic parameters was able to overcome an undesired behavior that you ran into, other users might be very happy to learn about this!

## Scaling of the optimization problem

When you formulate your optimizaton problem (either in AMPL or as programming code), you should try to make it "well-scaled" to make it easier for Ipopt (or any nonlinear optimization package) to solve it. For this, you should try to make the "typical" values of the non-zero first partial derivatives of the objective and constraint functions to be on the order of, say, 0.01 to 100. For example, if you multiply a problem function by a number K, then the first partial derivatives for this function are also multiplied by K. On the other hand, if you replace a variable xi by a number K, then the partial derivatives with respect to this variable are divided by K.

By default, Ipopt performs some very simple scaling of the problem functions, by looking at the gradients of each function evaluated at the user-provided starting point. If any entry for a given function is larger than 100, then this function is scaled down to make the largest entry in the gradient 100 (see the Ipopt options nlp_scaling_method and nlp_scaling_max_gradient). Of course, if some of the gradient elements are huge and some are very small, the variables corresponding to the small entries are almost ignored. If you set the print_level to at least 5, then you can see by how much the functions are scaled. For sufficiently large print_level you can also see the individual scaling factors for each constraint, and also the values of the first derivatives, if you want to find out which derivatives are very large or very small.

## Increasing robustness

If you have trouble finding a solution with Ipopt, it might sometimes help to increase to accuracy of the computation of the search directions, which is done by solving a linear system. There are a number of ways to do this: First, you can tell Ipopt to scale the linear system before it is sent to the linear solver; this assumes that you compiled your code with the Harwell routine MC19. By default this option is only activated if it seems necessary (see linear_system_scaling and linear_scaling_on_demand). Also, you can increase the pivot tolerance of the linear solver (if that is supported by the linear solver), for example, by increasing the value of ma27_pivtol if you are using the linear solver MA27.

Other options you might want to play with if you have trouble solving a problem are: mu_strategy, obj_scaling_factor, mu_init, bound_relax_factor...

## Compiling under Windows using MinGW/MSYS

Note: This is not to be confused with compiling within Windows under the Cygwin environment.

1. The IPOPT Documentation provides the general framework to follow. However, there are a few changes in procedure as follows.
1. (At the toplevel directory) edit the configure file. First search/find the text string "Try a symlink, then", then comment-out the following lines as shown (by placing # at beginning of lines).
```  # Try a symlink, then a hard link, then a copy.

#  ln -s \$ac_rel_source \$ac_dest 2>/dev/null ||
#    ln \$srcdir/\$ac_source \$ac_dest 2>/dev/null ||
#    cp -p \$srcdir/\$ac_source \$ac_dest ||
#    { { echo "\$as_me:\$LINENO: error: cannot link or copy \$srcdir/\$ac_source to \$ac_dest" >&5
#echo "\$as_me: error: cannot link or copy \$srcdir/\$ac_source to \$ac_dest" >&2;}
#   { (exit 1); exit 1; }; }
done
```
1. Open an MSYS console (StartMenu?>Programs>MSYS), and within it, execute the configure script, per the IPOPT documentation instructions, e.g.: ./configure --with-blas=BUILD --with-lapack=BUILD --with-hsl=BUILD --with-asl=BUILD
1. Copy (\$topdir)/lapack/lapack/src into (\$topdir)/lapack/. but don't take along makefile
1. In (\$topdir)/Extern/ASL/ mkdir ASLsolvers copy solvers/* into duplicate ASLsolvers/*
1. From topdir, run make
1. edit makefile in (\$topdir)/Extern/ASL: replace the line

ASLMAKEFLAGS = -j 1 CFLAGS=" -O3 -pipe "

with

ASLMAKEFLAGS = -j 1 CFLAGS=" -O3 -pipe -DNON_STDIO -DNO_RUSAGE -funroll-loops "

1. In In (\$topdir)/Extern/ASL/, run make
1. From topdir, rerun make
1. From topdir, run make install