Commit 319c43f3 authored by René Schöne's avatar René Schöne
Browse files

Tested latest fixes for parsing and property resolving.

parent 17a115d4
......@@ -6,8 +6,12 @@ import de.tudresden.inf.st.mquat.generator.*;
import de.tudresden.inf.st.mquat.jastadd.model.*;
import de.tudresden.inf.st.mquat.jastadd.parser.MquatParser;
import de.tudresden.inf.st.mquat.jastadd.scanner.MquatScanner;
import de.tudresden.inf.st.mquat.serializer.ASTNodeSerializer;
import de.tudresden.inf.st.mquat.serializer.JsonSerializer;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.config.Configurator;
import java.io.*;
import java.net.URL;
......@@ -139,13 +143,21 @@ public class Main {
public static void main(String[] args) throws Exception {
Logger logger = LogManager.getLogger(Main.class);
logger.info("Starting base.Main");
// String fileName = args.length > 0 ? args[0] : "model-handmade.txt";
// Optional<Root> parsedModel = loadModel(fileName);
String fileName = args.length > 0 ? args[0] : "model-handmade.txt";
// Configurator.setRootLevel(Level.TRACE);
Optional<Root> parsedModel = loadModel(fileName);
parsedModel.ifPresent(model -> JsonSerializer.write(model, "model-serialized.txt"));
// Root model = generateNewModel(new MquatWriteSettings(" "), false);
// JsonSerializer.write(model, "model-serialized.txt");
// checkParsedModel(parsedModel.orElseThrow(RuntimeException::new), getAbsoluteFileForLoading(fileName), settings);
ExtensibleScenarioGenerator esg = new ExtensibleScenarioGenerator();
esg.setDescription(SCENARIO_DESCRIPTION);
esg.setSerializer(new LoggingSerializer());
esg.generateModel();
// ExtensibleScenarioGenerator esg = new ExtensibleScenarioGenerator();
// esg.setDescription(SCENARIO_DESCRIPTION);
// esg.setSerializer(new LoggingSerializer());
// esg.generateModel();
}
}
......@@ -5,6 +5,8 @@ import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import de.tudresden.inf.st.mquat.jastadd.model.ASTNode;
import de.tudresden.inf.st.mquat.jastadd.model.ASTNodeAnnotation;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
......@@ -12,6 +14,8 @@ import java.lang.reflect.Method;
public class ASTNodeSerializer extends StdSerializer<ASTNode> {
Logger logger = LogManager.getLogger(ASTNodeSerializer.class);
public ASTNodeSerializer() {
this(null);
}
......@@ -27,12 +31,16 @@ public class ASTNodeSerializer extends StdSerializer<ASTNode> {
jgen.writeStartObject();
jgen.writeStringField("k", "NT");
jgen.writeStringField("t", value.getClass().getSimpleName());
String className = value.getClass().getSimpleName();
jgen.writeStringField("t", className);
logger.trace("class name: {}", className);
jgen.writeObjectFieldStart("c");
for (Method m : value.getClass().getMethods()) {
try {
if (m.getAnnotation(ASTNodeAnnotation.Child.class) != null) {
jgen.writeFieldName(m.getAnnotation(ASTNodeAnnotation.Child.class).name());
String name = m.getAnnotation(ASTNodeAnnotation.Child.class).name();
logger.trace("child name: {}", name);
jgen.writeFieldName(name);
provider.defaultSerializeValue(m.invoke(value), jgen);
} else if (m.getAnnotation(ASTNodeAnnotation.Token.class) != null) {
jgen.writeFieldName(m.getAnnotation(ASTNodeAnnotation.Token.class).name());
......@@ -40,7 +48,9 @@ public class ASTNodeSerializer extends StdSerializer<ASTNode> {
jgen.writeStringField("k", m.getReturnType().isEnum() ? "enum" : "t");
jgen.writeStringField("t", m.getReturnType().getName());
jgen.writeFieldName("v");
provider.defaultSerializeValue(m.invoke(value), jgen);
Object terminalValue = m.invoke(value);
logger.trace("terminal: {}", terminalValue);
provider.defaultSerializeValue(terminalValue, jgen);
jgen.writeEndObject();
} else if (m.getAnnotation(ASTNodeAnnotation.ListChild.class) != null) {
jgen.writeFieldName(m.getAnnotation(ASTNodeAnnotation.ListChild.class).name());
......
container resource type ComputeNode {
resource type CPU {
static property frequency [Hz]
runtime property load [%]
}
resource type RAM {
using property total
using property free
}
resource type DISK {
using property total
using property free
}
resource type NETWORK {
static property latency [ms]
static property throughput [kB/s]
}
derived property flops [ops/s]
runtime property STATE []
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 resource4:ComputeNode {
resource cpu4_0:CPU {
frequency = 1284.0
load = 0.0
}
resource ram4:RAM {
total = 539.0
free = 539.0
}
resource disk4:DISK {
total = 8426.0
free = 8426.0
}
resource network4:NETWORK {
latency = 244.0
throughput = 8395.0
}
}
resource resource2:ComputeNode {
resource cpu2_0:CPU {
frequency = 2039.0
load = 0.0
}
resource ram2:RAM {
total = 8942.0
free = 8942.0
}
resource disk2:DISK {
total = 11053.0
free = 11053.0
}
resource network2:NETWORK {
latency = 663.0
throughput = 85379.0
}
}
resource resource3:ComputeNode {
resource cpu3_0:CPU {
frequency = 1749.0
load = 0.0
}
resource ram3:RAM {
total = 12552.0
free = 12552.0
}
resource disk3:DISK {
total = 9171.0
free = 9171.0
}
resource network3:NETWORK {
latency = 118.0
throughput = 57675.0
}
}
resource resource0:ComputeNode {
resource cpu0_0:CPU {
frequency = 2930
load = 0
}
resource cpu0_1:CPU {
frequency = 2930
load = 0
}
resource cpu0_2:CPU {
frequency = 2930
load = 0
}
resource cpu0_3:CPU {
frequency = 2930
load = 0
}
resource ram0:RAM {
total = 10596
free = 12709
}
resource disk0:DISK {
total = 3421
free = 6238
}
resource network0:NETWORK {
latency = 762
throughput = 22003
}
resource cpu0_0:CPU {
frequency = 1567.0
load = 0.0
}
resource ram0:RAM {
total = 8602.0
free = 8602.0
}
resource disk0:DISK {
total = 15771.0
free = 15771.0
}
resource network0:NETWORK {
latency = 518.0
throughput = 80226.0
}
}
resource resource1:ComputeNode {
resource cpu1_0:CPU {
frequency = 1716.0
load = 0.0
}
resource ram1:RAM {
total = 8263.0
free = 8263.0
}
resource disk1:DISK {
total = 8707.0
free = 8707.0
}
resource network1:NETWORK {
latency = 73.0
throughput = 33656.0
}
}
property total [MB]
property free [MB]
meta size
static property total [MB]
runtime property free [MB]
runtime property energy [J]
runtime property quality [%]
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
requires resource cpu_0 of type CPU
requires resource cpu_1 of type CPU
requires resource cpu_2 of type CPU
requires resource cpu_3 of type CPU
requires resource ram_1 of type RAM
requires resource disk_1 of type DISK
requires resource network_1 of type NETWORK
requiring the_component_0i0_0.quality >= 95
requiring the_component_0i0_1.quality >= 86
mode configuration_0i0m0 {
requiring cpu_0.frequency >= 2159
requiring cpu_1.frequency >= 2159
requiring cpu_2.frequency >= 2159
requiring cpu_3.frequency >= 2159
requiring ram_1.total >= 11005
requiring disk_1.total >= 13482
requiring network_1.throughput >= 76460
providing compute_resource_0.flops = (((cpu_0.frequency+cpu_1.frequency)+cpu_2.frequency)+cpu_3.frequency)
providing quality = 90
providing energy = ((0.59*(size^2))+(0.89*compute_resource_0.flops))
}
mode configuration_0i0m1 {
requiring cpu_0.frequency >= 2929
requiring cpu_1.frequency >= 2929
requiring cpu_2.frequency >= 2929
requiring cpu_3.frequency >= 2929
requiring ram_1.total >= 10595
requiring disk_1.total >= 3420
requiring network_1.throughput >= 22002
providing compute_resource_0.flops = (((cpu_0.frequency+cpu_1.frequency)+cpu_2.frequency)+cpu_3.frequency)
providing quality = 35
providing energy = ((0.11*(size^2))+(0.94*compute_resource_0.flops))
}
}
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
requires resource cpu_0 of type CPU
requires resource cpu_1 of type CPU
requires resource cpu_2 of type CPU
requires resource cpu_3 of type CPU
requires resource ram_1 of type RAM
requires resource disk_1 of type DISK
requires resource network_1 of type NETWORK
requiring the_component_0i1_0.quality >= 72
requiring the_component_0i1_1.quality >= 30
mode configuration_0i1m0 {
requiring cpu_0.frequency >= 2289
requiring cpu_1.frequency >= 2289
requiring cpu_2.frequency >= 2289
requiring cpu_3.frequency >= 2289
requiring ram_1.total >= 14825
requiring disk_1.total >= 6315
requiring network_1.throughput >= 52125
providing compute_resource_0.flops = (((cpu_0.frequency+cpu_1.frequency)+cpu_2.frequency)+cpu_3.frequency)
providing quality = 10
providing energy = ((0.17*(size^2))+(0.78*compute_resource_0.flops))
}
mode configuration_0i1m1 {
requiring cpu_0.frequency >= 1888
requiring cpu_1.frequency >= 1888
requiring cpu_2.frequency >= 1888
requiring cpu_3.frequency >= 1888
requiring ram_1.total >= 4782
requiring disk_1.total >= 5972
requiring network_1.throughput >= 45852
providing compute_resource_0.flops = (((cpu_0.frequency+cpu_1.frequency)+cpu_2.frequency)+cpu_3.frequency)
providing quality = 1
providing energy = ((0.25*(size^2))+(0.44*compute_resource_0.flops))
}
}
contract implementation_0i0 {
requires component the_component_0c0 of type component_0c0
requires component the_component_0c1 of type component_0c1
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_0c0.quality >= 89.0
requiring the_component_0c1.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_0c0 of type component_0c0
requires component the_component_0c1 of type component_0c1
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_0c0.quality >= 45.0
requiring the_component_0c1.quality >= 67.0
requiring cpu_0.frequency >= 1566.0
requiring ram_1.total >= 8601.0
requiring disk_1.total >= 15770.0
requiring network_1.throughput >= 80225.0
providing quality = 96.0
providing energy = ((0.9*(size^2.0))+(0.13*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
requires resource cpu_0 of type CPU
requires resource cpu_1 of type CPU
requires resource cpu_2 of type CPU
requires resource cpu_3 of type CPU
requires resource ram_1 of type RAM
requires resource disk_1 of type DISK
requires resource network_1 of type NETWORK
mode configuration_0i0_0i0m0 {
requiring cpu_0.frequency >= 2847
requiring cpu_1.frequency >= 2847
requiring cpu_2.frequency >= 2847
requiring cpu_3.frequency >= 2847
requiring ram_1.total >= 1009
requiring disk_1.total >= 13412
requiring network_1.throughput >= 10042
providing compute_resource_0.flops = (((cpu_0.frequency+cpu_1.frequency)+cpu_2.frequency)+cpu_3.frequency)
providing quality = 2
providing energy = ((0.28*(size^2))+(0.96*compute_resource_0.flops))
}
mode configuration_0i0_0i0m1 {
requiring cpu_0.frequency >= 1901
requiring cpu_1.frequency >= 1901
requiring cpu_2.frequency >= 1901
requiring cpu_3.frequency >= 1901
requiring ram_1.total >= 15803
requiring disk_1.total >= 4106
requiring network_1.throughput >= 58977
providing compute_resource_0.flops = (((cpu_0.frequency+cpu_1.frequency)+cpu_2.frequency)+cpu_3.frequency)
providing quality = 95
providing energy = ((0.24*(size^2))+(0.39*compute_resource_0.flops))
}
}
}
component component_0i0_1 {
contract implementation_0i0_1i0 {
requires resource compute_resource_0 of type ComputeNode
requires resource cpu_0 of type CPU
requires resource cpu_1 of type CPU
requires resource cpu_2 of type CPU
requires resource cpu_3 of type CPU
requires resource ram_1 of type RAM
requires resource disk_1 of type DISK
requires resource network_1 of type NETWORK
mode configuration_0i0_1i0m0 {
requiring cpu_0.frequency >= 1968
requiring cpu_1.frequency >= 1968
requiring cpu_2.frequency >= 1968
requiring cpu_3.frequency >= 1968
requiring ram_1.total >= 2057
requiring disk_1.total >= 9579
requiring network_1.throughput >= 64854
providing compute_resource_0.flops = (((cpu_0.frequency+cpu_1.frequency)+cpu_2.frequency)+cpu_3.frequency)
providing quality = 60
providing energy = ((0.45*(size^2))+(0.34*compute_resource_0.flops))
}
mode configuration_0i0_1i0m1 {
requiring cpu_0.frequency >= 2573
requiring cpu_1.frequency >= 2573
requiring cpu_2.frequency >= 2573
requiring cpu_3.frequency >= 2573
requiring ram_1.total >= 7208
requiring disk_1.total >= 8109
requiring network_1.throughput >= 10366
providing compute_resource_0.flops = (((cpu_0.frequency+cpu_1.frequency)+cpu_2.frequency)+cpu_3.frequency)
providing quality = 52
providing energy = ((0.02*(size^2))+(0.71*compute_resource_0.flops))
}
}
component component_0c0 {
contract implementation_0c0i0 {
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 = 45.0
providing energy = ((0.31*(size^2.0))+(0.12*cpu_0.frequency))
}
contract implementation_0c0i1 {
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_0i1_0 {
contract implementation_0i1_0i0 {
requires resource compute_resource_0 of type ComputeNode
requires resource cpu_0 of type CPU
requires resource cpu_1 of type CPU
requires resource cpu_2 of type CPU
requires resource cpu_3 of type CPU
requires resource ram_1 of type RAM
requires resource disk_1 of type DISK
requires resource network_1 of type NETWORK
mode configuration_0i1_0i0m0 {
requiring cpu_0.frequency >= 2540
requiring cpu_1.frequency >= 2540
requiring cpu_2.frequency >= 2540
requiring cpu_3.frequency >= 2540
requiring ram_1.total >= 5708
requiring disk_1.total >= 11314
requiring network_1.throughput >= 87018
providing compute_resource_0.flops = (((cpu_0.frequency+cpu_1.frequency)+cpu_2.frequency)+cpu_3.frequency)
providing quality = 36
providing energy = ((0.77*(size^2))+(0.8*compute_resource_0.flops))
}
mode configuration_0i1_0i0m1 {
requiring cpu_0.frequency >= 2303
requiring cpu_1.frequency >= 2303
requiring cpu_2.frequency >= 2303
requiring cpu_3.frequency >= 2303
requiring ram_1.total >= 13297
requiring disk_1.total >= 15689
requiring network_1.throughput >= 2820
providing compute_resource_0.flops = (((cpu_0.frequency+cpu_1.frequency)+cpu_2.frequency)+cpu_3.frequency)
providing quality = 54
providing energy = ((0.21*(size^2))+(0.92*compute_resource_0.flops))
}
}
}
component component_0i1_1 {
contract implementation_0i1_1i0 {
requires resource compute_resource_0 of type ComputeNode
requires resource cpu_0 of type CPU
requires resource cpu_1 of type CPU
requires resource cpu_2 of type CPU
requires resource cpu_3 of type CPU
requires resource ram_1 of type RAM
requires resource disk_1 of type DISK
requires resource network_1 of type NETWORK
mode configuration_0i1_1i0m0 {
requiring cpu_0.frequency >= 1941
requiring cpu_1.frequency >= 1941
requiring cpu_2.frequency >= 1941
requiring cpu_3.frequency >= 1941
requiring ram_1.total >= 6327
requiring disk_1.total >= 6875
requiring network_1.throughput >= 99879
providing compute_resource_0.flops = (((cpu_0.frequency+cpu_1.frequency)+cpu_2.frequency)+cpu_3.frequency)
providing quality = 6
providing energy = ((0.67*(size^2))+(0.4*compute_resource_0.flops))
}
mode configuration_0i1_1i0m1 {
requiring cpu_0.frequency >= 2896
requiring cpu_1.frequency >= 2896
requiring cpu_2.frequency >= 2896
requiring cpu_3.frequency >= 2896
requiring ram_1.total >= 15404
requiring disk_1.total >= 4378
requiring network_1.throughput >= 94766
providing compute_resource_0.flops = (((cpu_0.frequency+cpu_1.frequency)+cpu_2.frequency)+cpu_3.frequency)
providing quality = 27
providing energy = ((0.47*(size^2))+(0.11*compute_resource_0.flops))
}
}
component component_0c1 {
contract implementation_0c1i0 {
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 >= 2038.0
requiring ram_1.total >= 8941.0
requiring disk_1.total >= 11052.0
requiring network_1.throughput >= 85378.0
providing quality = 86.0
providing energy = ((0.37*(size^2.0))+(0.71*cpu_0.frequency))
}
contract implementation_0c1i1 {
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 >= 2192.0
requiring ram_1.total >= 7448.0
requiring disk_1.total >= 15946.0
requiring network_1.throughput >= 6181.0
providing quality = 89.0
providing energy = ((0.1*(size^2.0))+(0.63*cpu_0.frequency))
}
using property quality
using property energy
}
request component_0 {
meta size = 6
requiring quality >= 35
request request0 for component_0 {
meta size = 144.0
requiring quality >= 96.0
}
minimize sum(energy)
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