Initializing help system before first use

New functionality for the Mosel language

The type qexp and its operators

The module mmquad defines the type qexp to represent quadratic expressions in the Mosel Language. As shown in the following example, mmquad 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 in addition the possibility to multiply two decision variables or one variable with itself. For the latter, the exponential notation x^2 may be used (assuming that x is of type mpvar).

Example: using mmquad for Quadratic Programming

Quadratic expressions as defined with the help of mmquad may be used to define quadratic objective functions for Quadratic Programming (QP) or Mixed Integer Quadratic Programming (MIQP) problems. The Xpress-Optimizer module mmxprs for instance accepts expressions of type qexp as arguments for its optimization subroutines minimize and maximize, and for the procedure loadprob (see also the mmxprs Reference Manual). The following

model "Small MIQP example"
 uses "mmxprs", "mmquad"

 declarations
  x: array(1..4) of mpvar
  Obj: qexp
 end-declarations

! Define some linear constraints
 x(1) + 2*x(2) - 4*x(4) >= 0
 3*x(1) - 2*x(3) - x(4) <= 100
 x(1) + 3*x(2) + 3*x(3) - 2*x(4) >= 10
 x(1) + 3*x(2) + 3*x(3) - 2*x(4) <= 30

 2 <= x(1); x(1) <= 20
 x(2) is_integer; x(3) is_integer
 x(4) is_free

! The objective function is a quadratic expression
 Obj:= x(1) + x(1)^2 + 2*x(1)*x(2) + 2*x(2)^2 + x(4)^2

! Solve the problem and print its solution
 minimize(Obj)

 writeln("Solution: ", getobjval)
 forall(i in 1..4) writeln(getsol(x(i)))
end-model

Procedures and functions

The module mmquad overloads certain subroutines of the Mosel language, replacing an argument of type linctr by the type qexp.

exportprob
Export a quadratic problem to a file.
getsol
Get the solution value of a quadratic expression.