Skip to content
Snippets Groups Projects
Commit 6b0ad707 authored by Johannes Mey's avatar Johannes Mey
Browse files

add second ai test

parent d37daeca
No related branches found
No related tags found
No related merge requests found
......@@ -66,5 +66,14 @@ public abstract class AbstractHandwrittenTestSuite extends HandwrittenTestSuite
assertComponentRequirement(config_0i0m0,"other", config_1i0m0);
}
@Test
public void test_02_abstract() throws IOException, Parser.Exception, SolvingException {
Tuple<Root, Solution> modelAndSolution = loadAndSolve("test_02_abstract.txt", 3);
assertValidSolution(modelAndSolution);
Assignment config_0i0m0 = assertAssignment(modelAndSolution.getSecondElement(), "rq1", "config_0i0m0", "r0");
Assignment config_1i0m0 = assertAssignment(modelAndSolution.getSecondElement(), "rq1", "config_1i0m0", "r1");
assertComponentRequirement(config_0i0m0,"other", config_1i0m0);
}
}
// One request, two simple components, first requires second one
// Using metaparameter size in clauses
// Expected solution
// Request0:
// config_0i0m0 -> r0 + cpu0_0
// config_1i0m0 -> r1 + cpu0_1
container resource type ComputeNode {
resource type CPU {
property frequency [Hz]
property load [%]
}
property flops [ops/s]
}
resource r0a:ComputeNode {
resource cpu0_0:CPU {
frequency = 2930
load = 30
}
flops = 293000
}
resource r0b:ComputeNode {
resource cpu0_0:CPU {
frequency = 2930
load = 30
}
flops = 293000
}
resource r0c:ComputeNode {
resource cpu0_0:CPU {
frequency = 2930
load = 30
}
flops = 293000
}
resource r0d:ComputeNode {
resource cpu0_0:CPU {
frequency = 2930
load = 30
}
flops = 293000
}
resource r0e:ComputeNode {
resource cpu0_0:CPU {
frequency = 2930
load = 30
}
flops = 293000
}
resource r1:ComputeNode {
resource cpu1_0:CPU {
frequency = 930
load = 10
}
flops = 93000
}
meta size
property energy [J]
property quality [%]
component c0 {
using property quality
contract config_0i0m0 {
// can run only on r0
requires component other of type c1
requires resource compute_resource_0 of type ComputeNode with {
cpu_1 of type CPU
}
requiring other.quality >= 95
requiring compute_resource_0.cpu_1.frequency >= 2159
providing quality = 300
providing energy = ((0.59*(size^2))+(0.89*compute_resource_0.flops))
}
contract config_0i0m1 {
// not satisfied at all
requires component other of type c1
requires resource compute_resource_0 of type ComputeNode with {
cpu_1 of type CPU
}
requiring other.quality >= 95
requiring compute_resource_0.cpu_1.frequency >= 14159
providing quality = 90
providing energy = ((0.11*(size^2))+(0.94*compute_resource_0.flops))
}
}
component c1 {
using property quality
contract config_1i0m0 {
// can run on both, r0 and r1
requires resource compute_resource_0 of type ComputeNode with {
cpu_1 of type CPU
}
requiring compute_resource_0.cpu_1.load <= (80 * size)
// fulfills c0 requirement
providing quality = 1004
providing energy = ((0.45*(size^2))+(0.34*compute_resource_0.flops))
}
contract config_1i0m1 {
// could run on r1
requires resource compute_resource_0 of type ComputeNode with {
cpu_1 of type CPU
}
requiring compute_resource_0.cpu_1.load <= (20 * size)
// does not fulfill c0 requirement
providing quality = 3
providing energy = ((0.25*(size^2))+(0.34*compute_resource_0.flops))
}
contract config_1i0m2 {
// not satisfied at all
requires resource compute_resource_0 of type ComputeNode with {
cpu_1 of type CPU
}
requiring compute_resource_0.cpu_1.load <= (1 * size)
providing quality = 200
providing energy = ((0.02*(size^2))+(0.71*compute_resource_0.flops))
}
}
request rq1 for c0 {
meta size = 1
requiring quality >= 35
}
minimize sum(energy)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment