41
Building Industrial- Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

  • View
    220

  • Download
    3

Embed Size (px)

Citation preview

Page 1: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Building Industrial-Sized Models and Performance Analysis

Lisa Wells

CPN Workshop 2004CPN Tools Tutorial, Session 3October 8, 2004

Page 2: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial2

Plan

Building industrial-sized models Introduction to an industrial-sized model Presenting models to non-CPN experts Tips and tricks when building large models

Simulation-based performance analysis Introduction to small queue system Collecting data from markings and transitions Running multiple simulations (Comparing different model configurations) Implementation status

Page 3: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial3

Danfoss project

Danfoss is developing new frequency converters, which are used to control the speed of motors, e.g. for cranes, elevators and conveyor belts.

The frequency converters contain safety-critical software which is to be certified as safe.

Three issues: Use semi-formal methods to

define safety requirements. Ensure that the

requirements are complete. Validate that software fulfills

safety requirements.

Page 4: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial4

Safety-related functionality

Designated safety functions (DSFs) are used to control or stop the motor.

There are four kinds of safety functions: Uncontrolled stop – the motor is stopped immediately. Controlled stop – the motor is stopped after a delay. Safe ramp – the speed of the motor is gradually slowed. Speed limit – the motor is stopped if a certain speed is exceeded.

Safety functions are activated by request from users, either via digital inputs or field bus.

Danfoss must show that the frequency converter will always recognize requests for safety functions, and subsequently limit the speed or stop the motor.

Page 5: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial5

System-level safety requirements System-level safety requirements were available at the

start of the project. The requirements were expressed as an informal

Statechart model. Important states:

Power-up Normal operation DSF activated Safe-end Fail state

Page 6: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial6

Power-up/Self-test

Normal operation

Fail-safe

Safe end state

Safe stop

No dangerous failure

1c

3

4

59a

11

12

13

2

1b

1a

14

Safe delayactivated

6aSafe delayinactive

6b

6c

Safe ramp downactivated

7aSafe

ramp downinactive

7b

7c

Safe speed limitactivated

8aSafe

speed limitinactive

8b

8c

DSF activated

10aPower

removalinactive

9b

10b

System-level statechart

Page 7: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial7

Multiple microprocessors

Safety functions were to be implemented in software that must run on two microprocessors.

The two microprocessors must regularly synchronize and coordinate diagnostic checks.

One goal of the project was to formally define safety requirements down to the level of the microprocessors.

Page 8: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial8

Block-level diagram of hardware

Motor

PWMGenerator

uP1

uP2Power

Electronics

Switch off 1

Switch off 2

Feedback 1

Feedback 2Speed Info 1

Mai

ns

Digital Input 1

Digital Input 2

Speed Info 2

n

n

u, v, w

Frequency Converter

CHANNEL 1

CHANNEL 2

Cro

ssC

omm

unic

atio

n

Fieldbus

Safe Board Control Board

Pow

er B

oard

Page 9: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial9

Block-level safety requirements The behaviour of each microprocessor should fulfill the

requirements described by the system-level statechart. The requirements needed to be formalized, e.g. with

proper definitions of event triggers rather than simple text sentences.

The synchronization between the microprocessors had to be specified.

Coordination of diagnostics also needed to be defined. This is were CPN came in…

Page 10: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial10

CPN and system requirements Certification authorities require

that semi-formal methods must be used to describe system safety requirements.

A CPN model constituted one specification of system safety requirements.

Simulation and state space analysis were used to find ambiguities and problems with the specification.

Page 11: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial11

The project team

The project team had two CPN experts, one person who was familiar with CPN, and two people who had never seen CP-nets.

There was no time (or need) to teach the non-CPN experts about declarations and inscriptions, but it was sufficient to explain the meaning of places, tokens, and transitions.

One of the challenges of the project was to develop a CP-net that was both sufficiently detailed and understandable by all.

Page 12: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial12

The structure of the model

The model of the frequency converter contains several levels of hierarchy.

Only the bottom-most pages contain regular transitions. Each page contains only one or two transitions. The state of the frequency converter is encoded in token

values of tokens on few places, rather than moving a token between a number of places.

Page names represented domain-specific events. The highlighting of pages with enabled transitions made

it possible to run, discuss, and investigate system behaviour without having to look at CP-net structure.

Page 13: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial13

Frequency converter model

Demo…

Page 14: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial14

Discussing models with non-CPN experts Avoid using CPN-specific terms, e.g. discuss states and

events rather than places, markings, and occurring binding elements.

Use domain-specific terms whenever possible – in page and node names, and token values.

Hide or avoid complex net structure and inscriptions Use animation facilities to completely hide the CP-net Attempt to show only high-level representations of the

system in question. Hide complex manipulation of token values in functions

with meaningful names.

Page 15: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial15

Plan

Building industrial-sized models Introduction to an industrial-sized model Presenting models to non-CPN experts Tips and tricks when building large models

Simulation-based performance analysis Introduction to small queue system Collecting data from markings and transitions Running multiple simulations (Comparing different model configurations) Implementation status

Page 16: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial16

Performance analysis using CPN CP-nets have the potential to be used to model and

analyze the performance, i.e. quantitative aspects, of systems.

In practice, there are very few studies using CPN for performance analysis.

This is due, in part, to lack of tool support.

Page 17: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial17

Example: simple queue system A single server processes jobs. If the server is busy when a job arrives, the job is added to a queue. Job inter-arrival times are independent and identically distributed

random variables. Similarly, for server processing times. Queuing strategy is FIFO.

ServerQueueJob arrival

Page 18: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial18

Queue system performance measures Performance measures of interest:

Expected average delay in queue Expected average queue length Expected utilization of the server

Simulate the system until n jobs have completed their delays in the queue.

The system can be modeled in CPN Tools, but it is currently very difficult to collect and process data.

Page 19: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial19

Performance facilities for CPN Tools High-level support for simulation-based performance

analysis is currently being implemented for CPN Tools. This includes support for:

Data collection during simulations Simulation output – statistics and log files Net-specific simulation stop criteria Running multiple simulations Comparing different model configurations

Page 20: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial20

Data collection functions

For each performance measure, functions are used to determine when to collect data and which data to collect. Predicate function Observation function

The functions can inspect the markings and occurring transitions during a simulation.

These functions can be used to, e.g. Count tokens Extract data from token values Count transition occurrences Extract data from variable bindings

Page 21: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial21

Data collection functions, cont. Three kinds of data collection functions will be available:

Pre-defined Parameterized Completely user-defined

Template SML code can be generated for these functions.

Users will usually have to write less than 5 lines of code. Currently, there is only support for generating template code for user-

defined functions.

fun pred (bindelem, System'QueueMark: Jobs ms) =

let

fun predBindElem (Arrivals’Arrive (instance, {jobs, job})) =

| predBindElem (Server’Start (instance, {jobs, job})) =

in

end

Page 22: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial22

Collecting data

The data collection functions are automatically activated after simulation steps: After every simulation step, or After every relevant transition has occurred

The collected data is handled appropriately. Additional functions are generated for, e.g.:

Opening, closing, and updating log files Initializing, calculating, and accessing statistics

Page 23: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial23

Estimating average queue delay Wish to calculate average queue delay for the first n jobs

in the queue. When a job arrives in the system, the time of its arrival

must be noted and saved. When a job leaves the queue, its queue delay is

equal to (current time – arrival time). Queue delays for jobs are not independent, since the

queue delay for jobi+1 depends on the delay of jobi if it was in the queue at the same time as jobi.

Page 24: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial24

Estimating average queue length Wish to calculate the time-

average queue length until n jobs have left the queue.

When calculating statistics, the length of the queue is weighted with a time interval.

Measure the length of the queue when the length changes.

The time-average queue length is equal to the area under an appropriate curve.

Page 25: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial25

Estimating server utilization

Wish to calculate the utilization of the server until n jobs have left the queue.

Use an indicator variable: server is busy => 1, server is idle => 0.

The utilization of the server is then equal to the area under an appropriate curve.

Page 26: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial26

Stopping a simulation

Would like to stop a simulation after n jobs have left the queue.

Currently, it is only possible to define a simulation stop criteria that is based on the number of steps that have been executed.

New stop criteria can Depend on model time Depend on markings or

transitions

Page 27: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial27

Simulation output

The data that is collected is numerical data, i.e. integers or reals.

Data can be saved in log files. Statistics can be calculated. Data can be plotted in graphs

– either on-the-fly during simulations or after a simulation has completed.

#data counter step time

0 1 0 0

0 2 1 0

0 3 4 548

1 4 5 579

0 5 7 595

1 6 8 697

2 7 9 710

3 8 10 848

Page 28: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial28

Collecting data during simulations Demo…

Page 29: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial29

Running multiple simulations

Running one simulation provides one estimate of performance measures.

Running multiple simulations will result in multiple estimates. Additional functions can be used to collect data from different

simulations (rather than from different steps in a simulation). There are also facilities for:

Running a given number of automatic simulations. Generating a status file for multiple simulations. Collecting data from independent, terminating simulations. Managing data files. Calculating confidence intervals for performance measures.

Page 30: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial30

Running multiple simulations

Demo…

Page 31: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial31

Comparing alternative configurations It is frequently necessary to compare alternative

configurations of a particular system. For example, in the queue system compare:

One fast server vs. two slow servers. FIFO queue vs. priority queue Uniformly vs. exponentially distributed inter-arrival times

Expect to have new facilities for Defining and changing model parameters Defining ranges of values for system parameters Running simulations of all possible configurations

Page 32: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial32

Paired-t confidence intervals

Performance measures from two system configurations can be compared using so-called paired-t confidence intervals.

The behavior of two configurations is significantly different if the paired-t confidence interval does not include 0.

The value of the confidence interval indicates which configuration is better (or worse).

Page 33: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial33

Random numbers in CPN Tools Random number generators are used to:

Create and choose bindings Generate random numbers from different probability distributions,

e.g. exponential, uniform, normal. Currently, different random numbers are used for every simulation. A fairer comparison of system configurations may be obtained if the

same random numbers can be used for each configuration Each configuration is subjected to the same experimental

conditions. More precise confidence intervals can often be obtained with

fewer or shorter simulations.

Page 34: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial34

Synchronizing random numbers Random numbers can be

synchronized so that a particular random number is used for the same purpose in simulations of different configurations.

Using synchronization, it is often possible to reduce the size of paired-t confidence intervals.

New facilities will support such synchronization.

Page 35: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial35

Development status – what’s done Can generate template code for monitoring functions

given lists of place and transition identifiers. Creation of net-specific breakpoints and data collectors

given syntactically correct functions. Functions are activated during automatic simulations. Ineffective activation during interactive simulations (files

opened and closed for each step).

Conclusion: The major components are implemented.

Page 36: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial36

Development status – what’s missing Full integration with the newest version of the simulator. Syntax check of predicate and observation functions. Definition of standard data collectors. Integration with CPN Tools GUI.

Conclusion: The facilities will not be useful until they are integrated with the GUI.

Page 37: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial37

GUI for performance facilities Tool palette for creating data collectors.

Data collectors can be created for single objects or groups of objects (on one page).

Page 38: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial38

Data collector tags

Tags are added to each object that is involved in data collection.

These tags are similar to hierarchy tags.

Tags can be used to navigate to the data collection functions

Page 39: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial39

Editing and viewing functions Data collection functions can be accessed in sheets and

the index

Page 40: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial40

Graphical feedback

Graphical feedback similar to feedback for regular declarations, e.g. dependency and error highlights.

Page 41: Building Industrial-Sized Models and Performance Analysis Lisa Wells CPN Workshop 2004 CPN Tools Tutorial, Session 3 October 8, 2004

Oct. 8, 2004 CPN Tools Tutorial41

Summary

Building large CP-nets is becoming easier with recent and coming new features.

It is always challenging to build CP-nets that are to be presented to non-CPN experts.

The basic components for performance analysis have been implemented.

The performance facilities will be difficult to use until there is a GUI for them.