D: Diverter Block.
MJMcCann-Consulting

Petri-Net component with randomizable routing.
MJMcCann-Consulting Logo

D: Diverter. Version for APN4
PetriNet component similar to the A:Activity type.
Originally intended to model an inspection process where some fraction of the items going through would be set aside, its normal action, at the appropriate time, is to send items through to the output Cn, BUT, with probablility defined by the input value from the Bn connection (and bb), it might send them to the output Dn. Thus, since the items can be tokens permitting other events, the probability that some event will occur can be controlled by passing a token that permits the event.

It has another mode of behaviour in which it uses the probability value to represent a fraction diverted to connection Dn. This mode is triggered by specifying a negative value for the probability and then its absolute value becomes the fraction delivered to connection Dn.
The default behaviour is to take single tokens and deliver single tokens with a constant delay time: the basic PetriNet idea.

There is ONLY one input connection, An, and whatever is taken from An (see 'Take Rules' below) is stored in the block
Probability (or diversion fraction) is forced into the range 0 to 1.
It won't deliver to either recipient block if either is blocked.
When occupied, the output value, Vn, is the next transition time.

Application Ideas
To provide a regular (not random) diversion, such as for every Nth item, then use a combination of counters and activity blocks as shown in the Demo model "Diverter_1_in_N.txt"
It can be used to split production streams by putting materials into a container (or integrator) then with the D-block immediately (zero delay if you wish) take them and use the splitting mode to put the specified fraction in the output block Dn (container or integrator) and the rest carries on to container Cn.
If the D-block is being used for random diversions, then simply using the negation of the probability, it will give long run averages.

Take Rules
Any positive 'aa' value will have to be available in the container An for a pick-up to be made and that specified quantity will be taken from the container. It does not have to be an integer amount.
For example, it can take a specific amount out of a heap of material being accumulated in an integrator.
Any negative "aa" values will tell the Block to check that there is something available and then take as much as it can up to the amount specified by the absolute value of aa.
Whatever is taken from An is placed in store in the D-Block and depending on the Put rules in use it can be delivered to the selected recipient block, Cn or Dn (or be split, part to each, if that is the mode of behaviour).
The put rules will be applied at the last possible moment; not decided until then. If random choice is used then it is a new random number every time it's checked.

Put Rules
Any positive "cc" or "dd" value will cause that quantity to be put into the container Block-Cn or Block-Dn respectively (if connected), provided there is something in the store AND provided that both receiving containers could accept their intended inputs. Note that "cc" does not have to be the same as "dd" nor the same as "aa". For example, an amount, e.g.50kg, taken from a store to represent a sack full of material can appear delivered as a unit (one sack) amount.
In diverter mode, any negative "cc" or "dd" value puts an upper bound on the amount to be delivered and will cause the contents of store to be put in the corresponding recipient container (if connected and if there is room) up to the amount represented by the absolute value of "cc" or "dd". Thus, making "cc" or "dd" the same as "aa", will result in a delivery into Block-Cn or Block-Dn of whatever was taken from Block-An.

In splitter mode, the same rules apply to the delivered outputs but the test for the amount of space needed will be based on the value of the fraction to be split off as it is then defined.Because it can be defined by Bn, it can be changed right up to the moment of delivery.

===============================

D: Diverter Block Code
Procedure ActivateD(ii:integer); //DIVERTER
// A=input source,B=Fraction to Divert to D, C,D outputs,
var initialState, Split :integer;
ProbDiv, AvailA, DropC, DropD : real;
begin
with B[ii] do begin
Split:=0; //default is to act as Diverter not to Split between outputs.
initialstate:=state; // in case it changes
if OnOff<=0 then begin Vn:=Vn+Delt; exit end; //switched off, let anything inside wait
if((State=0)OR(State=1)) then begin {for empty states in this block}
AvailA:=isAvail(An,aa);
if (AvailA>0) then begin //isAvail() has checked that An is type C or I.
Take(An,AvailA); //IsAvail has checked block number is OK
Store[1]:=AvailA; // save the amount in Store[1].
State:=2; Vn:=NextE
ventTime(B[Pn].Vn+pp)
end {if available};
end{State started empty};
// note state may now have changed to 2, so Zero time delay generates immediate action.
if (Time+TinyDelt>=Vn) then //it's time to dump stuff
if ((State=2)OR(State=3)) then begin {for OCCUPIED states}
ProbDiv:= B[Bn].Vn+bb; //to decide probability of diversion or share of Split to D.
if (ProbDiv<0) then Split:= 1; //will split store contents rather than divert all.
ProbDiv:=max(0,min(1,abs(ProbDiv))); //keep value between <0,1>.
DropC:= cc; DropD:= dd; //default values will be used if they're positive
case Split of
0: begin// divert randomly to D when space available either C or D
if cc<0 then DropC := min(Store[1],-cc); // neg value puts bound on Drop size.
if dd<0 then DropD := min(Store[1],-dd); // neg value puts bound on Drop size.
if isRoom(Dn,DropD) AND isRoom(Cn,DropC) then begin
if (random<=ProbDiv) then Put(Dn,DropD) else Put(Cn,DropC);
Store[1]:=0; State:=1;
end //if isRoom
else State:=3; //state 3 used to flag blocked condition for display
end;
1: begin // divide store in proportion to ProbDiv.
if dd<0 then DropD := min(Store[1]*ProbDiv,-dd);
if cc<0 then DropC := min(Store[1]*(1-ProbDiv),-cc);
if isRoom(Dn,DropD) AND isRoom(Cn,DropC) then begin
Put(Dn,DropD); Put(Cn,DropC);
Store[1] := 0; State:=1; end //if isRoom
else State:=3; //state 3 used to flag blocked condition for display
end;
end //case Split
end{for OCCUPIED states};
if ((initialstate<>state) AND Animation ) then DisplayD(ii)
end{with B(ii)}
end;

MJMcCann-Consulting

Help Index:
Index/Search

Background
Simulation Concepts
Continuous Systems
Discrete Systems
McSimAPN Structure
McSimAPN Operation

Using McSimAPN
Start McSimAPN
Save Model,data
Create Blocks
Run-Hold-Reset
Link Excel+VBA

PetriNet Block Types
A activity/action
B belt conveyor
C container/constant
D diverter(random)

Analogue Block Types
E exponents
F flux/flow
G function Generator
H hysteresis
I integrator
J inductor
K logic element
L logarithms
M memory
N note/label
O oscilloscope/graph
p not assigned
Q quantizer/rounding
R relay on/off
S sin/asin/atan
T timer/clock
U user link Excel
V visual voltmeter
W sWitch selector/MUX
X multiply
y not assigned
Z random (fuZZ)
& signed summation
% division/difference
@ access/move values

Invitation. McCann can help if you have a design or operational problem that needs some technical support that is outside your team's experience, some quantitative assessment of what is really the cause of the difficulties, some design alternatives or just a fresh look by an intelligent interrogator.
If you have a problem with the behaviour of a market sector, plant, process or item of equipment and would like to get a quantitative handle on it to improve yield or optimise performance, then contact us. We are always ready to give a little time to discuss a new puzzle, in confidence, of course. We'll only worry about fees when we have some defined work. We can be flexible about how we work with you.
Top
MJMcCann-Consulting,
POB 902,
Chadds Ford PA
19317 USA.
T: 1 302 654-2953
F: 1 302 429 9458
E: mjmccann@iee.org
Request. Please let us know how you found this software and your interests by sending an email to mjmccann@iee.org Thank you Date: 2014.06.02
File: d.htm