Commit bfe37c9c authored by Jan Philipp Haller's avatar Jan Philipp Haller
Browse files

Previously uncommited Test resources

parent b42eddcf
Pipeline #460939 failed with stage
in 5 minutes and 47 seconds
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;
component BoundedConditionsTest{
ports out Q xOut,
out Q yOut;
implementation Math{
minimize
Q x;
in
Q y = (x*x) - 2 * x + 1;
subject to
0 <= x <= 1;
0 <= 2*x <= 1;
end
xOut = x;
yOut = y;
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;
stream BoundedConditionsTest for BoundedConditionsTest{
xOut: 0.5 +/- 0.0001;
yOut: 0.25 +/- 0.0001;
}
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;
component ColRowMinTest{
ports out Q^{2,2} xOut,
out Q yOut;
implementation Math{
minimize
Q^{2,2} x;
in
Q y = x(1, :) * x(:, 1);
subject to
x(1, 1) >= 1;
x(1, 2) >= 2;
x(2, 1) >= 1;
x(2, 2) >= 1;
end
xOut = x;
yOut = y;
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;
stream ColRowMinTest for ColRowMinTest{
xOut: [1 +/- 0.0001, 2 +/- 0.0001; 1 +/- 0.0001, 1 +/- 0.0001];
yOut: 3 +/- 0.0001;
}
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;
component ConstMatrixSumMinimizationTest{
ports out Q xOut,
out Q yOut;
implementation Math{
minimize
Q x;
in
Q y = sum([0, 0, x, 0]);
subject to
-1 <= x <= 1;
end
xOut = x;
yOut = y;
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;
stream ConstMatrixSumMinimizationTest for ConstMatrixSumMinimizationTest{
xOut: -1 +/- 0.0001;
yOut: -1 +/- 0.0001;
}
/* (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;
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;
stream ConstraintTest for ConstraintTest{
xOut: [0 +/- 0.0001, 2 +/- 0.0001, 2 +/- 0.0001; 1 +/- 0.0001, 1 +/- 0.0001, 2 +/- 0.0001];
yOut: -1.6901 +/- 0.0001;
}
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;
component ForLoopConditionsTest{
ports out Q^{3} xOut,
out Q yOut;
implementation Math{
minimize
Q^{3} x;
in
Q y = x(1) * x(1) + x(2) * x(2) + x(3) * x(3);
subject to
for i = 1:3
x(i) >= 0;
0 <= 2 * x(i) <= 2;
end
end
xOut = x;
yOut = y;
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;
stream ForLoopConditionsTest for ForLoopConditionsTest{
xOut: [0 +/- 0.0001; 0 +/- 0.0001; 0 +/- 0.0001];
yOut: 0 +/- 0.0001;
}
/* (c) https://github.com/MontiCore/monticore */
// example problem, number 71 from the Hock-Schittkowsky test suite
// W. Hock and K. Schittkowski.
// Test examples for nonlinear programming codes.
// Lecture Notes in Economics and Mathematical Systems, 187, 1981.
// doi: 10.1007/978-3-642-48320-2.
package de.rwth.monticar.optimization;
component HS71{
ports out Q^{4} xOut,
out Q yOut;
implementation Math{
minimize
Q(1:5)^{4} x;
in
Q y = x(1) * x(4) * (x(1) + x(2) + x(3)) + x(3);
subject to
x(1) * x(2) * x(3) * x(4) >= 25;
x(1) * x(1) + x(2) * x(2) + x(3) * x(3) + x(4) * x(4) == 40;
end
xOut = x;
yOut = y;
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;
stream HS71 for HS71{
xOut: [-4.5676 +/- 0.01; -1.6614 +/- 0.01; -1.7612 +/- 0.01; -3.6434 +/- 0.01];
yOut: -134.734 +/- 0.01;
}
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;
component MatrixSumMinimizationTest1{
ports out Q^{2,2} xOut,
out Q yOut;
implementation Math{
minimize
Q^{2,2} x;
in
Q y = sum(x);
subject to
x(1,1) >= 0;
x(1,2) >= 0;
x(2,1) >= 0;
x(2,2) >= -5;
end
xOut = x;
yOut = y;
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;
stream MatrixSumMinimizationTest1 for MatrixSumMinimizationTest1{
xOut: [0 +/- 0.0001, 0 +/- 0.0001; 0 +/- 0.0001, -5 +/- 0.0001];
yOut: -5 +/- 0.0001;
}
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;
component MatrixSumMinimizationTest2{
ports out Q^{2,2} xOut,
out Q yOut;
implementation Math{
minimize
Q^{2,2} x;
in
Q y = sum(x);
subject to
x >= 0;
end
xOut = x;
yOut = y;
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;
stream MatrixSumMinimizationTest2 for MatrixSumMinimizationTest2{
xOut: [0 +/- 0.0001, 0 +/- 0.0001; 0 +/- 0.0001, 0 +/- 0.0001];
yOut: 0 +/- 0.0001;
}
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;
component MatrixTransposeMinimizationTest{
ports out Q^{2} xOut,
out Q yOut;
implementation Math{
minimize
Q^{2} x;
in
Q y = [1; 2; 3; 4]' * [x(1); x(2); 0; 0];
subject to
x(1) >= 1;
x(2) >= 1;
end
xOut = x;
yOut = y;
// test
// x = [1,1]
// y = 3
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;
stream MatrixTransposeMinimizationTest for MatrixTransposeMinimizationTest{
xOut: [1 +/- 0.0001; 1 +/- 0.0001];
yOut: 3 +/- 0.0001;
}
package de.rwth.monticar.optimization;
//
component QuadraticOpt{
implementation Math{
Q^{3,3} A = [1,0,0;0,2,0;0,0,3];
Q^{3,7} B = [1,1;2,2;3,3];
Q^{3,2} C = [2,2,3;3,4,4];
Q^{3} c = [4;5;6];
Q d = 42;
Q^{2} f = [3;3];
Q^{2} h = [6;5];
minimize
Q^{3} x;
in
Q val = 0.5 * x' * A * x + c' * x + d;
subject to
//Debug restraint
B * x <= f;
C * x == h;
end
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;
component ScalarMaximizationTest{
ports out Q xOut,
out Q yOut;
implementation Math{
maximize
Q x;
in
Q z = - x * x + 42;
subject to
x >= -10;
x <= 10;
end
yOut = z;
xOut = x;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment