C++: We Optimize Really Huge Problems (WORHP)

class ppnf::worhp : public not_population_based

WORHP - (We Optimize Really Huge Problems)

_images/worhp.png

This class is a user-defined algorithm (UDA) that contains a plugin to the WORHP (We Optimize Really Huge Problems) solver (https://worhp.de/), a software package for large-scale nonlinear optimization. WORHP is a powerful solver that is able to handle robustly and efficiently constrained nonlinear opimization problems also at high dimensionalities. The wrapper was developed around the version 1.12 of WORHP and the Full Feature Interface (FFI) using the Unified Solver Interface and the Reverse Communication paradigm (see worhp user manual).

Note

The WORHP library is only available acquiring a licence. You can consult the web pages at (https://worhp.de/) for further information. In thse web pages you will be able to download the correct library for your architecture and obtain a license file. The WORHP user manual is also available, where the user can see what options can be set and their intended use. You will be able to specify the location of the downloaded library when constructing this UDA.

Worhp is designed to efficiently solve small- to large-scale constrained optimisation problems (single objective), where the objective function and the constraints are sufficiently smooth, and may be linear, quadratic or nonlinear. It is designed to find locally optimal points of optimisation problems, which may be globally optimal, depending on the problem structure, the initial guess and other factors. Worhp combines a Sequential Quadratic Programming (SQP) method on the general nonlinear level with a primal-dual Interior Point (IP) method on the quadratic subproblem level, to generate a sequence of search directions, which are subject to line search using the Augmented Lagrangian or L1 merit function.

Worhp needs first and second order derivatives, which can be supplied by the user, or approximated by finite differences or quasi-Newton methods by WORHP.

In order to support pagmo’s population-based optimisation model, worhp::evolve() will select a single individual from the input ppnf::population to be optimised. If the optimisation produces an improved individual (as established by ppnf::compare_fc()), the optimised individual will be inserted back into the population. The selection and replacement strategies can be configured via set_selection(const std::string &), set_selection(population::size_type), set_replacement(const std::string &) and set_replacement(population::size_type).

Note

This plugin for the WORHP was developed around version 1.12.1 of the worhp library and will not work with any other version.

Warning

A moved-from ppnf::worhp is destructible and assignable. Any other operation will result in undefined behaviour.

Public Types

using log_line_type = std::tuple<unsigned long, double, pagmo::vector_double::size_type, double, bool>

Single data line for the algorithm’s log.

A log data line is a tuple consisting of:

  • the number of objective function evaluations made so far,

  • the objective function value for the current decision vector,

  • the number of constraints violated by the current decision vector,

  • the constraints violation norm for the current decision vector,

  • a boolean flag signalling the feasibility of the current decision vector.

using log_type = std::vector<log_line_type>

Log type.

The algorithm log is a collection of worhp::log_line_type data lines, stored in chronological order during the optimisation if the verbosity of the algorithm is set to a nonzero value (see worhp::set_verbosity()).

Public Functions

worhp(bool screen_output = false, std::string worhp_library = "/usr/local/lib/libworhp.so")

Constructor.

The algorithm WORHP can be constructed in two different ways. According to the user choice, only one among the original WORHP screen output and the pagmo logging system will be activated.

Parameters
  • screen_output: when true will activate the screen output from the WORHP library, otherwise will let pagmo regulate logs and screen_output via its pagmo::algorithm::set_verbosity mechanism.

  • worhp_library: The filename, including the absolute path, of the worhp library.

pagmo::population evolve(pagmo::population pop) const

Evolve population.

This method will select an individual from pop, optimise it using the WORHP USI interface, replace an individual in pop with the optimised individual, and finally return pop. The individual selection and replacement criteria can be set via set_selection(const std::string &), set_selection(population::size_type), set_replacement(const std::string &) and set_replacement(population::size_type). The WORHP solver will then run until one of the stopping criteria is satisfied, and the return status of the WORHP solver will be recorded (it can be fetched with get_last_opt_result()).

Warning

All options passed to the WORHP interface are determined first by the xml parameter file, or (if not found) by the default options. Then FGtogether is set to true (for constrained problems) and UserDF, UserDG , UserHM to the values detected by the pagmo::has_gradient, pagmo::has_hessians methods. TolFeas is then set to be the minimum of prob.get_c_tol() if not 0. All the other options, contained in the data members m_integer_opts, m_numeric_opts and m_bool_opts are set after and thus overwrite the above rules.

Return

the optimised population.

Parameters
  • pop: the population to be optimised.

Exceptions
  • std::invalid_argument: if a version mismatch is found between the declared library and 1.12

  • std::invalid_argument: in the following cases:

    • the population’s problem is multi-objective or stochastic

  • unspecified: any exception thrown by the public interface of pagmo::problem or pagmo::not_population_based.

void set_verbosity(unsigned n)

Set verbosity.

This method will set the algorithm’s verbosity. If n is zero, no output is produced during the optimisation by pagmo and no logging is performed. If n is nonzero, then every n objective function evaluations the status of the optimisation will be both printed to screen and recorded internally. See worhp::log_line_type and worhp::log_type for information on the logging format. The internal log can be fetched via get_log().

Example (verbosity 1):

objevals:        objval:      violated:    viol. norm:
        1        48.9451              1        1.25272 i
        2         30.153              1       0.716591 i
        3        26.2884              1        1.04269 i
        4        14.6958              2        7.80753 i
        5        14.7742              2        5.41342 i
        6         17.093              1      0.0905025 i
        7        17.1772              1      0.0158448 i
        8        17.0254              2      0.0261289 i
        9        17.0162              2     0.00435195 i
       10        17.0142              2    0.000188461 i
       11         17.014              1    1.90997e-07 i
       12         17.014              0              0
The i at the end of some rows indicates that the decision vector is infeasible. Feasibility is checked against the problem’s tolerance.
Parameters
  • n: the desired verbosity level.

By default, the verbosity level is zero.

Warning

The number of constraints violated, the constraints violation norm and the feasibility flag stored in the log are all determined via the facilities and the tolerances specified within pagmo::problem. That is, they might not necessarily be consistent with WORHP’s notion of feasibility.

Note

WORHP supports its own logging format and protocol, including the ability to print to screen and write to file. WORHP’s screen logging is disabled by default. On-screen logging can be enabled constructing the object ppnf::WORHP passing true as argument. In this case verbosity will not be allowed to be set.

const log_type &get_log() const

Get the optimisation log.

See worhp::log_type for a description of the optimisation log. Logging is turned on/off via set_verbosity().

Return

a const reference to the log.

unsigned int get_verbosity() const

Gets the verbosity level.

Return

the verbosity level

std::string get_name() const

Algorithm name.

One of the optional methods of any user-defined algorithm (UDA).

Return

a string containing the algorithm name

std::string get_extra_info() const

Get extra information about the algorithm.

Return

a human-readable string containing useful information about the algorithm’s properties (e.g., the WORHP user-set options, the selection/replacement policies, etc.), the worhp library path

void set_integer_option(const std::string &name, int value)

Set integer option.

This method will set the optimisation integer option name to value. The optimisation options are passed to the WORHP API when calling evolve().

Parameters
  • name: of the option.

  • value: of the option.

void set_integer_options(const std::map<std::string, int> &m)

Set integer options.

This method will set the optimisation integer options contained in m. It is equivalent to calling set_integer_option() passing all the name-value pairs in m as arguments.

Parameters
  • m: the name-value map that will be used to set the options.

std::map<std::string, int> get_integer_options() const

Get integer options.

Return

the name-value map of optimisation integer options.

void set_numeric_option(const std::string &name, double value)

Set numeric option.

This method will set the optimisation numeric option name to value. The optimisation options are passed to the WORHP API when calling evolve().

Parameters
  • name: of the option.

  • value: of the option.

void set_numeric_options(const std::map<std::string, double> &m)

Set numeric options.

This method will set the optimisation numeric options contained in m. It is equivalent to calling set_numeric_option() passing all the name-value pairs in m as arguments.

Parameters
  • m: the name-value map that will be used to set the options.

std::map<std::string, double> get_numeric_options() const

Get numeric options.

Return

the name-value map of optimisation numeric options.

void set_bool_option(const std::string &name, bool value)

Set bool option.

This method will set the optimisation integer option name to value. The optimisation options are passed to the WORHP API when calling evolve().

Parameters
  • name: of the option.

  • value: of the option.

void set_bool_options(const std::map<std::string, bool> &m)

Set bool options.

This method will set the optimisation integer options contained in m. It is equivalent to calling set_bool_option() passing all the name-value pairs in m as arguments.

Parameters
  • m: the name-value map that will be used to set the options.

std::map<std::string, bool> get_bool_options() const

Get bool options.

Return

the name-value map of optimisation integer options.

void reset_integer_options()

Clear all integer options.

void reset_numeric_options()

Clear all numeric options.

void reset_bool_options()

Clear all numeric options.

std::string get_last_opt_result() const

Get the result of the last optimisation.

Return

the result of the last call to WORHP. You can check The WORHP user manual for the meaning of the various entries.

template<typename Archive>
void serialize(Archive &ar, unsigned)

Object serialization.

This method will save/load this into the archive ar.

Parameters
  • ar: target archive.

Exceptions
  • unspecified: any exception thrown by the serialization of the UDA and of primitive types.