
pm-simulation.7.0.0.Beta1.source-code.default.simulation.rules.drl Maven / Gradle / Ivy
/*
* Copyright 2015 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//created on: Aug 2, 2012
package simulation
//list any import classes here.
import org.jbpm.simulation.impl.events.*;
import java.util.Date;
import org.jbpm.simulation.AggregatedSimulationEvent;
import org.jbpm.simulation.impl.SystemOutLogger;
//declare any global variables here
global java.util.List simulation;
global SystemOutLogger logger;
declare ActivityName
name : String
type : String
id : String
end
rule "Insert activity names"
no-loop
salience 13
when
ActivitySimulationEvent( $name : activityName, $id : activityId )
not ActivityName( name == $name )
then
insert( new ActivityName( $name, "abstract", $id ) );
end
rule "Insert activity names for ht"
no-loop
salience 14
when
HumanTaskActivitySimulationEvent( $name : activityName, $id : activityId )
not ActivityName( name == $name )
then
insert( new ActivityName( $name, "ht", $id ) );
end
rule "Insert event names"
no-loop
salience 15
when
EndSimulationEvent( $name : activityName, $id : activityId )
not ActivityName( name == $name )
then
insert( new ActivityName( $name, "event", $id ) );
end
rule "Calculate average duration for activity"
salience 20
no-loop
when
ActivityName($name : name, type=="abstract", $id : id)
accumulate(
ActivitySimulationEvent($duration : duration, activityName == $name, $type : type ),
$min : min( $duration ),
$avg : average( $duration ),
$max : max( $duration ),
$count : count( $duration ) )
then
logger.log("Duration for activity " + $name + " is avg: " + $avg + "; min: " + $min + "; max:" + $max + " count " + $count);
simulation.add(new AggregatedActivitySimulationEvent($name, $id, (Double)$min, (Double)$avg, (Double)$max, (Long)$count, ""));
end
rule "Calculate average duration for human activity"
salience 25
no-loop
when
ActivityName($name : name, type == "ht", $id : id)
accumulate(
HumanTaskActivitySimulationEvent($waitTime : waitTime, activityName == $name ),
$minwt : min( $waitTime ),
$avgwt : average( $waitTime ),
$maxwt : max( $waitTime ) )
accumulate(
HumanTaskActivitySimulationEvent($duration : duration, activityName == $name ),
$min : min( $duration ),
$avg : average( $duration ),
$max : max( $duration ),
$count : count( $duration ) )
accumulate(
HumanTaskActivitySimulationEvent($resourceUtilization : resourceUtilization, activityName == $name ),
$minru : min( $resourceUtilization ),
$avgru : average( $resourceUtilization ),
$maxru : max( $resourceUtilization ) )
accumulate(
HumanTaskActivitySimulationEvent($resourceCost : resourceCost, activityName == $name ),
$minrc : min( $resourceCost ),
$avgrc : average( $resourceCost ),
$maxrc : max( $resourceCost ) )
then
logger.log("Duration for human activity " + $name + " is avg: " + $avg + "; min: " + $min + "; max:"
+ $max + " is avgwt: " + $avgwt + "; minwt: " + $minwt + "; maxwt:" + $maxwt
+ " is avgru: " + $avgru + "; minru: " + $minru + "; maxru:" + $maxru + " count " + $count + " avg cost " + $avgrc + " min cost " + $minrc + " max cost " + $maxrc);
simulation.add(new HTAggregatedSimulationEvent($name, $id, (Double)$min, (Double)$avg, (Double)$max, (Double)$minwt, (Double)$avgwt, (Double)$maxwt,
(Double)$minru, (Double)$avgru, (Double)$maxru, (Long)$count, (Double)$avgrc, (Double)$minrc, (Double)$maxrc, "userTask"));
end
rule "Calculate end event duration"
salience 100
no-loop
when
ActivityName($name : name, type == "event", $id : id)
accumulate(
EndSimulationEvent($processDuration : processDuration),
$min : min( $processDuration ),
$avg : average( $processDuration ),
$max : max( $processDuration ),
$count : count( $processDuration ) )
then
logger.log("Duration for end event is avg: " + $avg + "; min: " + $min + "; max:" + $max);
AggregatedEndEventSimulationEvent aggEvent = new AggregatedEndEventSimulationEvent($name, $id, (Double)$min, (Double)$avg, (Double)$max, (Long)$count, "endEvent");
simulation.add(aggEvent);
end
rule "Calculate average duration for process"
salience 3
no-loop
when
accumulate(
ProcessInstanceEndSimulationEvent($pathId : pathId, $duration : processDuration, $processId : processId, $processName : processName, $processVersion : processVersion),
$min : min( $duration ),
$avg : average( $duration ),
$max : max( $duration ),
$processSet : collectSet($processId+"@"+$processName+"@"+$processVersion),
$pathIds : collectList($pathId) )
eval($processSet.size() > 0)
then
logger.log("Duration for processs is avg: " + $avg + "; min: " + $min + "; max:" + $max + " " + $processSet);
AggregatedProcessSimulationEvent aggEvent = new AggregatedProcessSimulationEvent($processSet, (Double)$min, (Double)$avg, (Double)$max);
aggEvent.calculatePaths($pathIds);
simulation.add(aggEvent);
end
© 2015 - 2025 Weber Informatics LLC | Privacy Policy