ConstraintTest.emam 946 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;

component ConstraintTest{

    ports out Q(-1:1)^{3,3} xOut,
          out Q yOut;

    implementation Math{
        Z n = 3;
        minimize
            Q(-1:1)^{3,3}  x;  // x(i) in [-1,1]; y in [-1, 5]
        in
            Q(-2:5) y = sum(x + x + x + x + x);
        subject to
            (-3) <= (5 * x) <= (1);     //  => [-2,1]
            x(1,1) == 0;                // first element alway == 0
            0.5 <= x(2,1);              // (2,1) >= 0      => accu = 2.5
            x(:,n) >= [1/4;1/4;1/4];    // last col > 0.75   => accu == 3.75
            for i = 1:n
              x(i, 2) == 0.01;          // 2nd col == 0.01  => accu == 0.15
            end
        end                             // (3,1) in [-1,1]  => accu == -5
                                        // min res = 6.4 - 5 = 1.4
        xOut = x;
        yOut = y;
    }
}