Commit 59a74e46 authored by Christoph Richter's avatar Christoph Richter
Browse files

Added additional stream tests

parent 6605aa88
......@@ -52,8 +52,8 @@ public class GeneratorCplexSolverTest {
}
@Test
public void lPOptimizationCMakeTest() throws IOException {
List<File> files = doGenerateModel("de.rwth.monticar.optimization.lPOptimizationTest");
public void transportationProblemCMakeTest() throws IOException {
List<File> files = doGenerateModel("de.rwth.monticar.optimization.transportationProblem");
}
@Test
......
......@@ -51,13 +51,13 @@ public class GeneratorEMAMOpt2CMakeTest extends BasicGenerationTest {
}
@Test
public void standardIpoptOptimizationTestCMakeTest() throws IOException {
List<File> files = doGenerateModel("de.rwth.monticar.optimization.standardIpoptOptimizationTest");
public void hs71TestCMakeTest() throws IOException {
List<File> files = doGenerateModel("de.rwth.monticar.optimization.hS71");
}
@Test
public void lPOptimizationCMakeTest() throws IOException {
List<File> files = doGenerateModel("de.rwth.monticar.optimization.lPOptimizationTest");
public void transportationProblemCMakeTest() throws IOException {
List<File> files = doGenerateModel("de.rwth.monticar.optimization.transportationProblem");
}
@Test
......
......@@ -69,7 +69,7 @@ public class GeneratorEMAMOpt2CPPTest extends BasicGenerationTest {
*/
@Test
public void testStandardIpoptOptimizationTest() throws IOException {
List<File> files = doGenerateOptimizationModel("standardIpoptOptimizationTest");
List<File> files = doGenerateOptimizationModel("hS71");
// TODO: create reference solution
// String restPath = "testMath/optimizationSolver/";
// testFilesAreEqual(files, restPath);
......@@ -81,7 +81,7 @@ public class GeneratorEMAMOpt2CPPTest extends BasicGenerationTest {
*/
@Test
public void testLPOptimizationTest() throws IOException {
List<File> files = doGenerateOptimizationModel("lPOptimizationTest");
List<File> files = doGenerateOptimizationModel("transportationProblem");
// TODO: create reference solution
// String restPath = "testMath/optimizationSolver/";
// testFilesAreEqual(files, restPath);
......
package de.rwth.monticar.optimization;
stream BoundedConditionsTest for BoundedConditionsTest{
xOut: 0.5 +/- 0.0001;
yOut: 0.25 +/- 0.0001;
}
\ No newline at end of file
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;
}
\ No newline at end of file
package de.rwth.monticar.optimization;
stream ConstMatrixSumMinimizationTest for ConstMatrixSumMinimizationTest{
xOut: -1 +/- 0.0001;
yOut: -1 +/- 0.0001;
}
\ No newline at end of file
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;
}
\ No newline at end of file
......@@ -3,9 +3,9 @@ package de.rwth.monticar.optimization;
component ExistingOptimizationVariableTest{
ports out Q xOut1,
out Q aOut2,
out Q^{3,3} aOut2,
out Q bOut2,
out Q aOut3,
out Q^{3,3} aOut3,
out Q cOut3;
......
package de.rwth.monticar.optimization;
stream ExistingOptimizationVariableTest for ExistingOptimizationVariableTest{
xOut1: -1 +/- 0.0001;
aOut2: [-10 +/- 0.0001, -, -; -, -10 +/- 0.0001, -; -, -, -10 +/- 0.0001];
bOut2: -1000 +/- 0.0001;
aOut3: [-20 +/- 0.0001, -, -; -, -20 +/- 0.0001, -; -, -, -20 +/- 0.0001];
cOut2: -57 +/- 0.0001;
}
\ No newline at end of file
......@@ -2,7 +2,7 @@ package de.rwth.monticar.optimization;
component ForLoopConditionsTest{
ports out Q xOut,
ports out Q^{3} xOut,
out Q yOut;
implementation Math{
......
package de.rwth.monticar.optimization;
stream ForLoopConditionsTest for ForLoopConditionsTest{
xOut: [0 +/- 0.0001; 0 +/- 0.0001; 0 +/- 0.0001];
yOut: 0 +/- 0.0001;
}
\ No newline at end of file
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;
}
\ No newline at end of file
// transportation problem example (linear)
// see https://www.gams.com/products/simple-example/
package de.rwth.monticar.optimization;
component LPOptimizationTest{
ports out Q^{3, 2} xOut,
out Q yOut;
implementation Math
{
// define problem
Q m = 2;
Q n = 3;
// define A, b
Q^{2, 1} A = [350; 600];
Q^{3, 1} b = [325; 300; 275];
// cost matrix
Q ^{m, n} c = [2.5, 1.7, 1.8; 2.5, 1.8, 1.4];
// minimization problem
Q y = minimize(Q^{2, 3} x)
sum(c .* x);
subject to
sum(x, 2) == A;
sum(x, 1) == b;
x >= 0;
end
xOut = x;
yOut = y;
}
}
\ No newline at end of file
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;
}
\ No newline at end of file
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;
}
\ No newline at end of file
......@@ -9,8 +9,8 @@ component MatrixTransposeMinimizationTest{
Q y = minimize(Q^{2} x)
[1; 2; 3; 4]' * [x(1); x(2); 0; 0];
subject to
x(1) >= 0;
x(2) >= 0;
x(1) >= 1;
x(2) >= 1;
end
xOut = x;
......
package de.rwth.monticar.optimization;
stream MatrixTransposeMinimizationTest for MatrixTransposeMinimizationTest{
xOut: [1 +/- 0.0001; 1 +/- 0.0001];
yOut: 3 +/- 0.0001;
}
\ No newline at end of file
package de.rwth.monticar.optimization;
stream ScalarMultMinTest for ScalarMultMinTest{
xOut: 5 +/- 0.0001;
yOut: 20 +/- 0.0001;
}
\ No newline at end of file
// 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 StandardIpoptOptimizationTest{
ports out Q^{4} xOut,
out Q yOut;
implementation Math{
Q y = minimize(Q^{4} x)
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;
1 <= x;
x <= 5;
end
xOut = x;
yOut = y;
}
}
\ No newline at end of file
package de.rwth.monticar.optimization;
stream TransportationProblem for TransportationProblem{
yOut: 1763.7096763348 +/- 0.0001;
}
\ No newline at end of file
Supports Markdown
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