Search in sources :

Example 1 with SimulationAttributeSet

use of org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationAttributeSet 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();
}
Also used : VoidMatch(org.kie.workbench.common.stunner.bpmn.backend.converters.VoidMatch) ParameterValue(bpsim.ParameterValue) Parameter(bpsim.Parameter) PoissonDistributionType(bpsim.PoissonDistributionType) SimulationSet(org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationSet) ResourceParameters(bpsim.ResourceParameters) UniformDistributionType(bpsim.UniformDistributionType) EList(org.eclipse.emf.common.util.EList) CostParameters(bpsim.CostParameters) FloatingParameterType(bpsim.FloatingParameterType) NormalDistributionType(bpsim.NormalDistributionType) Match(org.kie.workbench.common.stunner.bpmn.backend.converters.Match) ElementParameters(bpsim.ElementParameters) TimeParameters(bpsim.TimeParameters) SimulationAttributeSet(org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationAttributeSet) PoissonDistributionType(bpsim.PoissonDistributionType) SimulationAttributeSet(org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationAttributeSet) ParameterValue(bpsim.ParameterValue) NormalDistributionType(bpsim.NormalDistributionType) Parameter(bpsim.Parameter) TimeParameters(bpsim.TimeParameters)

Example 2 with SimulationAttributeSet

use of org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationAttributeSet in project kie-wb-common by kiegroup.

the class SimulationAttributeSets method of.

public static SimulationAttributeSet of(ElementParameters eleType) {
    TimeParameters timeParams = eleType.getTimeParameters();
    if (timeParams == null) {
        return new SimulationAttributeSet();
    }
    Parameter processingTime = timeParams.getProcessingTime();
    ParameterValue paramValue = processingTime.getParameterValue().get(0);
    return Match.of(ParameterValue.class, SimulationAttributeSet.class).when(NormalDistributionType.class, ndt -> {
        SimulationAttributeSet simulationSet = new SimulationAttributeSet();
        simulationSet.getMean().setValue(ndt.getMean());
        simulationSet.getStandardDeviation().setValue(ndt.getStandardDeviation());
        simulationSet.getDistributionType().setValue("normal");
        return simulationSet;
    }).when(UniformDistributionType.class, udt -> {
        SimulationAttributeSet simulationSet = new SimulationAttributeSet();
        simulationSet.getMin().setValue(udt.getMin());
        simulationSet.getMax().setValue(udt.getMax());
        simulationSet.getDistributionType().setValue("uniform");
        return simulationSet;
    }).when(PoissonDistributionType.class, pdt -> {
        SimulationAttributeSet simulationSet = new SimulationAttributeSet();
        simulationSet.getMean().setValue(pdt.getMean());
        simulationSet.getDistributionType().setValue("poisson");
        return simulationSet;
    }).apply(paramValue).asSuccess().value();
}
Also used : NormalDistributionType(bpsim.NormalDistributionType) ParameterValue(bpsim.ParameterValue) Parameter(bpsim.Parameter) PoissonDistributionType(bpsim.PoissonDistributionType) Match(org.kie.workbench.common.stunner.bpmn.backend.converters.Match) ElementParameters(bpsim.ElementParameters) TimeParameters(bpsim.TimeParameters) Factories.bpsim(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Factories.bpsim) UniformDistributionType(bpsim.UniformDistributionType) SimulationAttributeSet(org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationAttributeSet) PoissonDistributionType(bpsim.PoissonDistributionType) SimulationAttributeSet(org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationAttributeSet) ParameterValue(bpsim.ParameterValue) NormalDistributionType(bpsim.NormalDistributionType) Parameter(bpsim.Parameter) TimeParameters(bpsim.TimeParameters)

Aggregations

ElementParameters (bpsim.ElementParameters)2 NormalDistributionType (bpsim.NormalDistributionType)2 Parameter (bpsim.Parameter)2 ParameterValue (bpsim.ParameterValue)2 PoissonDistributionType (bpsim.PoissonDistributionType)2 TimeParameters (bpsim.TimeParameters)2 UniformDistributionType (bpsim.UniformDistributionType)2 Match (org.kie.workbench.common.stunner.bpmn.backend.converters.Match)2 SimulationAttributeSet (org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationAttributeSet)2 CostParameters (bpsim.CostParameters)1 FloatingParameterType (bpsim.FloatingParameterType)1 ResourceParameters (bpsim.ResourceParameters)1 EList (org.eclipse.emf.common.util.EList)1 VoidMatch (org.kie.workbench.common.stunner.bpmn.backend.converters.VoidMatch)1 Factories.bpsim (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Factories.bpsim)1 SimulationSet (org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationSet)1