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;
stream ScalarMaximizationTest for ScalarMaximizationTest{
xOut: 0 +/- 0.0001;
yOut: 42 +/- 0.0001;
}
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;
component ScalarMinimizationTest{
ports out Q xOut,
out Q yOut;
implementation Math{
minimize
Q x;
in
Q y = (x*x) - 2 * x + 1;
subject to
x >= 0;
end
xOut = x;
yOut = y;
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;
stream ScalarMinimizationTest for ScalarMinimizationTest{
xOut: 1 +/- 0.0001;
yOut: 0 +/- 0.0001;
}
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;
component ScalarMultMinTest{
ports out Q xOut,
out Q yOut;
implementation Math{
minimize
Q x;
in
Q y = (([1,1] * [2;2]) * x);
subject to
x >= 5;
end
xOut = x;
yOut = y;
// test result
// Q eps = 1E-5;
// assert(x = 5);
// assert(y = 20);
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;
stream ScalarMultMinTest for ScalarMultMinTest{
xOut: 5 +/- 0.0001;
yOut: 20 +/- 0.0001;
}
/* (c) https://github.com/MontiCore/monticore */
// transportation problem example (linear)
// see https://www.gams.com/products/simple-example/
package de.rwth.monticar.optimization;
component TransportationProblem{
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
minimize
Q^{2, 3} x;
in
Q y = sum(c .* x);
subject to
sum(x, 2) == A;
sum(x, 1) == b;
x >= 0;
end
xOut = x;
yOut = y;
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.monticar.optimization;
stream TransportationProblem for TransportationProblem{
yOut: 1763.7096763348 +/- 0.0001;
}
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