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

add new test 6 (for the paper) and shorten external ilp output by removing...

add new test 6 (for the paper) and shorten external ilp output by removing obviously zero-valued variables
parent 28dfaa05
No related branches found
No related tags found
No related merge requests found
abstract IlpElement ;
ILP ::= IlpObjective IlpConstraint* IlpBound* IlpVariable* <Info:IlpVarInfo> ;
TimedOutILP:ILP ::= <Reason:String> ;
// objective kind is either minimize or maximize
IlpObjective ::= <Kind:IlpObjectiveKind> IlpLeftHandSide ;
IlpObjective:IlpElement ::= <Kind:IlpObjectiveKind> IlpLeftHandSide ;
IlpConstraint ::= <Name:String> IlpLeftHandSide <ClauseComparator:ClauseComparator> <RightHandSide:double> ;
IlpConstraint:IlpElement ::= <Name:String> IlpLeftHandSide <ClauseComparator:ClauseComparator> <RightHandSide:double> ;
IlpBound ::= <Ref:IlpVariable> <Type:IlpBoundType> ;
IlpBound:IlpElement ::= <Ref:IlpVariable> <Type:IlpBoundType> ;
IlpVariable ::= <Name:String> <Request:Request> <Impl:Implementation> ;
IlpVariable:IlpElement ::= <Name:String> <Request:Request> <Impl:Implementation> ;
IlpAllResourcesVariable:IlpVariable ;
IlpMappingVariable:IlpVariable ::= <Resource:Resource> ;
// sum of terms
IlpLeftHandSide ::= IlpTerm* ;
IlpLeftHandSide:IlpElement ::= IlpTerm* ;
IlpTerm ::= <Value:double> <Ref:IlpVariable> ;
IlpTerm:IlpElement ::= <Value:double> <Ref:IlpVariable> ;
......@@ -14,8 +14,10 @@ aspect ILPPrinting {
// TODO check if "Generals" is always correct
result.append("Generals").lb();
for (IlpVariable v : getIlpVariableList()) {
if (v.isValid()) {
result.append(v.getName()).append(" ");
}
}
return result.lb().append("End").lb();
}
......@@ -30,7 +32,12 @@ aspect ILPPrinting {
syn IlpString IlpConstraint.printIlp() {
IlpString result = new IlpString();
result.append(getName()).append(": ").append(getIlpLeftHandSide().printIlp()).append(" ");
IlpString lhs = getIlpLeftHandSide().printIlp();
if (lhs == null) {
return result;
}
result.append(getName()).append(": ").append(lhs).append(" ");
switch (getClauseComparator()) {
case LT: result.append("<"); break;
case LE: result.append("<="); break;
......@@ -44,6 +51,9 @@ aspect ILPPrinting {
syn IlpString IlpBound.printIlp() {
IlpString result = new IlpString();
if (!getRef().isValid()) {
return result;
}
switch(getType()) {
case BINARY: result.append("0 <= ").append(getRef().getName()).append(" <= 1"); break;
case ZERO: result.append(getRef().getName()).append(" = 0"); break;
......@@ -53,9 +63,30 @@ aspect ILPPrinting {
return result;
}
inh ILP IlpElement.containingIlp();
eq ILP.getIlpObjective().containingIlp() = this;
eq ILP.getIlpConstraint(int i).containingIlp() = this;
eq ILP.getIlpBound(int i).containingIlp() = this;
eq ILP.getIlpVariable(int i).containingIlp() = this;
syn boolean IlpTerm.isValid() {
return getRef().isValid();
}
syn boolean IlpVariable.isValid() {
return !containingIlp().getInfo().illegal.contains(this);
}
syn IlpString IlpLeftHandSide.printIlp() {
IlpString result = new IlpString();
boolean printed = false;
for (IlpTerm t : getIlpTermList()) {
if (!t.isValid()) {
continue;
} else {
printed = true;
}
if (t.getValue() >= 0) {
result.append(" +");
} else {
......@@ -68,7 +99,11 @@ aspect ILPPrinting {
}
result.append(" ").append(t.getRef().getName());
}
if (printed) {
return result;
} else {
return null;
}
}
}
\ No newline at end of file
......@@ -8,8 +8,7 @@ import org.apache.logging.log4j.Logger;
import org.junit.*;
import org.junit.rules.ErrorCollector;
import java.io.*;
import java.net.URL;
import java.io.IOException;
import java.util.Iterator;
import static org.hamcrest.core.IsEqual.equalTo;
......@@ -18,10 +17,9 @@ import static org.junit.Assert.assertTrue;
public abstract class HandwrittenTestSuite {
private static Logger logger;
private Solver solver;
@Rule
public ErrorCollector collector = new ErrorCollector();
private Solver solver;
@BeforeClass
public static void setupClass() {
......@@ -35,6 +33,7 @@ public abstract class HandwrittenTestSuite {
/**
* Create and return the solver to use in this test suite
*
* @return a solver instance
*/
protected abstract Solver getSolver();
......@@ -80,6 +79,7 @@ public abstract class HandwrittenTestSuite {
/**
* Check if request, configuration and resource of the given assignments are equal
*
* @param actualAssignment assignment in the computed solution
* @param expectedAssignment expected assignment defined in the test case
* @return <code>true</code> if both match, <code>false</code> otherwise
......@@ -165,4 +165,11 @@ public abstract class HandwrittenTestSuite {
modelAndSolution.getSecondElement().computeObjective(), 0.01);
}
@Test
public void test_06() throws IOException, Parser.Exception, SolvingException {
Tuple<Root, Solution> modelAndSolution = loadAndSolve("test_06.txt");
assertValidSolution(modelAndSolution);
assertTrue(modelAndSolution.getSecondElement().isValid());
}
}
container resource type ComputeNode {
resource type CPU {
property frequency [Hz]
property load [%]
}
resource type RAM {
using property total
using property free
}
resource type DISK {
using property total
using property free
}
resource type NETWORK {
property latency [ms]
property throughput [kB/s]
}
}
resource resource0:ComputeNode {
resource cpu0_0:CPU { frequency = 1562.0 load = 0.0 }
resource ram0:RAM { total = 11494.0 free = 11494.0 }
resource disk0:DISK { total = 14107.0 free = 14107.0 }
resource network0:NETWORK { latency = 566.0 throughput = 70960.0
}
}
resource resource1:ComputeNode {
resource cpu1_0:CPU { frequency = 1602.0 load = 0.0 }
resource ram1:RAM { total = 10079.0 free = 10079.0 }
resource disk1:DISK { total = 5637.0 free = 5637.0 }
resource network1:NETWORK { latency = 298.0 throughput = 45704.0
}
}
resource resource2:ComputeNode {
resource cpu2_0:CPU { frequency = 976.0 load = 0.0 }
resource ram2:RAM { total = 3461.0 free = 3461.0 }
resource disk2:DISK { total = 7222.0 free = 7222.0 }
resource network2:NETWORK { latency = 22.0 throughput = 94130.0 }
}
property total [MB]
property free [MB]
meta size
property energy [J]
property quality [%]
component component_0 {
contract implementation_0i0 {
requires component the_component_0i0_0 of type component_0i0_0
requires component the_component_0i0_1 of type component_0i0_1
requires resource compute_resource_0 of type ComputeNode with { cpu_0 of type CPU ram_1 of type RAM disk_1 of type DISK
network_1 of type NETWORK }
requiring the_component_0i0_0.quality >= 100.0
requiring the_component_0i0_1.quality >= 71.0
requiring cpu_0.frequency >= 1858.0
requiring ram_1.total >= 2825.0
requiring disk_1.total >= 2707.0
requiring network_1.throughput >= 5414.0
providing quality = 6.0
providing energy = ((0.87*(size^2.0))+(0.98*cpu_0.frequency))
}
contract implementation_0i1 {
requires component the_component_0i1_0 of type component_0i1_0
requires component the_component_0i1_1 of type component_0i1_1
requires resource compute_resource_0 of type ComputeNode with { cpu_0 of type CPU ram_1 of type RAM disk_1 of type DISK
network_1 of type NETWORK }
requiring the_component_0i1_0.quality >= 18.0
requiring the_component_0i1_1.quality >= 75.0
requiring cpu_0.frequency >= 1561.0
requiring ram_1.total >= 11493.0
requiring disk_1.total >= 14106.0
requiring network_1.throughput >= 70959.0
providing quality = 45.0
providing energy = ((0.85*(size^2.0))+(0.01*cpu_0.frequency))
}
using property quality
using property energy
}
component component_0i0_0 {
contract implementation_0i0_0i0 {
requires resource compute_resource_0 of type ComputeNode with { cpu_0 of type CPU ram_1 of type RAM disk_1 of type DISK
network_1 of type NETWORK }
requiring cpu_0.frequency >= 1715.0
requiring ram_1.total >= 8262.0
requiring disk_1.total >= 8706.0
requiring network_1.throughput >= 33655.0
providing quality = 9.0
providing energy = ((0.31*(size^2.0))+(0.12*cpu_0.frequency))
}
contract implementation_0i0_0i1 {
requires resource compute_resource_0 of type ComputeNode with { cpu_0 of type CPU ram_1 of type RAM disk_1 of type DISK
network_1 of type NETWORK }
requiring cpu_0.frequency >= 2290.0
requiring ram_1.total >= 8914.0
requiring disk_1.total >= 3658.0
requiring network_1.throughput >= 61931.0
providing quality = 65.0
providing energy = ((0.98*(size^2.0))+(0.88*cpu_0.frequency))
}
using property quality
using property energy
}
component component_0i0_1 {
contract implementation_0i0_1i0 {
requires resource compute_resource_0 of type ComputeNode with { cpu_0 of type CPU ram_1 of type RAM disk_1 of type DISK
network_1 of type NETWORK }
requiring cpu_0.frequency >= 1718.0
requiring ram_1.total >= 11052.0
requiring disk_1.total >= 10535.0
requiring network_1.throughput >= 29446.0
providing quality = 68.0
providing energy = ((0.15*(size^2.0))+(0.02*cpu_0.frequency))
}
contract implementation_0i0_1i1 {
requires resource compute_resource_0 of type ComputeNode with { cpu_0 of type CPU ram_1 of type RAM disk_1 of type DISK
network_1 of type NETWORK }
requiring cpu_0.frequency >= 734.0
requiring ram_1.total >= 15946.0
requiring disk_1.total >= 7627.0
requiring network_1.throughput >= 34065.0
providing quality = 34.0
providing energy = ((0.25*(size^2.0))+(0.29*cpu_0.frequency))
}
using property quality
using property energy
}
component component_0i1_0 {
contract implementation_0i1_0i0 {
requires resource compute_resource_0 of type ComputeNode with { cpu_0 of type CPU ram_1 of type RAM disk_1 of type DISK
network_1 of type NETWORK }
requiring cpu_0.frequency >= 2877.0
requiring ram_1.total >= 885.0
requiring disk_1.total >= 3788.0
requiring network_1.throughput >= 65473.0
providing quality = 15.0
providing energy = ((0.53*(size^2.0))+(0.9*cpu_0.frequency))
}
contract implementation_0i1_0i1 {
requires resource compute_resource_0 of type ComputeNode with { cpu_0 of type CPU ram_1 of type RAM disk_1 of type DISK
network_1 of type NETWORK }
requiring cpu_0.frequency >= 1601.0
requiring ram_1.total >= 10078.0
requiring disk_1.total >= 5636.0
requiring network_1.throughput >= 45703.0
providing quality = 30.0
providing energy = ((0.31*(size^2.0))+(0.67*cpu_0.frequency))
}
using property quality
using property energy
}
component component_0i1_1 {
contract implementation_0i1_1i0 {
requires resource compute_resource_0 of type ComputeNode with { cpu_0 of type CPU ram_1 of type RAM disk_1 of type DISK
network_1 of type NETWORK }
requiring cpu_0.frequency >= 975.0
requiring ram_1.total >= 3460.0
requiring disk_1.total >= 7221.0
requiring network_1.throughput >= 94129.0
providing quality = 75.0
providing energy = ((0.67*(size^2.0))+(0.69*cpu_0.frequency))
}
contract implementation_0i1_1i1 {
requires resource compute_resource_0 of type ComputeNode with { cpu_0 of type CPU ram_1 of type RAM disk_1 of type DISK
network_1 of type NETWORK }
requiring cpu_0.frequency >= 2476.0
requiring ram_1.total >= 9865.0
requiring disk_1.total >= 11645.0
requiring network_1.throughput >= 20249.0
providing quality = 10.0
providing energy = ((0.97*(size^2.0))+(0.87*cpu_0.frequency))
}
using property quality
using property energy
}
request request0 for component_0 {
meta size = 917.0
requiring quality >= 45.0
}
minimize sum(energy)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment