Commit 5854faae authored by Marco Volpe's avatar Marco Volpe
Browse files

Fixed computation of the solution schedule

Issue-Ref: 3648
Issue-Url: https://af3-developer.fortiss.org/issues/3648

Signed-off-by: Marco Volpe's avatarMarco Volpe <volpe@fortiss.org>
parent 19604758
......@@ -5,7 +5,7 @@ ConstraintDefinitionUtils.java f110a4a216905d2236324ae459d789d50114e25c GREEN
ConstraintToNonQuantifiedSMT.java de0e8a7000e26d745b62a27f8c2482e7a7737add GREEN
ConstraintToQuantifiedSMT.java c84e799c69195fe80a2e66a39d0192325b06c7fd GREEN
DSMLTransformationService.java b2e90e11e36346d01c79c18f16ffc62f66f35888 GREEN
DSMLtoSMTTransformator.java 8f4b1880e6a4ab9e8c69eb1c784d7320f6a6a500 RED
DSMLtoSMTTransformator.java d12c195177891f8959f28850626213e56b5b04c8 YELLOW
DeploScheduleRun.java d074d157250deba431d8f34d13d6464fd27f8acb GREEN
DeploymentRun.java 67d240b1f02f906748811acad9ced9dd71e7cb56 GREEN
IDSMLTransformationService.java f56241d2dff68a69cd1fe09c119d615f74088650 GREEN
......
......@@ -138,6 +138,7 @@ public class DSMLtoSMTTransformator {
/** Function name used used to refer to starting times. */
// TODO (AD): Naming: Why "Dummy"? Can that substring be removed? refs #3472
private static final String START_TIME_FUNCTION_NAME = "f_StartTimeDummy_value";
private static final String DURATION_FUNCTION_NAME = "f_DurationDummy_value";
/** Constructor. */
public DSMLtoSMTTransformator(ExplorationSpecification explorationSpec, Context context) {
......@@ -322,6 +323,7 @@ public class DSMLtoSMTTransformator {
public EList<ResourceAllocation> computeSchedule(Model model) {
EList<ResourceAllocation> resAllList = new BasicEList<ResourceAllocation>();
FuncDecl startFun = getStartTimeDecl(model);
FuncDecl durationFun = getDurationDecl(model);
for(Entry<IModelElement, Expr> m : transformationService.getExistingInstances()
.entrySet()) {
......@@ -332,9 +334,11 @@ public class DSMLtoSMTTransformator {
// searches for the starting time value in the model
// for a given resource allocation and sets its trigger accordingly
Expr toEval = startFun.apply(m.getValue());
Expr startExpr = startFun.apply(m.getValue());
IntNum startNum = (IntNum)model.eval(startExpr, true);
Expr durationExpr = durationFun.apply(m.getValue());
IntNum durationNum = (IntNum)model.eval(durationExpr, true);
IntNum eval = (IntNum)model.eval(toEval, true);
IModelElement modelElement = m.getKey();
SuperSetMap superSets = explorationSpec.getSearchSpace();
......@@ -349,16 +353,13 @@ public class DSMLtoSMTTransformator {
}
ResourceAllocation allocation = findFirst.get();
PeriodicTimeTrigger periodicTimeTrigger = (PeriodicTimeTrigger)allocation.getTrigger();
// There is at least one target (we use it to get a reference to the
// corresponding {@link FileProject}).
// TODO(#3473): This runAsCommand looks suspicious and is an indicator that input
// TODO(#3473): This looks suspicious and is an indicator that input
// models are modified (Output models are added to the FileProject only after all
// operations were applied --> Not needed then). Probably can be removed when the
// input ResourceAllocations are gone.
runAsCommand(((ExplorationSpecification)superSets.eContainer()).getTargets().get(0),
() -> {
periodicTimeTrigger.setStartTime(new BigDecimal(eval.getBigInteger()));
});
periodicTimeTrigger.setStartTime(new BigDecimal(startNum.getBigInteger()));
allocation.setDuration(new BigDecimal(durationNum.getBigInteger()));
resAllList.add(allocation);
}
return resAllList;
......@@ -378,6 +379,19 @@ public class DSMLtoSMTTransformator {
return null;
}
/**
* Returns the {@link FuncDecl} corresponding to duration times ({@code null} in case it does
* not exist).
*/
private FuncDecl getDurationDecl(Model model) {
for(FuncDecl decl : model.getDecls()) {
if(decl.getName().toString().equals(DURATION_FUNCTION_NAME)) {
return decl;
}
}
return null;
}
/**
* Returns the {@link TaskToExecutionUnitAllocationEntry}s of the given {@link Model}.
*
......
Markdown is supported
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