exmcp6.gms : External Equation - Example MCP 6

Description

```This example is based on exmcp1.gms.  It uses the same shared library.
We hope to introduce some interweaving of regular & external equations, and
some different types of matching.

Contributor: Steve Dirkse, Feb 2015.
```

Small Model of Type : GAMS

Category : GAMS Test library

Main file : exmcp6.gms

``````\$title External Equation - Example MCP 6 (EXMCP6,SEQ=679)

\$onText
This example is based on exmcp1.gms.  It uses the same shared library.
We hope to introduce some interweaving of regular & external equations, and
some different types of matching.

Contributor: Steve Dirkse, Feb 2015.
\$offText

sets
i  / i1*i14 /
i1(i)
i2(i)
;
i1(i)\$[(ord(i)/card(i)) <= 0.5] = yes;
i2(i) = not i1(i);
alias (i,j);

parameter
Q(i,i) 'Covariance Matrix'
x0(i)  'Targets'
;
Q(i,j) = power(0.5, abs(ord(i)-ord(j)) );
x0(i)  = ord(i) / card(i);
display Q, x0;

variables
x(i)
t  / fx 1 /
u  / fx 2 /
v
;
equations
dzdx(i)    'del z wrt x(i)',
dzdxXA(i)  'del z wrt x(i), eXternal version'
dzdxXB(i)  'del z wrt x(i), eXternal version'
f, g, h
;

dzdx(i)..       2 * sum {j, Q(i,j) * (x(j) - x0(j)) } =e= 0;

dzdxXA(i1(i)).. sum {j, ord(j) * x(j) } =x= ord(i);

dzdxXB(i2(i)).. sum {j, ord(j) * x(j) } =x= ord(i);

f..  1.1*t + 1.2*u + 1.3*v + sum{j,x(j)} =N= 10;
g..  2.1*t + 2.2*u + 2.3*v + sum{j,x(j)} =N= 10;
h..  3.1*t + 3.2*u + 3.3*v + sum{j,x(j)} =N= 10;

model m 'standard algebra'
/ dzdx.x, f.t, g.u, h.v /;
model libexmcp1c64 'External equations'
/ f.t, dzdxXA.x, g.u, dzdxXB.x, h.v /;

x.l(j) = 0;
x.m(j) = 0;
x.lo('i1') = 0.125;
x.fx('i2') = 0.125;
x.up('i8') = 0.5;
x.fx('i9') = 0.5;

parameter
d(j)
xL(j) /
i1  0.125
i2  0.125
i3  0.209821428571423
i4  0.28571428571429
i5  0.35714285714286
i6  0.428571428571429
i7  0.561224489795917
i8  0.5
i9  0.5
i10 0.795918367346933
i11 0.785714285714291
i12 0.857142857142859
i13 0.928571428571431
i14 1
/
xM(j) /
i1   .0870535714285743
i2   .0133928571428617
i8  -.183673469387751
i9  -.244897959183668
/;

solve libexmcp1c64 using mcp;
* solve m using mcp;

* \$exit