Initializing help system before first use

New functionality for the Mosel language

This module exposes its functionality through an extension to the mpproblem problem type. As a consequence, all routines presented here are executed in the context of the current problem.

The type nlctr and its operators

The module mmnl defines the type nlctr to represent nonlinear constraints in the Mosel Language. As shown in the following example (Section Example: using mmnl for QCQP), mmnl also defines the standard arithmetic operations that are required for working with objects of this type. By and large, these are the same operations as for linear expressions (type linctr of the Mosel language) with additionally the possibility to multiply or divide by decision variables and to use the exponential notation x^r (assuming that x is of type mpvar). Nonlinear constraints may also be defined by using overloaded versions of Mosel's arithmetic and trigonometric functions on expressions involving decision variables (see Section Procedures and functions for a complete list).

Setting initial values

An important feature in Nonlinear Programming is the possibility to set initial values for decision variables. With mmnl this is done by the procedure setinitval. Nonlinear solvers use initial values as starting point for the search. The choice of the initial values may not only have an impact on the time spent by the solver but also, depending on the problem type, on the best (locally optimal) solution found by the solver.

The definitions of initial values can be removed with clearinitvals. It is also possible to employ the solution values obtained from the immediately preceding optimization run as initial values to the next by calling the procedure copysoltoinit.

Example: using mmnl for QCQP

The following example shows how to solve a QCQP (Quadratically Constrained Quadratic Programming) problem with the Xpress-MP QCQP solver. To use this solver we need to load the module mmxprs in addition to mmnl since the module mmnl does not include any solver.

The problem we wish to solve is a classical NLP test problem (source: http://www.orfe.princeton.edu/~rvdb/ampl/nlmodels/ that determines the shape of a hanging chain by minimizing its potential energy. The objective function is linear and the problem has convex quadratic constraints.

model "catenary"
 uses "mmxprs", "mmnl"

 parameters
  N = 100                       ! Number of chainlinks
  L = 1                         ! Difference in x-coordinates of endlinks
  H = 2*L/N                     ! Length of each link
 end-parameters

 declarations
  RN = 0..N
  x: array(RN) of mpvar         ! x-coordinates of endpoints of chainlinks
  y: array(RN) of mpvar         ! y-coordinates of endpoints of chainlinks
 end-declarations

 forall(i in RN) x(i) is_free
 forall(i in RN) y(i) is_free

! Objective: minimise the potential energy
 potential_energy:= sum(j in 1..N) (y(j-1)+y(j))/2

! Bounds: positions of endpoints
! Left anchor
  x(0) = 0; y(0) = 0
! Right anchor
  x(N) = L; y(N) = 0

! Constraints: positions of chainlinks
 forall(j in 1..N)
  Link_up(j):= (x(j)-x(j-1))^2+(y(j)-y(j-1))^2 <= H^2

! Setting start values
 forall(j in RN) setinitval(x(j), j*L/N)
 forall(j in RN) setinitval(y(j), 0)

 setparam("XPRS_verbose", true)
 minimise(potential_energy)

 writeln("Solution: ", getobjval)
 forall(j in RN)
  writeln(strfmt(getsol(x(j)),10,5), " ", strfmt(getsol(y(j)),10,5))
end-model

A QCQP matrix can be exported to a text file (in MPS or LP format) by adding the following lines to your model after the problem definition:

 setparam("XPRS_loadnames", true)    ! Enable loading of names
 loadprob(potential_energy)          ! Load the problem
 writeprob("catenary.mat", "")       ! Write an MPS matrix ("l" for LP format)

Not all problems with quadratic constraints conform with the properties required by QCQP solvers. Xpress-Optimizer therefore performs a convexity check before starting the optimization. This test takes some time and if you know that your problem is convex you may disable it by setting the following parameter before starting the optimization.

 setparam("XPRS_ifcheckconvexity", false)    ! Disable convexity check

© 2001-2021 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.