Commit 094095a7 authored by Albert Zuendorf's avatar Albert Zuendorf
Browse files

submitted version

parent ac2070a5
......@@ -7,7 +7,7 @@
"emfer",
"simple"
],
"timeoutValue": 2,
"timeoutValue": 15,
"timeoutUnit": "MINUTES",
"seed": 0,
// "repetitions": 10,
......
......@@ -15,10 +15,13 @@ dependencies {
compile "org.eclipse.emf:org.eclipse.emf.ecore:2.9.0-v20130528-0742"
compile "org.eclipse.emf:org.eclipse.emf.common:2.9.0-v20130528-0742"
// compile "org.eclipse.emf:org.eclipse.emf.ecore.xmi:2.9.0-v20130528-0742"
compile files("./libs/libEMFER.jar")
compile files("./libs/libEMFER.jar",
"./libs/org.eclipse.xtext.xbase.lib_2.13.0.v20171020-0659.jar",
"./libs/com.google.guava_21.0.0.v20170206-1425.jar")
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile project(path: ':jastadd-mquat-solver', configuration: 'testArtifacts')
}
group 'de.tudresden.inf.st'
version '1.0.0-SNAPSHOT'
......
This diff is collapsed.
......@@ -8,6 +8,8 @@ import de.tudresden.inf.st.mquat.solving.SolvingException;
import de.tudresden.inf.st.mquat.utils.StopWatch;
import emfer.EMFeR;
import emfer.reachability.ReachableState;
import emfer.stories.StoryStep;
import emfer.stories.Storyboard;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.emf.ecore.EDataType;
......@@ -102,8 +104,9 @@ public class EMFeRSolver implements BenchmarkableSolver {
EMFeR emfer = new EMFeR()
.withStart(eSolution)
.withMaxNoOfNewStates(100 * 1000)
.withMetric(root -> -1 * emFeRTrafos.getNumberOfOpenIssues(root))
.withTimeLimit(this.maxSolvingTime / 4 * 3)
.withMaxNoOfNewStates(300 * 1000)
.withMetric(root -> emFeRTrafos.getNumberOfSolvedIssues(root))
.withTrafo("choose implementation", root -> emFeRTrafos.getImplementationChoices(root), (root, impl) -> emFeRTrafos.applyImplementationChoice(root, impl))
.withTrafo("assign node", root -> emFeRTrafos.getComputeNodeChoices(root), (root, node) -> emFeRTrafos.assignComputeNode(root, node))
;
......@@ -148,6 +151,12 @@ public class EMFeRSolver implements BenchmarkableSolver {
}
}
// Storyboard story = new Storyboard("EmferSolverTest");
//
// printReachableStatesList(emfer, "E_");
//
// story.dumpHtml();
if (bestSolution != null)
{
logger.info("emfer found a solution with an objective of {}. Number of complete solutions {} ", bestSolution.computeObjective(), noOfCompleteSolutions );
......@@ -158,6 +167,25 @@ public class EMFeRSolver implements BenchmarkableSolver {
return bestSolution;
}
private void printReachableStatesList(EMFeR emfer, String prefix)
{
StoryStep step = new StoryStep();
for (ReachableState s : emfer.getReachabilityGraph().getStates())
{
StringBuilder buf = new StringBuilder();
String descr = step.genHtmlStateDescription(s, prefix);
java.util.logging.Logger.getGlobal().info(descr);
}
}
private boolean isCompleteSolution(ESolution eSolution)
{
for (EAssignment eAssignment : eSolution.getAssignments())
......
......@@ -143,7 +143,7 @@ public class EMFeRTrafos
componentMapping.setAssignment(dSubAssignment);
dAssignment.getComponentMappings().add(componentMapping);
transformSubAssignments(dSubAssignment, eSubAssignment, subImpl);
transformPartialSubAssignments(dSubAssignment, eSubAssignment, subImpl);
if (eSubAssignment.getNodeName() == null)
{
......@@ -381,12 +381,22 @@ public class EMFeRTrafos
for (Implementation dImpl : comp.getImplementations())
{
String implName = dImpl.getName().toString();
eAssignment.setImplName(implName);
// Collection computeNodeChoices = getComputeNodeChoices(eSolution, eAssignment);
// if (computeNodeChoices.size() == 0)
// {
// continue;
// }
EChoice eImpl = Ttc18Factory.eINSTANCE.createEChoice();
eImpl.setAssignment(eAssignment);
eImpl.setResName(dImpl.getName().toString());
result.add(eImpl);
}
eAssignment.setImplName(null);
return result;
}
......@@ -429,6 +439,24 @@ public class EMFeRTrafos
return result;
}
getComputeNodeChoices(eSolution, result, eAssignment);
return result;
}
private Collection getComputeNodeChoices(ESolution eSolution, EAssignment eAssignment)
{
ArrayList<EChoice> result = new ArrayList<>();
getComputeNodeChoices(eSolution, result, eAssignment);
return result;
}
private void getComputeNodeChoices(ESolution eSolution, ArrayList<EChoice> result, EAssignment eAssignment)
{
HashSet<String> alreadInUseComputeNodes = getAlreadInUseComputeNodes(eSolution);
// loop through all compute nodes
......@@ -448,7 +476,7 @@ public class EMFeRTrafos
// if assignment is valid, add choice
boolean allValid = checkAssignments(dSolution);
boolean allValid = checkAssignments(dSolution, eAssignment.getImplName());
if (allValid)
{
......@@ -466,57 +494,56 @@ public class EMFeRTrafos
eAssignment.setNodeName(null);
if (result.size() == 0)
{
System.out.println("did not find hardware for \n" + eAssignment);
}
return result;
// if (result.size() == 0)
// {
// System.out.println("did not find hardware for \n" + eAssignment);
// }
}
private boolean checkAssignments(Solution dSolution)
private boolean checkAssignments(Solution dSolution, String implName)
{
for (Assignment dAssignment : dSolution.getAssignmentList())
{
if (dAssignment.getResource() != null)
if (dAssignment.getImplementation().getName().toString().equals(implName))
{
if (dAssignment.isValid())
try
{
// check kids
checkAssignments(dAssignment);
return dAssignment.isValid();
}
else
catch (Exception e)
{
return false;
}
}
// check kids
if (checkAssignments(dAssignment, implName))
{
return true;
}
}
return true;
return false;
}
private boolean checkAssignments(Assignment parent)
private boolean checkAssignments(Assignment parent, String implName)
{
for (ComponentMapping componentMapping : parent.getComponentMappingList())
{
Assignment dAssignment = componentMapping.getAssignment();
if (dAssignment.getResourceMapping() != null && dAssignment.getResource() != null)
if (dAssignment.getImplementation().getName().toString().equals(implName))
{
if (dAssignment.isValid())
{
// check kids
checkAssignments(dAssignment);
}
else
{
return false;
}
return dAssignment.isValid();
}
if (checkAssignments(dAssignment, implName))
{
return true;
}
}
return true;
return false;
}
......@@ -642,6 +669,36 @@ public class EMFeRTrafos
eChoice.getAssignment().setNodeName(eChoice.getResName());
}
public double getNumberOfSolvedIssues(EObject root)
{
ESolution eSolution = (ESolution) root;
int result = 0;
for (EAssignment eAssignment : eSolution.getAssignments())
{
result += getNumberOfAssignmentSolvedIssues(eAssignment);
}
return result;
}
private int getNumberOfAssignmentSolvedIssues(EAssignment eAssignment)
{
int result = 0;
if (eAssignment.getImplName() != null) result++;
if (eAssignment.getNodeName() != null) result++;
for (EAssignment kid : eAssignment.getAssignments())
{
result += getNumberOfAssignmentSolvedIssues(kid);
}
return result;
}
public double getNumberOfOpenIssues(EObject root)
{
ESolution eSolution = (ESolution) root;
......
......@@ -29,18 +29,18 @@ public class EMFeRSolverTest {
@Test
public void testEmferSolver() throws SolvingException {
int tlc = 1;
int iac = 2;
int iac = 0;
int isd = 0;
int cac = 0;
int cac = 2;
int csd = 0;
int dep = 2;
int imp = 1;
int dep = 5;
int imp = 2;
int mod = 3;
double res = 1.5d;
int nfp = 0;
int req = 3;
int req = 1;
int cpu = 1;
int seed = 1;
int seed = 0;
ScenarioGenerator generator = new ScenarioGenerator(new ScenarioDescription(tlc, iac, isd, cac, csd, dep, imp, res, req, cpu, seed));
......
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