Skip to content

Commit

Permalink
Renamed fixedstepbuilder to jacobianstepbuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
FrederikPM committed Mar 31, 2021
1 parent 91c73c3 commit 5091e89
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 13 deletions.
2 changes: 0 additions & 2 deletions plugins/fixedstepbuilder/readme.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>

<groupId>org.into-cps.maestro.plugins</groupId>
<artifactId>fixedstepbuilder</artifactId>
<artifactId>jacobianstepbuilder</artifactId>

<dependencies>
<dependency>
Expand Down
2 changes: 2 additions & 0 deletions plugins/jacobianstepbuilder/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Jacobian Step Plugin

Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public List<PStm> expand(AFunctionDeclaration declaredFunction, List<PExp> forma
DynamicActiveBuilderScope dynamicScope = builder.getDynamicScope();
MathBuilderFmi2Api math = builder.getMathBuilder();
BooleanBuilderFmi2Api booleanLogic = builder.getBooleanBuilder();
RealTime realTime = builder.getRealTime();

// Convert raw MaBL to API
DoubleVariableFmi2Api externalStepSize = builder.getDoubleVariableFrom(stepSizeVar);
Expand Down Expand Up @@ -209,6 +210,11 @@ public List<PStm> expand(AFunctionDeclaration declaredFunction, List<PExp> forma
convergenceReached = dynamicScope.store("has_converged", false);
}



DoubleVariableFmi2Api realStartTime = dynamicScope.store("real_start_time", 0.0);
realStartTime.setValue(realTime.getRealTime());

ScopeFmi2Api scopeFmi2Api = dynamicScope.enterWhile(loopPredicate);
{

Expand Down Expand Up @@ -353,15 +359,26 @@ public List<PStm> expand(AFunctionDeclaration declaredFunction, List<PExp> forma

discardScope.enterElse();
{


// Update currentCommunicationTime
currentCommunicationTime.setValue(currentCommunicationTime.toMath().addition(currentStepSize));
currentStepSize.setValue(stepSize);

// Call log
dataWriterInstance.log(currentCommunicationTime);

DoubleVariableFmi2Api realStepTime = dynamicScope.store("real_step_time", 0.0);
realStepTime.setValue(new DoubleExpressionValue(realTime.getRealTime().toMath().subtraction(realStartTime.toMath()).getExp()));
if(jacobianStepConfig.simulationProgramDelay){
dynamicScope.enterIf(realStepTime.toMath().lessThan(currentCommunicationTime));
{
DoubleVariableFmi2Api sleepTime = dynamicScope.store("sleep_time", 0.0);
sleepTime.setValue(new DoubleExpressionValue(currentCommunicationTime.toMath().subtraction(realStepTime).getExp()));
builder.getLogger().debug("## Simulation is ahead of real time. Sleeping for: %f MS", sleepTime);
realTime.sleep(sleepTime);
dynamicScope.leave();
}
}

dynamicScope.leave();
}

Expand Down Expand Up @@ -424,11 +441,6 @@ public String getName() {
public String getVersion() {
return "0.0.1";
}

private enum algorithmEnum {
variableStep,
fixedStep
}
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.intocps.maestro.plugin;
import java.util.ArrayList;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class JacobianStepConfig implements IPluginConfiguration {
Expand All @@ -10,4 +9,5 @@ public class JacobianStepConfig implements IPluginConfiguration {
public double absoluteTolerance;
public double relativeTolerance;
public int stabilisationLoopMaxIterations;
public boolean simulationProgramDelay;
}
2 changes: 1 addition & 1 deletion plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<module>api</module>
<module>typeconverter</module>
<module>fixedstep</module>
<module>fixedstepbuilder</module>
<module>jacobianstepbuilder</module>
<module>demo</module>
<module>topologicalsorting</module>
<module>verificationsuite</module>
Expand Down

0 comments on commit 5091e89

Please sign in to comment.