Search in sources :

Example 11 with TimeParameters

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

Example 12 with TimeParameters

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

the class SimulationSets method toElementParameters.

public static ElementParameters toElementParameters(SimulationSet simulationSet) {
    ElementParameters elementParameters = bpsim.createElementParameters();
    TimeParameters timeParameters = bpsim.createTimeParameters();
    Parameter processingTime = bpsim.createParameter();
    timeParameters.setProcessingTime(processingTime);
    switch(simulationSet.getDistributionType().getValue()) {
        case "normal":
            NormalDistributionType ndt = bpsim.createNormalDistributionType();
            ndt.setMean(simulationSet.getMean().getValue());
            ndt.setStandardDeviation(simulationSet.getStandardDeviation().getValue());
            processingTime.getParameterValue().add(ndt);
            break;
        case "uniform":
            UniformDistributionType udt = bpsim.createUniformDistributionType();
            udt.setMin(simulationSet.getMin().getValue());
            udt.setMax(simulationSet.getMax().getValue());
            processingTime.getParameterValue().add(udt);
            break;
        case "poisson":
            PoissonDistributionType pdt = bpsim.createPoissonDistributionType();
            pdt.setMean(simulationSet.getMean().getValue());
            processingTime.getParameterValue().add(pdt);
            break;
    }
    elementParameters.setTimeParameters(timeParameters);
    Double unitCost = simulationSet.getUnitCost().getValue();
    Double quantity = simulationSet.getQuantity().getValue();
    Double workingHours = simulationSet.getWorkingHours().getValue();
    CostParameters costParameters = bpsim.createCostParameters();
    costParameters.setUnitCost(toParameter(unitCost));
    elementParameters.setCostParameters(costParameters);
    ResourceParameters resourceParameters = bpsim.createResourceParameters();
    resourceParameters.setQuantity(toParameter(quantity));
    resourceParameters.setAvailability(toParameter(workingHours));
    elementParameters.setResourceParameters(resourceParameters);
    return elementParameters;
}
Also used : UniformDistributionType(bpsim.UniformDistributionType) PoissonDistributionType(bpsim.PoissonDistributionType) CostParameters(bpsim.CostParameters) ElementParameters(bpsim.ElementParameters) NormalDistributionType(bpsim.NormalDistributionType) Parameter(bpsim.Parameter) TimeParameters(bpsim.TimeParameters) ResourceParameters(bpsim.ResourceParameters)

Example 13 with TimeParameters

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

the class Bpmn2JsonMarshaller method extractTimeParamsToProperties.

private void extractTimeParamsToProperties(ElementParameters eleType, Map<String, Object> properties) {
    TimeParameters timeParams = eleType.getTimeParameters();
    if (timeParams != null) {
        Parameter processingTime = timeParams.getProcessingTime();
        if (processingTime != null && processingTime.getParameterValue() != null && processingTime.getParameterValue().size() > 0) {
            ParameterValue paramValue = processingTime.getParameterValue().get(0);
            if (paramValue instanceof NormalDistributionType) {
                NormalDistributionType ndt = (NormalDistributionType) paramValue;
                properties.put(MEAN, ndt.getMean());
                properties.put(STANDARDDEVIATION, ndt.getStandardDeviation());
                properties.put(DISTRIBUTIONTYPE, "normal");
            } else if (paramValue instanceof UniformDistributionType) {
                UniformDistributionType udt = (UniformDistributionType) paramValue;
                properties.put(MIN, udt.getMin());
                properties.put(MAX, udt.getMax());
                properties.put(DISTRIBUTIONTYPE, "uniform");
            } else if (paramValue instanceof PoissonDistributionType) {
                PoissonDistributionType pdt = (PoissonDistributionType) paramValue;
                properties.put(MEAN, pdt.getMean());
                properties.put(DISTRIBUTIONTYPE, "poisson");
            }
            if (timeParams.getWaitTime() != null) {
                extractParamTypeToProperties(WAITTIME, timeParams.getWaitTime().getParameterValue(), properties);
            }
        }
    }
}
Also used : UniformDistributionType(bpsim.UniformDistributionType) PoissonDistributionType(bpsim.PoissonDistributionType) ParameterValue(bpsim.ParameterValue) NormalDistributionType(bpsim.NormalDistributionType) Parameter(bpsim.Parameter) TimeParameters(bpsim.TimeParameters)

Example 14 with TimeParameters

use of bpsim.TimeParameters in project jbpm by kiegroup.

the class BpsimTest method testBpsimData.

@SuppressWarnings("unchecked")
public void testBpsimData() throws Exception {
    // write
    XMLResource inResource = (XMLResource) resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
    inResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8");
    inResource.setEncoding("UTF-8");
    DocumentRoot documentRoot = BpsimFactory.eINSTANCE.createDocumentRoot();
    BPSimDataType bpsimData = BpsimFactory.eINSTANCE.createBPSimDataType();
    Scenario defaultScenario = BpsimFactory.eINSTANCE.createScenario();
    defaultScenario.setId("default");
    defaultScenario.setName("Scenario");
    ScenarioParameters scenarioParams = BpsimFactory.eINSTANCE.createScenarioParameters();
    scenarioParams.setBaseTimeUnit(TimeUnit.S);
    defaultScenario.setScenarioParameters(scenarioParams);
    ElementParameters elementParams = BpsimFactory.eINSTANCE.createElementParameters();
    TimeParameters elementTimeParams = BpsimFactory.eINSTANCE.createTimeParameters();
    Parameter processingTimeParameter = BpsimFactory.eINSTANCE.createParameter();
    UniformDistributionType uniformDistrobutionType = BpsimFactory.eINSTANCE.createUniformDistributionType();
    uniformDistrobutionType.setMin(180.0);
    uniformDistrobutionType.setMax(600.0);
    processingTimeParameter.getParameterValue().add(uniformDistrobutionType);
    elementTimeParams.setProcessingTime(processingTimeParameter);
    elementParams.setTimeParameters(elementTimeParams);
    defaultScenario.getElementParameters().add(elementParams);
    bpsimData.getScenario().add(defaultScenario);
    documentRoot.setBPSimData(bpsimData);
    inResource.getContents().add(documentRoot);
    StringWriter stringWriter = new StringWriter();
    inResource.save(stringWriter, null);
    assertNotNull(stringWriter.getBuffer().toString());
    if (stringWriter.getBuffer().toString().length() < 1) {
        fail("generated xml is empty");
    }
    // read
    XMLResource outResource = (XMLResource) resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
    outResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8");
    outResource.setEncoding("UTF-8");
    Map<String, Object> options = new HashMap<String, Object>();
    options.put(XMLResource.OPTION_ENCODING, "UTF-8");
    InputStream is = new ByteArrayInputStream(stringWriter.getBuffer().toString().getBytes("UTF-8"));
    outResource.load(is, options);
    DocumentRoot outRoot = (DocumentRoot) outResource.getContents().get(0);
    assertNotNull(outRoot.getBPSimData());
    BPSimDataType outAnalysisData = outRoot.getBPSimData();
    assertEquals(outAnalysisData.getScenario().size(), 1);
    Scenario outScenario = outAnalysisData.getScenario().get(0);
    assertEquals(outScenario.getElementParameters().size(), 1);
    assertEquals(outScenario.getId(), "default");
    assertEquals(outScenario.getName(), "Scenario");
    assertNotNull(outScenario.getScenarioParameters());
    assertNotNull(outScenario.getElementParameters());
    assertEquals(outScenario.getElementParameters().size(), 1);
    ElementParameters outElementParamType = outScenario.getElementParameters().get(0);
    assertNotNull(outElementParamType.getTimeParameters());
    TimeParameters outTimeParams = outElementParamType.getTimeParameters();
    assertNotNull(outTimeParams.getProcessingTime());
    assertEquals(outTimeParams.getProcessingTime().getParameterValue().size(), 1);
    UniformDistributionType outDistributionType = (UniformDistributionType) outTimeParams.getProcessingTime().getParameterValue().get(0);
    assertEquals(outDistributionType.getMax(), 600.0);
    assertEquals(outDistributionType.getMin(), 180.0);
}
Also used : UniformDistributionType(bpsim.UniformDistributionType) ElementParameters(bpsim.ElementParameters) HashMap(java.util.HashMap) DocumentRoot(bpsim.DocumentRoot) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource) Scenario(bpsim.Scenario) StringWriter(java.io.StringWriter) ByteArrayInputStream(java.io.ByteArrayInputStream) ScenarioParameters(bpsim.ScenarioParameters) Parameter(bpsim.Parameter) BPSimDataType(bpsim.BPSimDataType) TimeParameters(bpsim.TimeParameters)

Example 15 with TimeParameters

use of bpsim.TimeParameters in project jbpm by kiegroup.

the class ElementParametersImpl method basicSetTimeParameters.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetTimeParameters(TimeParameters newTimeParameters, NotificationChain msgs) {
    TimeParameters oldTimeParameters = timeParameters;
    timeParameters = newTimeParameters;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, BpsimPackage.ELEMENT_PARAMETERS__TIME_PARAMETERS, oldTimeParameters, newTimeParameters);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) TimeParameters(bpsim.TimeParameters)

Aggregations

TimeParameters (bpsim.TimeParameters)15 Parameter (bpsim.Parameter)13 UniformDistributionType (bpsim.UniformDistributionType)13 NormalDistributionType (bpsim.NormalDistributionType)12 PoissonDistributionType (bpsim.PoissonDistributionType)12 CostParameters (bpsim.CostParameters)8 ElementParameters (bpsim.ElementParameters)8 FloatingParameterType (bpsim.FloatingParameterType)7 EObject (org.eclipse.emf.ecore.EObject)6 ParameterValue (bpsim.ParameterValue)5 ResourceParameters (bpsim.ResourceParameters)5 ArrayList (java.util.ArrayList)5 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)5 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)5 DecimalFormat (java.text.DecimalFormat)4 List (java.util.List)4 Assignment (org.eclipse.bpmn2.Assignment)4 DataInput (org.eclipse.bpmn2.DataInput)4 DataInputAssociation (org.eclipse.bpmn2.DataInputAssociation)4 DataOutput (org.eclipse.bpmn2.DataOutput)4