Search in sources :

Example 1 with ElementParameters

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;
}
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 2 with ElementParameters

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;
}
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 ElementParameters

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();
}
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 4 with ElementParameters

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);
}
Also used : CostParameters(bpsim.CostParameters) ElementParameters(bpsim.ElementParameters) ExtensionAttributeValue(org.eclipse.bpmn2.ExtensionAttributeValue) ResourceParameters(bpsim.ResourceParameters) Scenario(bpsim.Scenario) FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) Relationship(org.eclipse.bpmn2.Relationship) EObject(org.eclipse.emf.ecore.EObject) ControlParameters(bpsim.ControlParameters) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) PriorityParameters(bpsim.PriorityParameters) BPSimDataType(bpsim.BPSimDataType) TimeParameters(bpsim.TimeParameters)

Example 5 with ElementParameters

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);
}
Also used : ElementParameters(bpsim.ElementParameters)

Aggregations

ElementParameters (bpsim.ElementParameters)13 TimeParameters (bpsim.TimeParameters)8 Parameter (bpsim.Parameter)7 UniformDistributionType (bpsim.UniformDistributionType)7 NormalDistributionType (bpsim.NormalDistributionType)6 PoissonDistributionType (bpsim.PoissonDistributionType)6 CostParameters (bpsim.CostParameters)5 ResourceParameters (bpsim.ResourceParameters)5 ParameterValue (bpsim.ParameterValue)4 Match (org.kie.workbench.common.stunner.bpmn.backend.converters.Match)4 BPSimDataType (bpsim.BPSimDataType)3 FloatingParameterType (bpsim.FloatingParameterType)3 Scenario (bpsim.Scenario)3 EList (org.eclipse.emf.common.util.EList)3 SimulationAttributeSet (org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationAttributeSet)3 SimulationSet (org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationSet)3 HashMap (java.util.HashMap)2 Relationship (org.eclipse.bpmn2.Relationship)2 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)2 VoidMatch (org.kie.workbench.common.stunner.bpmn.backend.converters.VoidMatch)2