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.
Export a quadratic problem to a file.
|
|
Get the solution value of a quadratic expression.
|
© 2001-2025 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.