Search in sources :

Example 1 with ParameterValue

use of bpsim.ParameterValue 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 ParameterValue

use of bpsim.ParameterValue 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;
}
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) SimulationSet(org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationSet) ParameterValue(bpsim.ParameterValue) CostParameters(bpsim.CostParameters) NormalDistributionType(bpsim.NormalDistributionType) Parameter(bpsim.Parameter) TimeParameters(bpsim.TimeParameters) ResourceParameters(bpsim.ResourceParameters)

Example 3 with ParameterValue

use of bpsim.ParameterValue in project kie-wb-common by kiegroup.

the class Simulations method extractDouble.

private static Double extractDouble(EList<ParameterValue> parameterValues) {
    if (parameterValues.isEmpty()) {
        throw new IllegalArgumentException("failure params");
    }
    ParameterValue value = parameterValues.get(0);
    FloatingParameterType floatingValue = (FloatingParameterType) value;
    return floatingValue.getValue();
}
Also used : ParameterValue(bpsim.ParameterValue) FloatingParameterType(bpsim.FloatingParameterType)

Example 4 with ParameterValue

use of bpsim.ParameterValue 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;
}
Also used : ParameterValue(bpsim.ParameterValue) Parameter(bpsim.Parameter) PoissonDistributionType(bpsim.PoissonDistributionType) SimulationSet(org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationSet) ResourceParameters(bpsim.ResourceParameters) Factories.bpsim(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Factories.bpsim) 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) PoissonDistributionType(bpsim.PoissonDistributionType) SimulationSet(org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationSet) ParameterValue(bpsim.ParameterValue) CostParameters(bpsim.CostParameters) NormalDistributionType(bpsim.NormalDistributionType) Parameter(bpsim.Parameter) TimeParameters(bpsim.TimeParameters) ResourceParameters(bpsim.ResourceParameters)

Example 5 with ParameterValue

use of bpsim.ParameterValue in project kie-wb-common by kiegroup.

the class SimulationSets method extractDouble.

private static Double extractDouble(EList<ParameterValue> parameterValues) {
    if (parameterValues.isEmpty()) {
        throw new IllegalArgumentException("failure params");
    }
    ParameterValue value = parameterValues.get(0);
    FloatingParameterType floatingValue = (FloatingParameterType) value;
    return floatingValue.getValue();
}
Also used : ParameterValue(bpsim.ParameterValue) FloatingParameterType(bpsim.FloatingParameterType)

Aggregations

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