FICO Xpress Optimization Examples Repository
 FICO Optimization Community FICO Xpress Optimization Home

Basic QCQP solver interface for Xpress Optimizer

Description
Language extensions provided by this module:
• type: extension of mpproblem
• subroutines: procedures and functions
• implementation of a callback function
• services: reset, unload, accessing and enumerating parameters, module dependency
• parameters: real, integer, boolean
• constants: integer

 myqxprs.zip [download all files]

Source Files
 myqxprs.c [download]

Data Files
 Test model catenary_mx.mos [download]

catenary_mx.mos

```(!*********************************************************************
Mosel NI examples
=================

file catenary_mx.mos
````````````````````
QCQP problem (linear objective, convex quadratic constraints)
Based on AMPL model catenary.mod
(Source: http://www.orfe.princeton.edu/~rvdb/ampl/nlmodels/ )

This model finds the shape of a hanging chain by
minimizing its potential energy.

- Using the myqxprs module -

(c) 2008 Fair Issac Corporation
author: S. Heipcke, May 2008, rev. Apr. 2018
*********************************************************************!)

model "catenary - myqxprs version"
uses "myqxprs"

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
PotentialEnergy: linctr       ! Objective function
Link: array(range) of nlctr   ! Constraints
end-declarations

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

! Objective: minimise the potential energy
PotentialEnergy:= 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(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)

! Configuration of the solver
setparam("myxp_verbose", true)

! Solve the problem
minimise(PotentialEnergy)

! Solution reporting
if getprobstat<>MYXP_OPT and getprobstat<>MYXP_UNF then
writeln("No solution available. Solver status: ", getprobstat)
else
writeln("Solution: ", getobjval)
forall(j in RN)
writeln(strfmt(getsol(x(j)),10,5), " ", strfmt(getsol(y(j)),10,5))
end-if

end-model

```