...
 
Commits (2)
......@@ -103,6 +103,7 @@ public class Algorithm {
}
/******************************/
/** Sums Lmin for every edge, + capacity for every device for this flow, up to *entry* in h **/
public float minTimeTakenFromSourceToH(Flow f, Node h) {
Path p = f.getPath().pathRestrictedToH(h);
......@@ -117,7 +118,7 @@ public class Algorithm {
}
/******************************/
/** Sums Lmax for every edge, + capacity for every device for this flow, up to *entry* in h **/
public float maxTimeTakenFromSourceToH(Flow f, Node h) {
Path p = f.getPath().pathRestrictedToH(h);
......@@ -142,7 +143,7 @@ public class Algorithm {
List<Node> nodesI = i.getPath().getNodes();
List<Node> nodesJ = j.getPath().getNodes();
List<Node> intersectNodesINodesJ = Utils.getIntersectionList(nodesJ,
nodesI);
nodesI); //ordered by J
for (Node x : intersectNodesINodesJ) {
if (intersectNodesINodesJ.indexOf(x) == 0) {
......@@ -442,7 +443,7 @@ public class Algorithm {
for (Node k : i.getPath().pathRestrictedToH(h).getNodes()) {
if (k != slow) {
double max = 0;
double max = 0; // for this node, biggest capacity for all flows that cross flow i and are at least as important (and have a common first point)
for (Flow j : Utils.getUnionList(i.getHigherPriorityFlows(),
i.getSamePriorityFlows(), i)) {
if(k.getCapacity().get(j)==null)
......
package fr.tpt.mem4csd.sefa.trajectory.control;
import java.util.ArrayList;
import java.util.List;
import fr.tpt.mem4csd.sefa.trajectory.model.Flow;
import fr.tpt.mem4csd.sefa.trajectory.model.Node;
/** Helper class to compute details of worst case response time
* contains a list of LogAggregate
* **/
public class DetailLogger {
/** A single log **/
public class Log{
Flow f;
Node n;
public Log(String s, double val){this.reason=s;this.value=val;};
public Log(String s, double val, Flow f, Node n){this.reason=s;this.value=val;this.f=f;this.n=n;};
public Log(String s, double val, Node n){this.reason=s;this.value=val;this.n=n;};
String reason;
double value;
}
/** A list of log **/
public class LogAggregate{
List<Log> a;
double value;
public LogAggregate(){this.a=new ArrayList<Log>();this.value=0.;}
public void add(Log l) {this.a.add(l);this.value+=l.value;}
public LogAggregate max(LogAggregate l){if(l.value>this.value)return l; else return this;}
public void add(LogAggregate l){for(Log ll:l.a) {this.add(ll);};}
}
ArrayList<LogAggregate> cur;
public DetailLogger() {this.cur=new ArrayList<LogAggregate>();}
public void fork(){this.cur.add(new LogAggregate());}
public void joinMax(){
assert(this.cur.size()>1);
LogAggregate m = this.cur.get(this.cur.size()-2).max(this.cur.get(this.cur.size()-1));
this.cur.remove(this.cur.size()-1);
this.cur.remove(this.cur.size()-1);
this.cur.add(m);
}
public void joinAdd(){
assert(this.cur.size()>1);
this.cur.get(this.cur.size()-2).add(this.cur.get(this.cur.size()-1));
this.cur.remove(this.cur.size()-1);
}
public void log(String s, double val) {this.cur.get(this.cur.size()-1).add(new Log(s,val));}
public void log(String s, double val, Node n) {this.cur.get(this.cur.size()-1).add(new Log(s,val,n));}
public void log(String s, double val, Flow f, Node n) {this.cur.get(this.cur.size()-1).add(new Log(s,val,f,n));}
}
......@@ -495,12 +495,14 @@ public class LatencyAnalyzer //extends AbstractAnalyzer
System.out.println(n);
Algorithm algo = new Algorithm(n);
List<Float> resultList = algo.computeWorstCaseEndToEndResponse();
Map<ComponentInstance, Float> results = new HashMap<ComponentInstance, Float>();
Map<ComponentInstance, Float> deadlines = new HashMap<ComponentInstance, Float>();
if(false) {
Algorithm algo = new Algorithm(n);
List<Float> resultList = algo.computeWorstCaseEndToEndResponse();
int i=0;
for(Float res: resultList)
{
......@@ -512,6 +514,38 @@ public class LatencyAnalyzer //extends AbstractAnalyzer
i++;
System.out.println("Flow "+i+" : WCRT = "+res);
}
} else {
Algorithm2 algo = new Algorithm2(n);
List<DetailLogger> resultList = algo.computeWorstCaseEndToEndResponse();
int i=0;
for(DetailLogger res: resultList)
{
Flow flow = n.getFlows().get(i);
ComponentInstance ci = flow2CI.get(flow);
results.put(ci, (float)(res.cur.get(0).value) );
deadlines.put(ci, flow.getDeadline());
i++;
for(DetailLogger.Log l:res.cur.get(0).a) {
if(l.n==null) System.out.println(" , , "+l.value);
}
for(Node nn:flow.getPath().getNodes()) {
for(DetailLogger.Log l:res.cur.get(0).a) {
if(l.n==nn) System.out.println(l.n.getId()+", "+(l.f==null ? "" : l.f.getId()) +", "+l.value);
}
}
System.out.println("Flow "+i+" : WCRT = "+res.cur.get(0).value);
}
//TODO
}
return new TrajectoryAnalysisResult(results, deadlines);
}
......
......@@ -40,6 +40,7 @@ public class Path {
public void setNodeDirection() {}//TODO
/***********************/
/** Path up to h (included) **/
public Path pathRestrictedToH(Node h) {
Path p = new Path();
if (this.getNodes().contains(h)) {
......