Prechádzať zdrojové kódy

Some work done on TaskFulfillmentMetric

Jan Enders 8 rokov pred
rodič
commit
a3709170df

+ 11 - 1
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/metrics/CommunicationCostMetric.java

@@ -27,6 +27,10 @@ import javafx.util.Pair;
 // TODO: make this work well with multiple operator graphs
 public class CommunicationCostMetric implements ScopvizGraphMetric {
 
+	/** Message to show if not all Operator nodes have been placed onto the underlay */
+	private static final Pair<String, String> ERROR_MESSAGE = new Pair<String, String>("Warning",
+			"Not all Nodes have a valid Mapping");
+	
 	/** Flag for when an error occurs during computation. */
 	// TODO: this is not yet being used for output and never reset
 	private boolean error = false;
@@ -49,6 +53,11 @@ public class CommunicationCostMetric implements ScopvizGraphMetric {
 	@Override
 	public LinkedList<Pair<String, String>> calculate(MyGraph g) {
 		LinkedList<Pair<String, String>> results = new LinkedList<Pair<String, String>>();
+		
+		if(error){
+			error = false;
+			results.add(ERROR_MESSAGE);
+		}
 
 		MyGraph operator = new MyGraph("opWithTime");
 		for (Node n : g.getNodeSet()) {
@@ -69,7 +78,8 @@ public class CommunicationCostMetric implements ScopvizGraphMetric {
 		// TODO: not fully sure if the diameter Method does exactly what we
 		// want, requires testing
 		double communicationCost = Toolkit.diameter(operator, "cost", true);
-
+		communicationCost = Math.round(communicationCost * 100) / 100;
+		
 		results.add(new Pair<String, String>("Overall Cost", "" + communicationCost));
 
 		return results;

+ 12 - 5
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/metrics/TaskFulfillmentMetric.java

@@ -7,11 +7,14 @@ import org.graphstream.graph.Edge;
 
 import de.tu_darmstadt.informatik.tk.scopviz.graphs.MappingGraphManager;
 import de.tu_darmstadt.informatik.tk.scopviz.graphs.MyGraph;
+import de.tu_darmstadt.informatik.tk.scopviz.main.Layer;
 import de.tu_darmstadt.informatik.tk.scopviz.metrics.interfaces.ScopvizGraphMetric;
 import javafx.util.Pair;
 
 //TODO: TaksFulfillmentMetric not yet implemented due to missing support for graph attributes.
 public class TaskFulfillmentMetric implements ScopvizGraphMetric {
+	
+	private boolean error = false;
 
 	@Override
 	public boolean isSetupRequired() {
@@ -31,14 +34,18 @@ public class TaskFulfillmentMetric implements ScopvizGraphMetric {
 	@Override
 	public LinkedList<Pair<String, String>> calculate(MyGraph g) {
 		LinkedList<Pair<String, String>> results = new LinkedList<Pair<String, String>>();
+		
+		
 		if (g.isComposite()) {
 			LinkedList<MyGraph> graphs = g.getAllSubGraphs();
-			for (MyGraph current : graphs) {
-				String attributes = "";
-				for (String key : current.getAttributeKeySet()) {
-					attributes = attributes.concat(key + ":" + current.getAttribute(key) + ", ");
+			for (MyGraph current : graphs) {				
+				if (current.getAttribute("layer") == Layer.OPERATOR){
+					Double priority = current.getAttribute("priority");
+					if (priority == null){
+						error = true;
+					}
 				}
-				results.add(new Pair<String, String>(current.getId(), attributes));
+//				
 			}
 		}
 		LinkedList<Edge> mappingEdges = new LinkedList<Edge>(g.getEdgeSet().stream()