Py: We Optimize Really Huge Problems (WORHP)

class pygmo_plugins_nonfree.worhp(screen_output = false, library = '\usr\local\lib\libworhp.so')

WORHP - (We Optimize Really Huge Problems)

This class is a user-defined algorithm (UDA) that contains a plugin to the WORHP (We Optimize Really Huge Problems) solver, 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.14 of WORHP and the Full Feature Interface (FFI) using the Unified Solver Interface and the Reverse Communication paradigm (see worhp user manual).

Intended use::
>>> import pygmo as pg
>>> import pygmo_plugins_nonfree as ppnf
>>> uda = ppnf.worhp(screen_output = False, library = "/usr/local/lib/libworhp.so")
>>> algo = pg.algorithm(uda)

Note

The WORHP library is only available buying a licence. You can consult the web pages at (https://worhp.de/) for further information. There you will be able to download the correct library for your architecture and obtain a license file. 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, 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.

In order to support pagmo’s population-based optimisation model, worhp selects a single individual from the input population to be optimised. If the optimisation produces an improved individual (as established by pagmo comparison criteria), the optimised individual will be inserted back into the population.

Parameters
  • screen_output (bool) – when True will activate the original screen output from WORHP and deactivate the logging system based on set_verbosity().

  • library (str) – the worhp library filename in your system (absolute path included)

Raises

ArgumentError – for any conversion problems between the python types and the c++ signature

Note

This plugin for the WORHP was developed around version 1.12.1 of the worhp library. It will not work with versions having a different amajor or minor version.

Warning

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

See also the docs of the C++ class worhp::worhp.

get_log()
Returns

the optimisation log containing the values objevals, objval, violated, viol. norm, feas., where:

  • objevals (int), the number of objective function evaluations made so far

  • objval (float), the objective function value for the current decision vector

  • violated (int), the number of constraints violated by the current decision vector

  • viol. norm (float), the constraints violation norm for the current decision vector

  • feas. (bool), a boolean flag signalling the feasibility of the current decision vector (as determined by pagmo)

Return type

list

Raises
  • unspecified – any exception thrown by failures at the intersection between C++ and Python (e.g.,

  • type conversion errors, mismatched function signatures, etc.)

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 pygmo.problem. That is, they might not necessarily be consistent with worhp’s notion of feasibility.

Note

WORHP supports its own screen output. It can be activated upon construction by setting the relative kwarg to True

Examples

>>> from pygmo import *
>>> from pygmo_plugins_nonfree import worhp
>>> algo = algorithm(worhp(screen_output = False, library = "/usr/local/lib/libworhp.so"))
>>> algo.set_verbosity(1)
>>> prob = problem(cec2006(prob_id = 1))
>>> prob.c_tol = [1e-6]*9
>>> pop = population(prob, 1)
>>> pop = algo.evolve(pop) 
 Error (Read_XML_File): Could not open file param.xml.
 WorhpFromXML: Could not open parameter file, using default values.
WORHP version is (library): 1.14.0
WORHP version is (plugin headers): 1.14.0

WORHP plugin for pagmo/pygmo:
    The gradient sparsity is assumed dense: 130 components detected.
    The gradient is computed numerically by WORHP.
    The hessian of the lagrangian sparsity has: 91 components.
    The hessian of the lagrangian is computed numerically by WORHP.

The following parameters have been set by pagmo to values other than their xml provided ones (or their default ones):
    par.FGtogether: true
    par.UserDF: false
    par.UserDG: false
    par.UserHM: false
    par.TolFeas: false
    par.AcceptTolFeas: false

objevals:        objval:      violated:    viol. norm:
       13       -57.4531              9        69.6602 i
       26       -57.4525              9        69.6591 i
       39       -57.4531              9        69.6602 i
       52       -57.4525              9        69.6591 i
       65       -43.2785              9        45.1295 i
       78       -43.2783              9        45.1293 i
       91       -22.0316              6        10.7489 i
      104       -22.0315              6        10.7488 i
      117        -15.149              6       0.208663 i
      130       -15.1489              6       0.208673 i
      143       -15.0001              6     5.0492e-05 i
      156            -15              6    6.80956e-05 i
      169            -15              0              0
      182            -15              1    8.99984e-06 i

Warning (ParameterReset): WORHP has reset 2 invalid parameters to default values.

 Final values after iteration 5:
 Final objective value ............. -1.4999999999E+01
 Final constraint violation ........  0.0000000000E+00
 Final complementarity .............  0.0000000000E+00 (0.0000000000E+00)
 Final KKT conditions ..............  1.2589097553E-11 (4.3087122652E-06)
 Successful termination: Optimal Solution Found.


>>> uda = algo.extract(worhp)
>>> uda.get_log() 
[(1, -214.45104382308432, 9, 294.79616317933454, False), (11, -214.45108700799688, ...
property replacement

Individual replacement policy.

This attribute represents the policy that is used in the evolve() method to select the individual that will be replaced by the optimised individual. The attribute can be either a string or an integral.

If the attribute is a string, it must be one of "best", "worst" and "random":

  • "best" will select the best individual in the population,

  • "worst" will select the worst individual in the population,

  • "random" will randomly choose one individual in the population.

set_random_sr_seed() can be used to seed the random number generator used by the "random" policy.

If the attribute is an integer, it represents the index (in the population) of the individual that will be replaced by the optimised individual.

Returns

the individual replacement policy or index

Return type

int or str

Raises
  • OverflowError – if the attribute is set to an integer which is negative or too large

  • ValueError – if the attribute is set to an invalid string

  • TypeError – if the attribute is set to a value of an invalid type

  • unspecified – any exception thrown by failures at the intersection between C++ and Python (e.g., type conversion errors, mismatched function signatures, etc.)

property selection

Individual selection policy.

This attribute represents the policy that is used in the evolve() method to select the individual that will be optimised. The attribute can be either a string or an integral.

If the attribute is a string, it must be one of "best", "worst" and "random":

  • "best" will select the best individual in the population,

  • "worst" will select the worst individual in the population,

  • "random" will randomly choose one individual in the population.

set_random_sr_seed() can be used to seed the random number generator used by the "random" policy.

If the attribute is an integer, it represents the index (in the population) of the individual that is selected for optimisation.

Returns

the individual selection policy or index

Return type

int or str

Raises
  • OverflowError – if the attribute is set to an integer which is negative or too large

  • ValueError – if the attribute is set to an invalid string

  • TypeError – if the attribute is set to a value of an invalid type

  • unspecified – any exception thrown by failures at the intersection between C++ and Python (e.g., type conversion errors, mismatched function signatures, etc.)

set_bool_option(name, value)

Set bool option.

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

Parameters
  • name (string) – name of the option

  • value (bool) – value of the option

Note

In case of invalid option name this function will not throw, but a subsequent call to evolve() will raise a ValueError.

set_integer_option(name, value)

Set integer option.

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

Parameters
  • name (string) – name of the option

  • value (int) – value of the option

Note

In case of invalid option name this function will not throw, but a subsequent call to evolve() will raise a ValueError.

set_numeric_option(name, value)

Set numeric option.

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

Parameters
  • name (string) – name of the option

  • value (float) – value of the option

Note

In case of invalid option name this function will not throw, but a subsequent call to evolve() will raise a ValueError.

set_random_sr_seed(seed)

Set the seed for the "random" selection/replacement policies.

Parameters

seed (int) – the value that will be used to seed the random number generator used by the "random" election/replacement policies (see selection and replacement)

Raises
  • OverflowError – if the attribute is set to an integer which is negative or too large

  • unspecified – any exception thrown by failures at the intersection between C++ and Python (e.g., type conversion errors, mismatched function signatures, etc.)