use of bpsim.ElementParameters in project kie-wb-common by kiegroup.
the class SimulationSets method of.
public static SimulationSet of(ElementParameters eleType) {
TimeParameters timeParams = eleType.getTimeParameters();
if (timeParams == null) {
return new SimulationSet();
}
Parameter processingTime = timeParams.getProcessingTime();
ParameterValue paramValue = processingTime.getParameterValue().get(0);
SimulationSet simulationSet = Match.of(ParameterValue.class, SimulationSet.class).when(NormalDistributionType.class, ndt -> {
SimulationSet sset = new SimulationSet();
sset.getMean().setValue(ndt.getMean());
sset.getStandardDeviation().setValue(ndt.getStandardDeviation());
sset.getDistributionType().setValue("normal");
return sset;
}).when(UniformDistributionType.class, udt -> {
SimulationSet sset = new SimulationSet();
sset.getMin().setValue(udt.getMin());
sset.getMax().setValue(udt.getMax());
sset.getDistributionType().setValue("uniform");
return sset;
}).when(PoissonDistributionType.class, pdt -> {
SimulationSet sset = new SimulationSet();
sset.getMean().setValue(pdt.getMean());
sset.getDistributionType().setValue("poisson");
return sset;
}).apply(paramValue).asSuccess().value();
CostParameters costParams = eleType.getCostParameters();
if (costParams != null) {
simulationSet.getUnitCost().setValue(extractDouble(costParams.getUnitCost()));
}
ResourceParameters resourceParams = eleType.getResourceParameters();
if (resourceParams != null) {
Double quantity = extractDouble(resourceParams.getQuantity());
simulationSet.getQuantity().setValue(quantity);
Double availability = extractDouble(resourceParams.getAvailability());
simulationSet.getWorkingHours().setValue(availability);
}
return simulationSet;
}
use of bpsim.ElementParameters in project kie-wb-common by kiegroup.
the class Simulations method simulationSet.
public static SimulationSet simulationSet(ElementParameters eleType) {
SimulationSet simulationSet = new SimulationSet();
TimeParameters timeParams = eleType.getTimeParameters();
if (timeParams == null) {
return simulationSet;
}
Parameter processingTime = timeParams.getProcessingTime();
ParameterValue paramValue = processingTime.getParameterValue().get(0);
VoidMatch.of(ParameterValue.class).when(NormalDistributionType.class, ndt -> {
simulationSet.getMean().setValue(ndt.getMean());
simulationSet.getStandardDeviation().setValue(ndt.getStandardDeviation());
simulationSet.getDistributionType().setValue("normal");
}).when(UniformDistributionType.class, udt -> {
simulationSet.getMin().setValue(udt.getMin());
simulationSet.getMax().setValue(udt.getMax());
simulationSet.getDistributionType().setValue("uniform");
}).when(PoissonDistributionType.class, pdt -> {
simulationSet.getMean().setValue(pdt.getMean());
simulationSet.getDistributionType().setValue("poisson");
}).apply(paramValue).asSuccess().value();
CostParameters costParams = eleType.getCostParameters();
if (costParams != null) {
simulationSet.getUnitCost().setValue(extractDouble(costParams.getUnitCost()));
}
// controlParams(eleType, simulationSet);
ResourceParameters resourceParams = eleType.getResourceParameters();
if (resourceParams != null) {
Double quantity = extractDouble(resourceParams.getQuantity());
simulationSet.getQuantity().setValue(quantity);
Double availability = extractDouble(resourceParams.getAvailability());
simulationSet.getWorkingHours().setValue(availability);
}
return simulationSet;
}
use of bpsim.ElementParameters in project kie-wb-common by kiegroup.
the class Simulations method simulationAttributeSet.
public static SimulationAttributeSet simulationAttributeSet(ElementParameters eleType) {
SimulationAttributeSet simulationSet = new SimulationAttributeSet();
TimeParameters timeParams = eleType.getTimeParameters();
if (timeParams == null) {
return simulationSet;
}
Parameter processingTime = timeParams.getProcessingTime();
ParameterValue paramValue = processingTime.getParameterValue().get(0);
return Match.of(ParameterValue.class, SimulationAttributeSet.class).when(NormalDistributionType.class, ndt -> {
simulationSet.getMean().setValue(ndt.getMean());
simulationSet.getStandardDeviation().setValue(ndt.getStandardDeviation());
simulationSet.getDistributionType().setValue("normal");
return simulationSet;
}).when(UniformDistributionType.class, udt -> {
simulationSet.getMin().setValue(udt.getMin());
simulationSet.getMax().setValue(udt.getMax());
simulationSet.getDistributionType().setValue("uniform");
return simulationSet;
}).when(PoissonDistributionType.class, pdt -> {
simulationSet.getMean().setValue(pdt.getMean());
simulationSet.getDistributionType().setValue("poisson");
return simulationSet;
}).apply(paramValue).asSuccess().value();
}
use of bpsim.ElementParameters in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method addSimulation.
public void addSimulation(Definitions def) {
Relationship relationship = Bpmn2Factory.eINSTANCE.createRelationship();
relationship.getSources().add(def);
relationship.getTargets().add(def);
relationship.setType(defaultRelationshipType);
BPSimDataType simDataType = BpsimFactory.eINSTANCE.createBPSimDataType();
// currently support single scenario
Scenario defaultScenario = BpsimFactory.eINSTANCE.createScenario();
// single scenario suppoert
defaultScenario.setId("default");
// single scenario support
defaultScenario.setName("Simulationscenario");
defaultScenario.setScenarioParameters(_simulationScenarioParameters);
if (_simulationElementParameters.size() > 0) {
Iterator<String> iter = _simulationElementParameters.keySet().iterator();
while (iter.hasNext()) {
String key = iter.next();
ElementParameters etype = BpsimFactory.eINSTANCE.createElementParameters();
etype.setElementRef(key);
List<EObject> params = _simulationElementParameters.get(key);
for (EObject np : params) {
if (np instanceof ControlParameters) {
etype.setControlParameters((ControlParameters) np);
} else if (np instanceof CostParameters) {
etype.setCostParameters((CostParameters) np);
} else if (np instanceof PriorityParameters) {
etype.setPriorityParameters((PriorityParameters) np);
} else if (np instanceof ResourceParameters) {
etype.setResourceParameters((ResourceParameters) np);
} else if (np instanceof TimeParameters) {
etype.setTimeParameters((TimeParameters) np);
}
}
defaultScenario.getElementParameters().add(etype);
}
}
simDataType.getScenario().add(defaultScenario);
ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
relationship.getExtensionValues().add(extensionElement);
FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry((Internal) BpsimPackage.Literals.DOCUMENT_ROOT__BP_SIM_DATA, simDataType);
relationship.getExtensionValues().get(0).getValue().add(extensionElementEntry);
def.getRelationships().add(relationship);
}
use of bpsim.ElementParameters in project kie-wb-common by kiegroup.
the class SubProcessPropertyWriter method setSimulationSet.
public void setSimulationSet(SimulationSet simulations) {
ElementParameters elementParameters = SimulationSets.toElementParameters(simulations);
elementParameters.setElementRef(this.baseElement.getId());
this.simulationParameters.add(elementParameters);
}
Aggregations