Stochastic Transition with event.

within PNlib.Components;

model TES "Stochastic Transition with event"
  //****MODIFIABLE PARAMETERS AND VARIABLES BEGIN****//
  parameter Integer nIn(min = 0) = 0 "number of input places"
  parameter Integer nOut(min = 0) = 0 "number of output places"
  parameter PNlib.Types.DistributionType distributionType = PNlib.Types.DistributionType.Exponential "distribution type of event"
  parameter Real h = 1 "probability density"
  parameter Real a = 0 "Lower Limit"
  parameter Real b = 1 "Upper Limit"
  parameter Real c = 0.5 "Most likely value"
  parameter Real mu = 0.5 "Expected value"
  parameter Real sigma = 1/6 "Standard deviation"
  parameter Real E[:] = {1, 2, 3, 4, 5, 6} "Events of Discrete Distribution"
  parameter Real P[:] = {1/6, 1/6, 1/6, 1/6, 1/6, 1/6} "Probability of Discrete Distribution"
  Real arcWeightIn[nIn] = fill(1, nIn) "arc weights of input places"
  Real arcWeightOut[nOut] = fill(1, nOut) "arc weights of output places"
  Boolean firingCon = true "additional firing condition"
  //****MODIFIABLE PARAMETERS AND VARIABLES END****//
  discrete Real putFireTime "putative firing time";
  discrete Real putEvent "putative Event";
  Boolean showTransitionName = settings.showTransitionName "only for transition animation and display (Do not change!)";
  Boolean animatePutFireTime = settings.animatePutFireTime "only for transition animation and display (Do not change!)";
  Boolean animateHazardFunc = settings.animateHazardFunc "only for transition animation and display (Do not change!)";
  Real color[3] "only for transition animation and display (Do not change!)";
  parameter Integer localSeed = PNlib.Functions.Random.counter() "Local seed to initialize random number generator"
  Boolean TimeOver;
  Boolean active "Is the transition active?";
  Boolean fire "Does the transition fire?";
  PNlib.Interfaces.TransitionIn inPlaces[nIn](each active = eventPassed, arcWeight = arcWeightIn, arcWeightint = arcWeightIntIn, each fire = fire, each disTransition = true, each instSpeed = 0, each prelimSpeed = 0, each maxSpeed = 0, t = tIn, tint = tIntIn, arcType = arcType, minTokens = minTokens, minTokensint = minTokensInt, disPlace = disPlaceIn, enable = enableIn, tokenInOut = tokenInOut, testValue = testValue, testValueint = testValueInt, normalArc = normalArc) if nIn > 0 "connector for input places"
  PNlib.Interfaces.TransitionOut outPlaces[nOut](each active = eventPassed, arcWeight = arcWeightOut, arcWeightint = arcWeightIntOut, each fire = fire, each enabledByInPlaces = enabledByInPlaces, each disTransition = true, each instSpeed = 0, each prelimSpeed = 0, each maxSpeed = 0, t = tOut, tint = tIntOut, maxTokens = maxTokens, maxTokensint = maxTokensInt, disPlace = disPlaceOut, enable = enableOut) if nOut > 0 "connector for output places"
protected
  discrete Integer state128[4] "state of random number generator";
  Real r128 "random number";
  outer PNlib.Components.Settings settings "global settings for animation and display";
  discrete Real fireTime "for transition animation";
  Real tIn[nIn] "tokens of input places";
  Real tOut[nOut] "tokens of output places";
  Real minTokens[nIn] "minimum tokens of input places";
  Real maxTokens[nOut] "maximum tokens of output places";
  Real testValue[nIn] "test values of input arcs";
  Integer arcWeightIntIn[nIn] "Integer arc weights of discrete input places (for generating events!)";
  Integer arcWeightIntOut[nOut] "Integer arc weights of discrete output places (for generating events!)";
  Integer minTokensInt[nIn] "Integer minimum tokens of input places (for generating events!)";
  Integer maxTokensInt[nOut] "Integer maximum tokens of output places (for generating events!)";
  Integer tIntIn[nIn] "Integer tokens of input places (for generating events!)";
  Integer tIntOut[nOut] "Integer tokens of output places (for generating events!)";
  PNlib.Types.ArcType arcType[nIn] "type of input arcs 1=normal, 2=real test arc,  3=test arc, 4=real inhibitor arc, 5=inhibitor arc, 6=read arc";
  Integer testValueInt[nIn] "Integer test values of input arcs (for generating events!)";
  Boolean normalArc[nIn] "1=no, 2=yes, i.e. double arc: test and normal arc or inhibitor and normal arc";
  Boolean eventPassed(start = false, fixed = true) "Is the event passed?";
  Boolean ani "for transition animation";
  Boolean disPlaceIn[nIn] "Are the input places discrete or continuous? true=discrete";
  Boolean disPlaceOut[nOut] "Are the output places discrete or continuous? true=discrete";
  Boolean enableIn[nIn] "Is the transition enabled by input places?";
  Boolean enableOut[nOut] "Is the transition enabled by output places?";
  Boolean tokenInOut[nIn] "Have the tokens of input places changed?";
  //****BLOCKS BEGIN****// since no events are generated within functions!!!
  //activation process
  Blocks.activationDis activation(testValue = testValue, testValueInt = testValueInt, normalArc = normalArc, nIn = nIn, nOut = nOut, tIn = tIn, tOut = tOut, tIntIn = tIntIn, tIntOut = tIntOut, arcType = arcType, arcWeightIn = arcWeightIn, arcWeightIntIn = arcWeightIntIn, arcWeightOut = arcWeightOut, arcWeightIntOut = arcWeightIntOut, minTokens = minTokens, maxTokens = maxTokens, minTokensInt = minTokensInt, maxTokensInt = maxTokensInt, firingCon = firingCon, disPlaceIn = disPlaceIn, disPlaceOut = disPlaceOut);
  //Is the transition enabled by all input places?
  Boolean enabledByInPlaces = Functions.OddsAndEnds.allTrue(enableIn);
  //Is the transition enabled by all output places?
  Boolean enabledByOutPlaces = Functions.OddsAndEnds.allTrue(enableOut);
  //Has at least one input place changed its tokens?
  Blocks.anyTrue tokenChange(vec = tokenInOut);
  //****BLOCKS END****//
equation
  //****MAIN BEGIN****//
  //reset active when event passed
  active = activation.active and not pre(eventPassed);
  //event passed?
  eventPassed = active and time >= putFireTime;
  //firing process
  fire = if nOut == 0 then enabledByInPlaces else enabledByOutPlaces;
  //****MAIN END****//
  //****ANIMATION BEGIN****//
  when fire then
    fireTime = time;
    ani = true;
  end when;
  color = if (fireTime + settings.timeFire >= time and settings.animateTransition and ani) then {255, 255, 0} else {0, 0, 0};
  //****ANIMATION END****//
  //****ERROR MESSENGES BEGIN****//
  for i in 1:nIn loop
    if disPlaceIn[i] then
      arcWeightIntIn[i] = integer(arcWeightIn[i]);
    else
      arcWeightIntIn[i] = 1;
    end if;
    assert((disPlaceIn[i] and arcWeightIn[i] - arcWeightIntIn[i] <= 0.0) or not disPlaceIn[i], "Input arcs connected to discrete places must have integer weights.");
    assert(arcWeightIn[i] >= 0, "Input arc weights must be positive.");
  end for;
  for i in 1:nOut loop
    if disPlaceOut[i] then
      arcWeightIntOut[i] = integer(arcWeightOut[i]);
    else
      arcWeightIntOut[i] = 1;
    end if;
    assert((disPlaceOut[i] and arcWeightOut[i] - arcWeightIntOut[i] <= 0.0) or not disPlaceOut[i], "Output arcs connected to discrete places must have integer weights.");
    assert(arcWeightOut[i] >= 0, "Output arc weights must be positive.");
  end for;
  assert(h > 0 or distributionType <> PNlib.Types.DistributionType.Exponential, "The probability density must be greater than zero");
  assert((a < b and a <= c and c <= b) or distributionType <> PNlib.Types.DistributionType.Triangular, "The Lower Limit must be less than or equal to the Most likely value and the Most likely value must be less than or equal to the Upper Limit but he Lower Limit must be less than the Upper Limit");
  assert(a < b or distributionType <> PNlib.Types.DistributionType.Uniform, "The Lower Limit must be less than the Upper Limit");
  assert(Functions.OddsAndEnds.isEqual(sum(P), 1.0, 1e-6) or distributionType <> PNlib.Types.DistributionType.Discrete, "The Probability sum Probability of Discrete Distribution has to be equal to 1");
  assert(size(E, 1) == size(P, 1) or distributionType <> PNlib.Types.DistributionType.Discrete, "Discrete probability distribution must have the same number of events and probabilities");
  //****ERROR MESSENGES END****//
algorithm
  //****MAIN BEGIN****//
  TimeOver := time >= putFireTime;
  //generate random putative fire time according to Next-Reaction method of Gibson and Bruck
  when pre(TimeOver) then //17.06.11 Reihenfolge getauscht!
    (r128, state128) := Modelica.Math.Random.Generators.Xorshift128plus.random(pre(state128));
    if distributionType == PNlib.Types.DistributionType.Exponential then
      putEvent := PNlib.Functions.Random.randomexp(h, r128);
    elseif distributionType == PNlib.Types.DistributionType.Triangular then
      putEvent := PNlib.Functions.Random.randomtriangular(a, b, c, r128);
    elseif distributionType == PNlib.Types.DistributionType.Uniform then
      putEvent := Modelica.Math.Distributions.Uniform.quantile(max(r128, 10^(-10)), a, b);
    elseif distributionType == PNlib.Types.DistributionType.TruncatedNormal then
      putEvent := Modelica.Math.Distributions.TruncatedNormal.quantile(max(r128, 10^(-10)), a, b, mu, sigma);
    else
      putEvent := max(PNlib.Functions.Random.randomdis(E, P, r128), 1e-6);
    end if;
    putFireTime := time + putEvent;
  end when;
  //****MAIN END****//
initial equation
  //to initialize the random generator otherwise the first random number is always the same in every simulation run
  if distributionType == PNlib.Types.DistributionType.Exponential then
    putEvent = PNlib.Functions.Random.randomexp(h, r128);
  elseif distributionType == PNlib.Types.DistributionType.Triangular then
    putEvent = PNlib.Functions.Random.randomtriangular(a, b, c, r128);
  elseif distributionType == PNlib.Types.DistributionType.Uniform then
    putEvent = Modelica.Math.Distributions.Uniform.quantile(max(r128, 10^(-10)), a, b);
  elseif distributionType == PNlib.Types.DistributionType.TruncatedNormal then
    putEvent = Modelica.Math.Distributions.TruncatedNormal.quantile(max(r128, 10^(-10)), a, b, mu, sigma);
  else
    putEvent = max(PNlib.Functions.Random.randomdis(E, P, r128), 1e-6);
  end if;
  putFireTime = time + putEvent;
initial algorithm
  // Generate initial state from localSeed and globalSeed
  state128 := Modelica.Math.Random.Generators.Xorshift128plus.initialState(localSeed, settings.globalSeed);
  (r128, state128) := Modelica.Math.Random.Generators.Xorshift128plus.random(state128);
end TES;


Discrete Transition with fire duration.

within PNlib.Components;

model TFD "Discrete Transition with fire duration"
  parameter Integer nIn(min = 0) = 0 "number of input places"
  parameter Integer nOut(min = 0) = 0 "number of output places"
  //****MODIFIABLE PARAMETERS AND VARIABLES BEGIN****//
  Real duration = 1 "duration of timed transition"
  Real arcWeightIn[nIn] = fill(1, nIn) "arc weights of input places"
  Real arcWeightOut[nOut] = fill(1, nOut) "arc weights of output places"
  Boolean firingCon = true "additional firing condition"
  //****MODIFIABLE PARAMETERS AND VARIABLES END****//
  Boolean activeIn "Is the transition Input active?";
  Boolean activeOut "Is the transition Output active?";
  Boolean fireIn "Does the transition Input fire?";
  Boolean fireOut "Does the transition Output fire?";
  Boolean fire(start = false, fixed = true) "Is the Transition fire?";
  PNlib.Interfaces.TransitionIn inPlaces[nIn](each active = durationPassedIn, arcWeight = arcWeightIn, arcWeightint = arcWeightIntIn, each fire = fireIn, each disTransition = true, each instSpeed = 0, each prelimSpeed = 0, each maxSpeed = 0, t = tIn, tint = tIntIn, arcType = arcType, minTokens = minTokens, minTokensint = minTokensInt, disPlace = disPlaceIn, enable = enableIn, testValue = testValue, testValueint = testValueInt, normalArc = normalArc) if nIn > 0 "connector for input places"
  PNlib.Interfaces.TransitionOut outPlaces[nOut](each active = durationPassedOut, arcWeight = arcWeightOut, arcWeightint = arcWeightIntOut, each fire = fireOut, each enabledByInPlaces = true, each disTransition = true, each instSpeed = 0, each prelimSpeed = 0, each maxSpeed = 0, t = tOut, tint = tIntOut, maxTokens = maxTokens, maxTokensint = maxTokensInt, disPlace = disPlaceOut, enable = enableOut) if nOut > 0 "connector for output places"
protected
  outer PNlib.Components.Settings settings "global settings for animation and display";
  Boolean showTransitionName = settings.showTransitionName "only for transition animation and display (Do not change!)";
  Boolean showDuration = settings.showTime "only for transition animation and display (Do not change!)";
  Real color[3] "only for transition animation and display (Do not change!)";
  Real tIn[nIn] "tokens of input places";
  Real tOut[nOut] "tokens of output places";
  Real testValue[nIn] "test values of input arcs";
  Real firingTimeIn "next putative firing time";
  Real firingTimeOut "next putative firing time";
  Real fireTime "for transition animation";
  Real minTokens[nIn] "minimum tokens of input places";
  Real maxTokens[nOut] "maximum tokens of output places";
  Real duration_ = if duration < 1e-6 then 1e-6 else duration "due to event problems if duration==0";
  Integer tIntIn[nIn] "integer tokens of input places (for generating events!)";
  Integer tIntOut[nOut] "integer tokens of output places (for generating events!)";
  PNlib.Types.ArcType arcType[nIn] "type of input arcs 1=normal, 2=real test arc,  3=test arc, 4=real inhibitor arc, 5=inhibitor arc, 6=read arc";
  Integer arcWeightIntIn[nIn] "Integer arc weights of discrete input places (for generating events!)";
  Integer arcWeightIntOut[nOut] "Integer arc weights of discrete output places (for generating events!)";
  Integer minTokensInt[nIn] "Integer minimum tokens of input places (for generating events!)";
  Integer maxTokensInt[nOut] "Integer maximum tokens of output places (for generating events!)";
  Integer testValueInt[nIn] "Integer test values of input arcs (for generating events!)";
  Boolean normalArc[nIn] "1=no, 2=yes, i.e. double arc: test and normal arc or inhibitor and normal arc";
  Boolean disPlaceIn[nIn] "Are the input places discrete or continuous? true=discrete";
  Boolean disPlaceOut[nOut] "Are the output places discrete or continuous? true=discrete";
  Boolean enableIn[nIn] "Is the transition enabled by input places?";
  Boolean enableOut[nOut] "Is the transition enabled by output places?";
  Boolean durationPassedIn(start = false, fixed = true) "Is the duration passed?";
  Boolean durationPassedOut(start = false, fixed = true) "Is the duration passed?";
  Boolean ani "for transition animation";
  Boolean prefire(start = false, fixed = true) "Was the Transition fire?";
  //****BLOCKS BEGIN****// since no events are generated within functions!!!
  //activation process
  Blocks.activationDisIn activationIn(testValue = testValue, testValueInt = testValueInt, normalArc = normalArc, nIn = nIn, tIn = tIn, tIntIn = tIntIn, arcType = arcType, arcWeightIn = arcWeightIn, arcWeightIntIn = arcWeightIntIn, minTokens = minTokens, minTokensInt = minTokensInt, firingCon = firingCon, disPlaceIn = disPlaceIn);
  Blocks.activationDisOut activationOut(nOut = nOut, tOut = tOut, tIntOut = tIntOut, arcWeightOut = arcWeightOut, arcWeightIntOut = arcWeightIntOut, maxTokens = maxTokens, maxTokensInt = maxTokensInt, firingCon = firingCon, disPlaceOut = disPlaceOut);
  //Is the transition enabled by all input places?
  Boolean enabledByInPlaces = Functions.OddsAndEnds.allTrue(enableIn);
  //Is the transition enabled by all output places?
  Boolean enabledByOutPlaces = Functions.OddsAndEnds.allTrue(enableOut);
  //****BLOCKS END****//
equation
  //****MAIN BEGIN****//
  //reset active when duration passed
  activeIn = activationIn.active and not pre(durationPassedIn) and not prefire;
  activeOut = activationOut.active and not pre(durationPassedOut) and prefire;
  //save next putative firing time
  when activeIn then
    firingTimeIn = time + 1e-6;
  end when;
  when activeOut then
    firingTimeOut = if time >= firingTimeIn + duration_ - 1e-6 then time + 1e-6 else firingTimeIn + duration_ - 1e-6;
  end when;
  //is the Transition fire?
  prefire = pre(fire);
  when {fireIn, fireOut} then
    if durationPassedOut then
      fire = false;
    else
      fire = true;
    end if;
  end when;
  //duration passed?
  durationPassedIn = activeIn and time >= firingTimeIn;
  durationPassedOut = activeOut and time >= firingTimeOut;
  //firing process
  fireIn = enabledByInPlaces;
  fireOut = enabledByOutPlaces;
  //****MAIN END****//
  //****ANIMATION BEGIN****//
  when fireIn then
    fireTime = time;
    ani = true;
  end when;
  color = if (fireTime + settings.timeFire >= time and settings.animateTransition and ani) then {255, 255, 0} else {0, 0, 0};
  //****ANIMATION END****//
  //****ERROR MESSENGES BEGIN****//
  for i in 1:nIn loop
    if disPlaceIn[i] then
      arcWeightIntIn[i] = integer(arcWeightIn[i]);
    else
      arcWeightIntIn[i] = 1;
    end if;
    assert((disPlaceIn[i] and arcWeightIn[i] - arcWeightIntIn[i] <= 0.0) or not disPlaceIn[i], "Input arcs connected to discrete places must have integer weights.");
    assert(arcWeightIn[i] >= 0, "Input arc weights must be positive.");
  end for;
  for i in 1:nOut loop
    if disPlaceOut[i] then
      arcWeightIntOut[i] = integer(arcWeightOut[i]);
    else
      arcWeightIntOut[i] = 1;
    end if;
    assert((disPlaceOut[i] and arcWeightOut[i] - arcWeightIntOut[i] <= 0.0) or not disPlaceOut[i], "Output arcs connected to discrete places must have integer weights.");
    assert(arcWeightOut[i] >= 0, "Output arc weights must be positive.");
  end for;
  //****ERROR MESSENGES END****//
end TFD;


Stochastic Transition with fire duration.

within PNlib.Components;

model TFDS "Stochastic Transition with fire duration"
  //****MODIFIABLE PARAMETERS AND VARIABLES BEGIN****//
  parameter Integer nIn(min = 0) = 0 "number of input places"
  parameter Integer nOut(min = 0) = 0 "number of output places"
  parameter PNlib.Types.DistributionType distributionType = PNlib.Types.DistributionType.Exponential "distribution type of duration"
  parameter Real h = 1 "probability density"
  parameter Real a = 0 "Lower Limit"
  parameter Real b = 1 "Upper Limit"
  parameter Real c = 0.5 "Most likely value"
  parameter Real mu = 0.5 "Expected value"
  parameter Real sigma = 1/6 "Standard deviation"
  parameter Real E[:] = {1, 2, 3, 4, 5, 6} "Events of Discrete Distribution"
  parameter Real P[:] = {1/6, 1/6, 1/6, 1/6, 1/6, 1/6} "Probability of Discrete Distribution"
  Real arcWeightIn[nIn] = fill(1, nIn) "arc weights of input places"
  Real arcWeightOut[nOut] = fill(1, nOut) "arc weights of output places"
  Boolean firingCon = true "additional firing condition"
  //****MODIFIABLE PARAMETERS AND VARIABLES END****//
  discrete Real putDuration "putative firing time";
  Boolean showTransitionName = settings.showTransitionName "only for transition animation and display (Do not change!)";
  Boolean animateputDuration = settings.animatePutFireTime "only for transition animation and display (Do not change!)";
  Boolean animateHazardFunc = settings.animateHazardFunc "only for transition animation and display (Do not change!)";
  Real color[3] "only for transition animation and display (Do not change!)";
  parameter Integer localSeed = PNlib.Functions.Random.counter() "Local seed to initialize random number generator"
  Boolean activeIn "Is the transition Input active?";
  Boolean activeOut "Is the transition Output active?";
  Boolean fireIn "Does the transition Input fire?";
  Boolean fireOut "Does the transition Output fire?";
  Boolean fire(start = false, fixed = true) "Is the Transition fire?";
  PNlib.Interfaces.TransitionIn inPlaces[nIn](each active = durationPassedIn, arcWeight = arcWeightIn, arcWeightint = arcWeightIntIn, each fire = fireIn, each disTransition = true, each instSpeed = 0, each prelimSpeed = 0, each maxSpeed = 0, t = tIn, tint = tIntIn, arcType = arcType, minTokens = minTokens, minTokensint = minTokensInt, disPlace = disPlaceIn, enable = enableIn, tokenInOut = tokenInOut, testValue = testValue, testValueint = testValueInt, normalArc = normalArc) if nIn > 0 "connector for input places"
  PNlib.Interfaces.TransitionOut outPlaces[nOut](each active = durationPassedOut, arcWeight = arcWeightOut, arcWeightint = arcWeightIntOut, each fire = fireOut, each enabledByInPlaces = true, each disTransition = true, each instSpeed = 0, each prelimSpeed = 0, each maxSpeed = 0, t = tOut, tint = tIntOut, maxTokens = maxTokens, maxTokensint = maxTokensInt, disPlace = disPlaceOut, enable = enableOut) if nOut > 0 "connector for output places"
protected
  discrete Integer state128[4] "state of random number generator";
  Real r128 "random number";
  outer PNlib.Components.Settings settings "global settings for animation and display";
  Real firingTimeIn "next putative firing time";
  Real firingTimeOut "next putative firing time";
  discrete Real fireTime "for transition animation";
  Real tIn[nIn] "tokens of input places";
  Real tOut[nOut] "tokens of output places";
  Real minTokens[nIn] "minimum tokens of input places";
  Real maxTokens[nOut] "maximum tokens of output places";
  Real testValue[nIn] "test values of input arcs";
  Integer arcWeightIntIn[nIn] "Integer arc weights of discrete input places (for generating events!)";
  Integer arcWeightIntOut[nOut] "Integer arc weights of discrete output places (for generating events!)";
  Integer minTokensInt[nIn] "Integer minimum tokens of input places (for generating events!)";
  Integer maxTokensInt[nOut] "Integer maximum tokens of output places (for generating events!)";
  Integer tIntIn[nIn] "Integer tokens of input places (for generating events!)";
  Integer tIntOut[nOut] "Integer tokens of output places (for generating events!)";
  PNlib.Types.ArcType arcType[nIn] "type of input arcs 1=normal, 2=test arc, 3=inhibitor arc, 4=read arc";
  Integer testValueInt[nIn] "Integer test values of input arcs (for generating events!)";
  Boolean normalArc[nIn] "1=no, 2=yes, i.e. double arc: test and normal arc or inhibitor and normal arc";
  Boolean durationPassedIn(start = false, fixed = true) "Is the duration passed?";
  Boolean durationPassedOut(start = false, fixed = true) "Is the duration passed?";
  Boolean ani "for transition animation";
  Boolean prefire(start = false, fixed = true) "Was the Transition fire?";
  Boolean disPlaceIn[nIn] "Are the input places discrete or continuous? true=discrete";
  Boolean disPlaceOut[nOut] "Are the output places discrete or continuous? true=discrete";
  Boolean enableIn[nIn] "Is the transition enabled by input places?";
  Boolean enableOut[nOut] "Is the transition enabled by output places?";
  Boolean tokenInOut[nIn] "Have the tokens of input places changed?";
  //****BLOCKS BEGIN****// since no events are generated within functions!!!
  //activation process
  Blocks.activationDisIn activationIn(testValue = testValue, testValueInt = testValueInt, normalArc = normalArc, nIn = nIn, tIn = tIn, tIntIn = tIntIn, arcType = arcType, arcWeightIn = arcWeightIn, arcWeightIntIn = arcWeightIntIn, minTokens = minTokens, minTokensInt = minTokensInt, firingCon = firingCon, disPlaceIn = disPlaceIn);
  Blocks.activationDisOut activationOut(nOut = nOut, tOut = tOut, tIntOut = tIntOut, arcWeightOut = arcWeightOut, arcWeightIntOut = arcWeightIntOut, maxTokens = maxTokens, maxTokensInt = maxTokensInt, firingCon = firingCon, disPlaceOut = disPlaceOut);
  //Is the transition enabled by all input places?
  Boolean enabledByInPlaces = Functions.OddsAndEnds.allTrue(enableIn);
  //Is the transition enabled by all output places?
  Boolean enabledByOutPlaces = Functions.OddsAndEnds.allTrue(enableOut);
  //Has at least one input place changed its tokens?
  Blocks.anyTrue tokenChange(vec = tokenInOut);
  //****BLOCKS END****//
equation
  //****MAIN BEGIN****//
  //reset active when duration passed
  activeIn = activationIn.active and not pre(durationPassedIn) and not prefire;
  activeOut = activationOut.active and not pre(durationPassedOut) and prefire;
  //save next putative firing time
  when activeIn then
    firingTimeIn = time + 1e-6;
  end when;
  when activeOut then
    firingTimeOut = if time >= firingTimeIn + putDuration - 1e-6 then time + 1e-6 else firingTimeIn + putDuration - 1e-6;
  end when;
  //is the Transition fire?
  prefire = pre(fire);
  when {fireIn, fireOut} then
    if durationPassedOut then
      fire = false;
    else
      fire = true;
    end if;
  end when;
  //duration passed?
  durationPassedIn = activeIn and time >= firingTimeIn;
  durationPassedOut = activeOut and time >= firingTimeOut;
  //firing process
  fireIn = enabledByInPlaces;
  fireOut = enabledByOutPlaces;
  //****MAIN END****//
  //****ANIMATION BEGIN****//
  when fireIn then
    fireTime = time;
    ani = true;
  end when;
  color = if (fireTime + settings.timeFire >= time and settings.animateTransition and ani) then {255, 255, 0} else {0, 0, 0};
  //****ANIMATION END****//
  //****ERROR MESSENGES BEGIN****//
  for i in 1:nIn loop
    if disPlaceIn[i] then
      arcWeightIntIn[i] = integer(arcWeightIn[i]);
    else
      arcWeightIntIn[i] = 1;
    end if;
    assert((disPlaceIn[i] and arcWeightIn[i] - arcWeightIntIn[i] <= 0.0) or not disPlaceIn[i], "Input arcs connected to discrete places must have integer weights.");
    assert(arcWeightIn[i] >= 0, "Input arc weights must be positive.");
  end for;
  for i in 1:nOut loop
    if disPlaceOut[i] then
      arcWeightIntOut[i] = integer(arcWeightOut[i]);
    else
      arcWeightIntOut[i] = 1;
    end if;
    assert((disPlaceOut[i] and arcWeightOut[i] - arcWeightIntOut[i] <= 0.0) or not disPlaceOut[i], "Output arcs connected to discrete places must have integer weights.");
    assert(arcWeightOut[i] >= 0, "Output arc weights must be positive.");
  end for;
  assert(h > 0 or distributionType <> PNlib.Types.DistributionType.Exponential, "The probability density must be greater than zero");
  assert((a < b and a <= c and c <= b) or distributionType <> PNlib.Types.DistributionType.Triangular, "The Lower Limit must be less than or equal to the Most likely value and the Most likely value must be less than or equal to the Upper Limit but he Lower Limit must be less than the Upper Limit");
  assert(a < b or distributionType <> PNlib.Types.DistributionType.Uniform, "The Lower Limit must be less than the Upper Limit");
  assert(Functions.OddsAndEnds.isEqual(sum(P), 1.0, 1e-6) or distributionType <> PNlib.Types.DistributionType.Discrete, "The Probability sum Probability of Discrete Distribution has to be equal to 1");
  assert(size(E, 1) == size(P, 1) or distributionType <> PNlib.Types.DistributionType.Discrete, "Discrete probability distribution must have the same number of events and probabilities");
  //****ERROR MESSENGES END****//
algorithm
  //****MAIN BEGIN****//
  //generate random putative fire time according to Next-Reaction method of Gibson and Bruck
  when pre(fireOut) then //17.06.11 Reihenfolge getauscht!
    (r128, state128) := Modelica.Math.Random.Generators.Xorshift128plus.random(pre(state128));
    if distributionType == PNlib.Types.DistributionType.Exponential then
      putDuration := PNlib.Functions.Random.randomexp(h, r128);
    elseif distributionType == PNlib.Types.DistributionType.Triangular then
      putDuration := PNlib.Functions.Random.randomtriangular(a, b, c, r128);
    elseif distributionType == PNlib.Types.DistributionType.Uniform then
      putDuration := Modelica.Math.Distributions.Uniform.quantile(max(r128, 10^(-10)), a, b);
    elseif distributionType == PNlib.Types.DistributionType.TruncatedNormal then
      putDuration := Modelica.Math.Distributions.TruncatedNormal.quantile(max(r128, 10^(-10)), a, b, mu, sigma);
    else
      putDuration := max(PNlib.Functions.Random.randomdis(E, P, r128), 1e-6);
    end if;
  end when;
  //****MAIN END****//
initial equation
  //to initialize the random generator otherwise the first random number is always the same in every simulation run
  if distributionType == PNlib.Types.DistributionType.Exponential then
    putDuration = PNlib.Functions.Random.randomexp(h, r128);
  elseif distributionType == PNlib.Types.DistributionType.Triangular then
    putDuration = PNlib.Functions.Random.randomtriangular(a, b, c, r128);
  elseif distributionType == PNlib.Types.DistributionType.Uniform then
    putDuration = Modelica.Math.Distributions.Uniform.quantile(max(r128, 10^(-10)), a, b);
  elseif distributionType == PNlib.Types.DistributionType.TruncatedNormal then
    putDuration = Modelica.Math.Distributions.TruncatedNormal.quantile(max(r128, 10^(-10)), a, b, mu, sigma);
  else
    putDuration = max(PNlib.Functions.Random.randomdis(E, P, r128), 1e-6);
  end if;
initial algorithm
  // Generate initial state from localSeed and globalSeed
  state128 := Modelica.Math.Random.Generators.Xorshift128plus.initialState(localSeed, settings.globalSeed);
  (r128, state128) := Modelica.Math.Random.Generators.Xorshift128plus.random(state128);
end TFDS;


Discrete Transition.

within PNlib.Components;

model TT "Discrete Transition"
  parameter Integer nIn(min = 0) = 0 "number of input places"
  parameter Integer nOut(min = 0) = 0 "number of output places"
  //****MODIFIABLE PARAMETERS AND VARIABLES BEGIN****//
  parameter Real tactIntervall = 1 "tact intervall of timed transition"
  parameter Real tactStart = 1 "tact start of timed transition"
  Real arcWeightIn[nIn] = fill(1, nIn) "arc weights of input places"
  Real arcWeightOut[nOut] = fill(1, nOut) "arc weights of output places"
  Boolean firingCon = true "additional firing condition"
  //****MODIFIABLE PARAMETERS AND VARIABLES END****//
  Boolean active "Is the transition active?";
  Boolean fire "Does the transition fire?";
  PNlib.Interfaces.TransitionIn inPlaces[nIn](each active = tactPassed, arcWeight = arcWeightIn, arcWeightint = arcWeightIntIn, each fire = fire, each disTransition = true, each instSpeed = 0, each prelimSpeed = 0, each maxSpeed = 0, t = tIn, tint = tIntIn, arcType = arcType, minTokens = minTokens, minTokensint = minTokensInt, disPlace = disPlaceIn, enable = enableIn, testValue = testValue, testValueint = testValueInt, normalArc = normalArc) if nIn > 0 "connector for input places"
  PNlib.Interfaces.TransitionOut outPlaces[nOut](each active = tactPassed, arcWeight = arcWeightOut, arcWeightint = arcWeightIntOut, each fire = fire, each enabledByInPlaces = enabledByInPlaces, each disTransition = true, each instSpeed = 0, each prelimSpeed = 0, each maxSpeed = 0, t = tOut, tint = tIntOut, maxTokens = maxTokens, maxTokensint = maxTokensInt, disPlace = disPlaceOut, enable = enableOut) if nOut > 0 "connector for output places"
protected
  outer PNlib.Components.Settings settings "global settings for animation and display";
  Boolean showTransitionName = settings.showTransitionName "only for transition animation and display (Do not change!)";
  Boolean showTakt = settings.showTime "only for transition animation and display (Do not change!)";
  Real color[3] "only for transition animation and display (Do not change!)";
  Real tIn[nIn] "tokens of input places";
  Real tOut[nOut] "tokens of output places";
  Real testValue[nIn] "test values of input arcs";
  Real firingTime "next putative firing time";
  Real fireTime "for transition animation";
  Real minTokens[nIn] "minimum tokens of input places";
  Real maxTokens[nOut] "maximum tokens of output places";
  Integer tIntIn[nIn] "integer tokens of input places (for generating events!)";
  Integer tIntOut[nOut] "integer tokens of output places (for generating events!)";
  PNlib.Types.ArcType arcType[nIn] "type of input arcs 1=normal, 2=test arc, 3=inhibitor arc, 4=read arc";
  Integer arcWeightIntIn[nIn] "Integer arc weights of discrete input places (for generating events!)";
  Integer arcWeightIntOut[nOut] "Integer arc weights of discrete output places (for generating events!)";
  Integer minTokensInt[nIn] "Integer minimum tokens of input places (for generating events!)";
  Integer maxTokensInt[nOut] "Integer maximum tokens of output places (for generating events!)";
  Integer testValueInt[nIn] "Integer test values of input arcs (for generating events!)";
  Boolean normalArc[nIn] "1=no, 2=yes, i.e. double arc: test and normal arc or inhibitor and normal arc";
  Boolean disPlaceIn[nIn] "Are the input places discrete or continuous? true=discrete";
  Boolean disPlaceOut[nOut] "Are the output places discrete or continuous? true=discrete";
  Boolean enableIn[nIn] "Is the transition enabled by input places?";
  Boolean enableOut[nOut] "Is the transition enabled by output places?";
  Boolean tactPassed(start = false, fixed = true) "Is the tact passed?";
  Boolean ani "for transition animation";
  //****BLOCKS BEGIN****// since no events are generated within functions!!!
  //activation process
  Blocks.activationDis activation(testValue = testValue, testValueInt = testValueInt, normalArc = normalArc, nIn = nIn, nOut = nOut, tIn = tIn, tOut = tOut, tIntIn = tIntIn, tIntOut = tIntOut, arcType = arcType, arcWeightIn = arcWeightIn, arcWeightIntIn = arcWeightIntIn, arcWeightOut = arcWeightOut, arcWeightIntOut = arcWeightIntOut, minTokens = minTokens, maxTokens = maxTokens, minTokensInt = minTokensInt, maxTokensInt = maxTokensInt, firingCon = firingCon, disPlaceIn = disPlaceIn, disPlaceOut = disPlaceOut);
  //Is the transition enabled by all input places?
  Boolean enabledByInPlaces = Functions.OddsAndEnds.allTrue(enableIn);
  //Is the transition enabled by all output places?
  Boolean enabledByOutPlaces = Functions.OddsAndEnds.allTrue(enableOut);
  //****BLOCKS END****//
equation
  //****MAIN BEGIN****//
  active = activation.active;
  //save next putative firing time
  //due to event problems if tactStart==0
  when active and sample(max(tactStart, 10^(-8)), max(tactIntervall, 10^(-6))) then
    firingTime = time;
  end when;
  //tact passed?
  tactPassed = active and abs(time - firingTime) <= 10^(-9);
  //firing process
  fire = if nOut == 0 then enabledByInPlaces else enabledByOutPlaces;
  //****MAIN END****//
  //****ANIMATION BEGIN****//
  when fire then
    fireTime = time;
    ani = true;
  end when;
  color = if (fireTime + settings.timeFire >= time and settings.animateTransition and ani) then {255, 255, 0} else {0, 0, 0};
  //****ANIMATION END****//
  //****ERROR MESSENGES BEGIN****//
  for i in 1:nIn loop
    if disPlaceIn[i] then
      arcWeightIntIn[i] = integer(arcWeightIn[i]);
    else
      arcWeightIntIn[i] = 1;
    end if;
    assert((disPlaceIn[i] and arcWeightIn[i] - arcWeightIntIn[i] <= 0.0) or not disPlaceIn[i], "Input arcs connected to discrete places must have integer weights.");
    assert(arcWeightIn[i] >= 0, "Input arc weights must be positive.");
  end for;
  for i in 1:nOut loop
    if disPlaceOut[i] then
      arcWeightIntOut[i] = integer(arcWeightOut[i]);
    else
      arcWeightIntOut[i] = 1;
    end if;
    assert((disPlaceOut[i] and arcWeightOut[i] - arcWeightIntOut[i] <= 0.0) or not disPlaceOut[i], "Output arcs connected to discrete places must have integer weights.");
    assert(arcWeightOut[i] >= 0, "Output arc weights must be positive.");
  end for;
  //****ERROR MESSENGES END****//
end TT;


within PNlib;

package Constants "contains constants which are used in the Petri net component models"
  constant Real inf = 3.40282e+038 "Biggest Real number such that inf and -inf are representable on the machine";
  constant Integer Integer_inf = 1073741823 "Biggest Integer number such that Integer_inf and -Integer_inf are representable on the machine";
  constant Real eps = 1.e-15 "Biggest number such that 1.0 + eps = 1.0";
  constant Real almost_eps = 1.e-9;
end Constants;


newton.

within PNlib.Examples.ConTest;

model Conflict
  extends Modelica.Icons.Example;
  PNlib.Components.TC T1(nOut = 1)
  PNlib.Components.TC T2(maximumSpeed = 2, nIn = 1, nOut = 1)
  PNlib.Components.TC T3(nIn = 1, nOut = 1)
  PNlib.Components.PC P1(nIn = 1, nOut = 2)
  PNlib.Components.PC P2(nIn = 1)
  PNlib.Components.PC P3(nIn = 1)
  inner PNlib.Components.Settings settings
equation
  connect(T1.outPlaces[1], P1.inTransition[1])
  connect(P1.outTransition[1], T2.inPlaces[1])
  connect(T2.outPlaces[1], P2.inTransition[1])
  connect(T3.inPlaces[1], P1.outTransition[2])
  connect(P3.inTransition[1], T3.outPlaces[1])
end Conflict;


within PNlib.Examples.ConTest;

model ConflictLoop
  extends Modelica.Icons.Example;
  PNlib.Components.TC T1(nOut = 1, nIn = 2, arcWeightOut = {3}, arcWeightIn = {2, 1})
  PNlib.Components.TC T2(nIn = 1, nOut = 1, maximumSpeed = 4)
  PNlib.Components.TC T3(nIn = 1, nOut = 1, maximumSpeed = 2)
  PNlib.Components.PC P1(nIn = 1, nOut = 2)
  PNlib.Components.PC P2(nIn = 1, nOut = 1, startMarks = 2)
  PNlib.Components.PC P3(nIn = 1, nOut = 1, startMarks = 1)
  inner PNlib.Components.Settings settings
equation
  connect(T1.outPlaces[1], P1.inTransition[1])
  connect(P1.outTransition[1], T2.inPlaces[1])
  connect(T2.outPlaces[1], P2.inTransition[1])
  connect(T3.inPlaces[1], P1.outTransition[2])
  connect(P3.inTransition[1], T3.outPlaces[1])
  connect(P2.outTransition[1], T1.inPlaces[1])
  connect(P3.outTransition[1], T1.inPlaces[2])
end ConflictLoop;


within PNlib.Examples.ConTest;

model LoopAndArcweight
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PC P1(nOut = 1, nIn = 1, startMarks = 1)
  PNlib.Components.TC T1(nIn = 1, nOut = 2, arcWeightIn = {3}, arcWeightOut = {2, 2})
  PNlib.Components.PC P2(nIn = 1)
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(P1.inTransition[1], T1.outPlaces[1])
  connect(P2.inTransition[1], T1.outPlaces[2])
end LoopAndArcweight;


within PNlib.Examples.ConTest;

model PCtoTC
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PC P1(nOut = 1, startMarks = 1)
  PNlib.Components.TC T1(nIn = 1)
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
end PCtoTC;


within PNlib.Examples.ConTest;

model PCtoTCfunction
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PC P1(nOut = 1, startMarks = 1)
  PNlib.Components.TC T1(arcWeightIn = {P1.t}, nIn = 1)
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
end PCtoTCfunction;


within PNlib.Examples.ConTest;

model SinglePC
  extends Modelica.Icons.Example;
  PNlib.Components.PC P1
  inner PNlib.Components.Settings settings
end SinglePC;


within PNlib.Examples.ConTest;

model SingleTC
  extends Modelica.Icons.Example;
  PNlib.Components.TC T1
  inner PNlib.Components.Settings settings
end SingleTC;


within PNlib.Examples.ConTest;

model Speed
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.TC T1(nOut = 1, maximumSpeed = 2)
  PNlib.Components.PC P1(nIn = 2, nOut = 1)
  PNlib.Components.TC T2(nOut = 1, arcWeightOut = {2})
  PNlib.Components.TC T3(nIn = 1, nOut = 1, arcWeightIn = {4}, arcWeightOut = {4})
  PNlib.Components.PC P2(nIn = 1)
equation
  connect(T1.outPlaces[1], P1.inTransition[1])
  connect(T2.outPlaces[1], P1.inTransition[2])
  connect(T3.inPlaces[1], P1.outTransition[1])
  connect(T3.outPlaces[1], P2.inTransition[1])
end Speed;


within PNlib.Examples.ConTest;

model TCtoPC
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.TC T1(nOut = 1)
  PNlib.Components.PC P1(nIn = 1)
equation
  connect(T1.outPlaces[1], P1.inTransition[1])
end TCtoPC;


within PNlib.Examples.ConTest;

model TCtoPCfunction
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.TC T1(arcWeightOut = {P1.t}, nOut = 1)
  PNlib.Components.PC P1(nIn = 1, startMarks = 1)
equation
  connect(T1.outPlaces[1], P1.inTransition[1])
end TCtoPCfunction;


within PNlib.Examples.ConTest;

model ZeroArcWeight
  extends Modelica.Icons.Example;
  PNlib.Components.PC P1(nOut = 1)
  PNlib.Components.PC P2(nOut = 1, startMarks = 10)
  PNlib.Components.TC T1(nIn = 2, nOut = 1, arcWeightIn = {0, 1})
  PNlib.Components.PC P3(nIn = 1)
  inner PNlib.Components.Settings settings
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(P2.outTransition[1], T1.inPlaces[2])
  connect(T1.outPlaces[1], P3.inTransition[1])
end ZeroArcWeight;


within PNlib.Examples.ConTest;

model ZeroPlace
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.TC T1(nOut = 1)
  PNlib.Components.PC P1(nIn = 1, nOut = 1)
  PNlib.Components.TC T2(nIn = 1, nOut = 1)
  PNlib.Components.PC P2(nIn = 1)
equation
  connect(T1.outPlaces[1], P1.inTransition[1])
  connect(P1.outTransition[1], T2.inPlaces[1])
  connect(T2.outPlaces[1], P2.inTransition[1])
end ZeroPlace;


within PNlib.Examples.DisTest;

model ConflictBeneBaB
  extends Modelica.Icons.Example;
  PNlib.Components.PD P1(nIn = 1)
  PNlib.Components.TD T1(arcWeightIn = {4}, nIn = 1, nOut = 1)
  PNlib.Components.TD T2(arcWeightIn = {3}, nIn = 1, nOut = 1)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.PD P3(nIn = 1)
  inner PNlib.Components.Settings settings
  PNlib.Components.TD T3(arcWeightIn = {1}, nIn = 1, nOut = 1)
  PNlib.Components.TD T4(arcWeightIn = {1}, nIn = 1, nOut = 1)
  PNlib.Components.TD T5(arcWeightIn = {1}, nIn = 1, nOut = 1)
  PNlib.Components.PD P4(nIn = 1)
  PNlib.Components.PD P5(maxTokens = 1, nIn = 1, nOut = 1, startTokens = 1)
  PNlib.Components.PD P7(benefitType = PNlib.Types.BenefitType.BranchAndBound, enablingBeneOut = {6, 5, 3, 4, 2, 0}, enablingType = PNlib.Types.EnablingType.Benefit, nIn = 1, nOut = 6, startTokens = 4)
  PNlib.Components.TD T7(arcWeightOut = {4}, delay = 2, nIn = 1, nOut = 1)
  PNlib.Components.TD T6(arcWeightIn = {1}, nIn = 1, nOut = 1)
  PNlib.Components.PD P6(nIn = 1)
equation
  connect(T6.inPlaces[1], P7.outTransition[6])
  connect(T6.outPlaces[1], P6.inTransition[1])
  connect(T4.outPlaces[1], P5.inTransition[1])
  connect(T5.outPlaces[1], P4.inTransition[1])
  connect(T3.outPlaces[1], P3.inTransition[1])
  connect(T2.outPlaces[1], P2.inTransition[1])
  connect(T1.outPlaces[1], P1.inTransition[1])
  connect(P7.outTransition[5], T4.inPlaces[1])
  connect(P7.outTransition[4], T5.inPlaces[1])
  connect(P7.outTransition[3], T3.inPlaces[1])
  connect(P7.outTransition[2], T2.inPlaces[1])
  connect(P7.outTransition[1], T1.inPlaces[1])
  connect(T7.outPlaces[1], P7.inTransition[1])
  connect(T7.inPlaces[1], P5.outTransition[1])
end ConflictBeneBaB;


within PNlib.Examples.DisTest;

model ConflictBeneGreedy
  extends Modelica.Icons.Example;
  PNlib.Components.PD P1(enablingType = PNlib.Types.EnablingType.Benefit, nIn = 1, nOut = 2, startTokens = 2)
  PNlib.Components.TD T1(nIn = 1, nOut = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.PD P3(nIn = 1)
  PNlib.Components.TD T3(nOut = 1)
  inner PNlib.Components.Settings settings
equation
  connect(T3.outPlaces[1], P1.inTransition[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(T2.inPlaces[1], P1.outTransition[2])
  connect(T2.outPlaces[1], P3.inTransition[1])
end ConflictBeneGreedy;


within PNlib.Examples.DisTest;

model ConflictBeneQuotient
  extends Modelica.Icons.Example;
  PNlib.Components.PD P1(benefitType = PNlib.Types.BenefitType.BenefitQuotient, enablingBeneOut = {10, 7}, enablingType = PNlib.Types.EnablingType.Benefit, nIn = 1, nOut = 2, startTokens = 9)
  PNlib.Components.TD T1(arcWeightIn = {5}, nIn = 1, nOut = 1)
  PNlib.Components.TD T2(arcWeightIn = {3}, nIn = 1, nOut = 1)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.PD P3(nIn = 1)
  PNlib.Components.TD T3(arcWeightOut = {4}, nOut = 1)
  inner PNlib.Components.Settings settings
equation
  connect(T3.outPlaces[1], P1.inTransition[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(T2.inPlaces[1], P1.outTransition[2])
  connect(T2.outPlaces[1], P3.inTransition[1])
end ConflictBeneQuotient;


within PNlib.Examples.DisTest;

model ConflictPrio
  extends Modelica.Icons.Example;
  PNlib.Components.PD P1(nIn = 1, nOut = 2, startTokens = 2)
  PNlib.Components.TD T1(nIn = 1, nOut = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.PD P3(nIn = 1)
  PNlib.Components.TD T3(nOut = 1)
  inner PNlib.Components.Settings settings
equation
  connect(T3.outPlaces[1], P1.inTransition[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(T2.inPlaces[1], P1.outTransition[2])
  connect(T2.outPlaces[1], P3.inTransition[1])
end ConflictPrio;


within PNlib.Examples.DisTest;

model ConflictProb
  extends Modelica.Icons.Example;
  PNlib.Components.PD P1(nIn = 1, startTokens = 2, nOut = 2, enablingType = PNlib.Types.EnablingType.Probability, enablingProbOut = {0.5, 0.5}, localSeedIn = 1, localSeedOut = 2)
  PNlib.Components.TD T1(nIn = 1, nOut = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
  PNlib.Components.PD P2(nIn = 1, localSeedIn = 3, localSeedOut = 4)
  PNlib.Components.PD P3(nIn = 1, localSeedIn = 5, localSeedOut = 6)
  PNlib.Components.TD T3(nOut = 1)
  inner PNlib.Components.Settings settings
equation
  connect(T3.outPlaces[1], P1.inTransition[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(T2.inPlaces[1], P1.outTransition[2])
  connect(T2.outPlaces[1], P3.inTransition[1])
end ConflictProb;


within PNlib.Examples.DisTest;

model DisLoopAndArcweight
  extends Modelica.Icons.Example;
  PNlib.Components.PD P1(nOut = 1, nIn = 1, startTokens = 2)
  PNlib.Components.TD T1(nIn = 1, nOut = 1, arcWeightIn = {2}, arcWeightOut = {3})
  inner PNlib.Components.Settings settings
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P1.inTransition[1])
end DisLoopAndArcweight;


within PNlib.Examples.DisTest;

model EightConflictProb
  extends Modelica.Icons.Example;
  PNlib.Components.PD P1(startTokens = 1, enablingType = PNlib.Types.EnablingType.Probability, nOut = 8, localSeedIn = 1, localSeedOut = 2)
  PNlib.Components.TD T1(nIn = 1)
  PNlib.Components.TD T2(nIn = 1)
  PNlib.Components.TD T3(nIn = 1)
  PNlib.Components.TD T4(nIn = 1)
  PNlib.Components.TD T5(nIn = 1)
  PNlib.Components.TD T6(nIn = 1)
  PNlib.Components.TD T7(nIn = 1)
  PNlib.Components.TD T8(nIn = 1)
  inner PNlib.Components.Settings settings
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T2.inPlaces[1], P1.outTransition[2])
  connect(T3.inPlaces[1], P1.outTransition[3])
  connect(T4.inPlaces[1], P1.outTransition[4])
  connect(T5.inPlaces[1], P1.outTransition[5])
  connect(T6.inPlaces[1], P1.outTransition[6])
  connect(T7.inPlaces[1], P1.outTransition[7])
  connect(T8.inPlaces[1], P1.outTransition[8])
end EightConflictProb;


within PNlib.Examples.DisTest;

model FiveTimes
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(nIn = 1, nOut = 1, startTokens = 3)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.PD P3(nIn = 1, nOut = 1, startTokens = 3)
  PNlib.Components.PD P4(nIn = 1)
  PNlib.Components.PD P5(nIn = 1, nOut = 1, startTokens = 3)
  PNlib.Components.PD P6(nIn = 1)
  PNlib.Components.PD P7(nIn = 1, nOut = 1, startTokens = 3)
  PNlib.Components.PD P8(nIn = 1)
  PNlib.Components.TD T1(nIn = 1, nOut = 1)
  PNlib.Components.TE T2(event = {1, 3, 4, 5, 6, 9}, nIn = 1, nOut = 1)
  PNlib.Components.TFD T3(nIn = 1, nOut = 1)
  PNlib.Components.TT T4(nIn = 1, nOut = 1, tactStart = 2)
  PNlib.Components.TE T6(arcWeightOut = {3, 3, 3, 3, 3}, event = {5.5}, nOut = 5)
  PNlib.Components.PC P9(nIn = 1, nOut = 1, startMarks = 3)
  PNlib.Components.PC P10(nIn = 1)
  PNlib.Components.TC T5(nIn = 1, nOut = 1)
equation
  connect(T6.outPlaces[5], P9.inTransition[1])
  connect(P9.outTransition[1], T5.inPlaces[1])
  connect(T5.outPlaces[1], P10.inTransition[1])
  connect(T4.outPlaces[1], P8.inTransition[1])
  connect(P7.outTransition[1], T4.inPlaces[1])
  connect(T6.outPlaces[4], P7.inTransition[1])
  connect(T6.outPlaces[3], P5.inTransition[1])
  connect(T6.outPlaces[2], P3.inTransition[1])
  connect(T6.outPlaces[1], P1.inTransition[1])
  connect(T3.outPlaces[1], P6.inTransition[1])
  connect(P5.outTransition[1], T3.inPlaces[1])
  connect(T2.outPlaces[1], P4.inTransition[1])
  connect(P3.outTransition[1], T2.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
end FiveTimes;


within PNlib.Examples.DisTest;

model InputConflictBeneBaB
  extends Modelica.Icons.Example;
  PNlib.Components.PD P1(benefitType = PNlib.Types.BenefitType.BranchAndBound, enablingBeneIn = {6, 5}, enablingType = PNlib.Types.EnablingType.Benefit, maxTokens = 5, nIn = 2, nOut = 1)
  PNlib.Components.TD T1(arcWeightIn = {3}, nIn = 1)
  PNlib.Components.TD T2(arcWeightOut = {3}, nIn = 1, nOut = 1)
  PNlib.Components.TD T3(arcWeightOut = {2}, nIn = 1, nOut = 1)
  PNlib.Components.PD P2(startTokens = 5, nOut = 1)
  PNlib.Components.PD P3(startTokens = 5, nOut = 1)
  inner PNlib.Components.Settings settings
equation
  connect(T1.inPlaces[1], P1.outTransition[1])
  connect(P2.outTransition[1], T2.inPlaces[1])
  connect(P3.outTransition[1], T3.inPlaces[1])
  connect(T2.outPlaces[1], P1.inTransition[1])
  connect(T3.outPlaces[1], P1.inTransition[2])
end InputConflictBeneBaB;


within PNlib.Examples.DisTest;

model InputConflictBeneGreedy
  extends Modelica.Icons.Example;
  PNlib.Components.PD P1(enablingBeneIn = {1, 2}, enablingType = PNlib.Types.EnablingType.Benefit, maxTokens = 2, nIn = 2, nOut = 1)
  PNlib.Components.TD T1(nIn = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
  PNlib.Components.TD T3(nIn = 1, nOut = 1)
  PNlib.Components.PD P2(startTokens = 5, nOut = 1)
  PNlib.Components.PD P3(startTokens = 5, nOut = 1)
  inner PNlib.Components.Settings settings
equation
  connect(P2.outTransition[1], T2.inPlaces[1])
  connect(P3.outTransition[1], T3.inPlaces[1])
  connect(T2.outPlaces[1], P1.inTransition[1])
  connect(T3.outPlaces[1], P1.inTransition[2])
  connect(T1.inPlaces[1], P1.outTransition[1])
end InputConflictBeneGreedy;


within PNlib.Examples.DisTest;

model InputConflictBeneQuotient
  extends Modelica.Icons.Example;
  PNlib.Components.PD P1(benefitType = PNlib.Types.BenefitType.BenefitQuotient, enablingBeneIn = {6, 5}, enablingType = PNlib.Types.EnablingType.Benefit, maxTokens = 5, nIn = 2, nOut = 1)
  PNlib.Components.TD T1(arcWeightIn = {3}, nIn = 1)
  PNlib.Components.TD T2(arcWeightOut = {3}, nIn = 1, nOut = 1)
  PNlib.Components.TD T3(arcWeightOut = {2}, nIn = 1, nOut = 1)
  PNlib.Components.PD P2(startTokens = 5, nOut = 1)
  PNlib.Components.PD P3(startTokens = 5, nOut = 1)
  inner PNlib.Components.Settings settings
equation
  connect(P2.outTransition[1], T2.inPlaces[1])
  connect(P3.outTransition[1], T3.inPlaces[1])
  connect(T2.outPlaces[1], P1.inTransition[1])
  connect(T3.outPlaces[1], P1.inTransition[2])
  connect(T1.inPlaces[1], P1.outTransition[1])
end InputConflictBeneQuotient;


within PNlib.Examples.DisTest;

model InputConflictPrio
  extends Modelica.Icons.Example;
  PNlib.Components.PD P1(maxTokens = 2, nIn = 2, nOut = 1)
  PNlib.Components.TD T1(nIn = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
  PNlib.Components.TD T3(nIn = 1, nOut = 1)
  PNlib.Components.PD P2(startTokens = 5, nOut = 1)
  PNlib.Components.PD P3(startTokens = 5, nOut = 1)
  inner PNlib.Components.Settings settings
equation
  connect(P2.outTransition[1], T2.inPlaces[1])
  connect(P3.outTransition[1], T3.inPlaces[1])
  connect(T2.outPlaces[1], P1.inTransition[1])
  connect(T3.outPlaces[1], P1.inTransition[2])
  connect(T1.inPlaces[1], P1.outTransition[1])
end InputConflictPrio;


within PNlib.Examples.DisTest;

model InputConflictProb
  extends Modelica.Icons.Example;
  PNlib.Components.PD P1(maxTokens = 2, nIn = 2, nOut = 1, enablingType = PNlib.Types.EnablingType.Probability, localSeedIn = 1, localSeedOut = 2)
  PNlib.Components.TD T1(nIn = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
  PNlib.Components.TD T3(nIn = 1, nOut = 1)
  PNlib.Components.PD P2(startTokens = 5, nOut = 1, localSeedIn = 3, localSeedOut = 4)
  PNlib.Components.PD P3(startTokens = 5, nOut = 1, localSeedIn = 5, localSeedOut = 6)
  inner PNlib.Components.Settings settings
equation
  connect(P2.outTransition[1], T2.inPlaces[1])
  connect(P3.outTransition[1], T3.inPlaces[1])
  connect(T2.outPlaces[1], P1.inTransition[1])
  connect(T3.outPlaces[1], P1.inTransition[2])
  connect(T1.inPlaces[1], P1.outTransition[1])
end InputConflictProb;


within PNlib.Examples.DisTest;

model NoInputConflict
  extends Modelica.Icons.Example;
  PNlib.Components.TD T1(nOut = 1)
  PNlib.Components.TD T2(delay = 2, nOut = 1)
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(enablingPrioIn = {2, 1}, maxTokens = 1, nIn = 2)
equation
  connect(T1.outPlaces[1], P1.inTransition[1])
  connect(T2.outPlaces[1], P1.inTransition[2])
end NoInputConflict;


within PNlib.Examples.DisTest;

model OutputConflictBeneBaB
  extends Modelica.Icons.Example;
  PNlib.Components.PD P1(benefitType = PNlib.Types.BenefitType.BranchAndBound, enablingBeneOut = {8, 7}, enablingType = PNlib.Types.EnablingType.Benefit, minTokens = 8, nIn = 1, nOut = 2, startTokens = 15)
  PNlib.Components.TD T1(arcWeightIn = {4}, nIn = 1, nOut = 1)
  PNlib.Components.TD T2(arcWeightIn = {3}, nIn = 1, nOut = 1)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.PD P3(nIn = 1)
  PNlib.Components.TD T3(arcWeightOut = {2}, nOut = 1)
  inner PNlib.Components.Settings settings
equation
  connect(T3.outPlaces[1], P1.inTransition[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(T2.inPlaces[1], P1.outTransition[2])
  connect(T2.outPlaces[1], P3.inTransition[1])
end OutputConflictBeneBaB;


within PNlib.Examples.DisTest;

model OutputConflictBeneGreedy
  extends Modelica.Icons.Example;
  PNlib.Components.PD P1(enablingBeneOut = {2, 1}, enablingType = PNlib.Types.EnablingType.Benefit, minTokens = 2, nIn = 1, nOut = 2, startTokens = 2)
  PNlib.Components.TD T1(nIn = 1, nOut = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.PD P3(nIn = 1)
  PNlib.Components.TD T3(nOut = 1)
  inner PNlib.Components.Settings settings
equation
  connect(T3.outPlaces[1], P1.inTransition[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(T2.inPlaces[1], P1.outTransition[2])
  connect(T2.outPlaces[1], P3.inTransition[1])
end OutputConflictBeneGreedy;


within PNlib.Examples.DisTest;

model OutputConflictBeneQuotient
  extends Modelica.Icons.Example;
  PNlib.Components.PD P1(benefitType = PNlib.Types.BenefitType.BenefitQuotient, enablingBeneOut = {8, 7}, enablingType = PNlib.Types.EnablingType.Benefit, minTokens = 8, nIn = 1, nOut = 2, startTokens = 8)
  PNlib.Components.TD T1(arcWeightIn = {4}, nIn = 1, nOut = 1)
  PNlib.Components.TD T2(arcWeightIn = {3}, nIn = 1, nOut = 1)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.PD P3(nIn = 1)
  PNlib.Components.TD T3(arcWeightOut = {2}, nOut = 1)
  inner PNlib.Components.Settings settings
equation
  connect(T3.outPlaces[1], P1.inTransition[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(T2.inPlaces[1], P1.outTransition[2])
  connect(T2.outPlaces[1], P3.inTransition[1])
end OutputConflictBeneQuotient;


within PNlib.Examples.DisTest;

model OutputConflictPrio
  extends Modelica.Icons.Example;
  PNlib.Components.PD P1(nIn = 1, startTokens = 2, nOut = 2, minTokens = 2)
  PNlib.Components.TD T1(nIn = 1, nOut = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.PD P3(nIn = 1)
  PNlib.Components.TD T3(nOut = 1)
  inner PNlib.Components.Settings settings
equation
  connect(T3.outPlaces[1], P1.inTransition[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(T2.inPlaces[1], P1.outTransition[2])
  connect(T2.outPlaces[1], P3.inTransition[1])
end OutputConflictPrio;


within PNlib.Examples.DisTest;

model OutputConflictProb
  extends Modelica.Icons.Example;
  PNlib.Components.PD P1(nIn = 1, startTokens = 2, nOut = 2, enablingProbOut = {0.5, 0.5}, minTokens = 2, enablingType = PNlib.Types.EnablingType.Probability, localSeedIn = 1, localSeedOut = 2)
  PNlib.Components.TD T1(nIn = 1, nOut = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
  PNlib.Components.PD P2(nIn = 1, localSeedIn = 3, localSeedOut = 4)
  PNlib.Components.PD P3(nIn = 1, localSeedIn = 5, localSeedOut = 6)
  PNlib.Components.TD T3(nOut = 1)
  inner PNlib.Components.Settings settings
equation
  connect(T3.outPlaces[1], P1.inTransition[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(T2.inPlaces[1], P1.outTransition[2])
  connect(T2.outPlaces[1], P3.inTransition[1])
end OutputConflictProb;


within PNlib.Examples.DisTest;

model PDtoTD
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(nOut = 1, startTokens = 10)
  PNlib.Components.TD T1(nIn = 1)
equation
  connect(T1.inPlaces[1], P1.outTransition[1])
end PDtoTD;


within PNlib.Examples.DisTest;

model PDtoTDfunction
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(nOut = 1, startTokens = 10)
  PNlib.Components.TD T1(arcWeightIn = {P1.t}, nIn = 1)
equation
  connect(T1.inPlaces[1], P1.outTransition[1])
end PDtoTDfunction;


within PNlib.Examples.DisTest;

model PDtoTT
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(nOut = 1, startTokens = 10)
  PNlib.Components.TT T1(nIn = 1)
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
end PDtoTT;


within PNlib.Examples.DisTest;

model PrioTest
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(enablingPrioOut = {4, 3, 2, 1}, nIn = 1, nOut = 4, startTokens = 1)
  PNlib.Components.TD T1(nOut = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
  PNlib.Components.TD T3(nIn = 1, nOut = 1)
  PNlib.Components.TD T4(nIn = 1, nOut = 1)
  PNlib.Components.TD T5(nIn = 1, nOut = 1)
  PNlib.Components.PD P2(maxTokens = 1, nIn = 1)
  PNlib.Components.PD P3(maxTokens = 1, nIn = 1)
  PNlib.Components.PD P4(maxTokens = 1, nIn = 1)
  PNlib.Components.PD P5(maxTokens = 1, nIn = 1)
equation
  connect(T5.outPlaces[1], P5.inTransition[1])
  connect(T4.outPlaces[1], P4.inTransition[1])
  connect(T3.outPlaces[1], P3.inTransition[1])
  connect(T2.outPlaces[1], P2.inTransition[1])
  connect(P1.outTransition[4], T5.inPlaces[1])
  connect(P1.outTransition[1], T2.inPlaces[1])
  connect(P1.outTransition[3], T4.inPlaces[1])
  connect(P1.outTransition[2], T3.inPlaces[1])
  connect(T1.outPlaces[1], P1.inTransition[1])
end PrioTest;


within PNlib.Examples.DisTest;

model SinglePD
  extends Modelica.Icons.Example;
  PNlib.Components.PD P1
  inner PNlib.Components.Settings settings
end SinglePD;


within PNlib.Examples.DisTest;

model SingleTD
  extends Modelica.Icons.Example;
  PNlib.Components.TD T1
  inner PNlib.Components.Settings settings
end SingleTD;


within PNlib.Examples.DisTest;

model SixConflictProb
  extends Modelica.Icons.Example;
  PNlib.Components.PD P1(startTokens = 1, enablingType = PNlib.Types.EnablingType.Probability, nOut = 6, localSeedIn = 1, localSeedOut = 2)
  PNlib.Components.TD T1(nIn = 1)
  PNlib.Components.TD T2(nIn = 1)
  PNlib.Components.TD T3(nIn = 1)
  PNlib.Components.TD T4(nIn = 1)
  PNlib.Components.TD T5(nIn = 1)
  PNlib.Components.TD T6(nIn = 1)
  inner PNlib.Components.Settings settings
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T2.inPlaces[1], P1.outTransition[2])
  connect(T3.inPlaces[1], P1.outTransition[3])
  connect(T4.inPlaces[1], P1.outTransition[4])
  connect(T5.inPlaces[1], P1.outTransition[5])
  connect(T6.inPlaces[1], P1.outTransition[6])
end SixConflictProb;


within PNlib.Examples.DisTest;

model TDtoPD
  extends Modelica.Icons.Example;
  PNlib.Components.PD P1(nOut = 0, nIn = 1)
  PNlib.Components.TD T1(nOut = 1)
  inner PNlib.Components.Settings settings
equation
  connect(P1.inTransition[1], T1.outPlaces[1])
end TDtoPD;


within PNlib.Examples.DisTest;

model TDtoPDfunction
  extends Modelica.Icons.Example;
  PNlib.Components.PD P1(nIn = 1, nOut = 0, startTokens = 1)
  PNlib.Components.TD T1(arcWeightOut = {P1.t}, nOut = 1)
  inner PNlib.Components.Settings settings
equation
  connect(P1.inTransition[1], T1.outPlaces[1])
end TDtoPDfunction;


within PNlib.Examples.DisTest;

model TEnoInput
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(nIn = 1, startTokens = 0)
  PNlib.Components.TE T2(event = {0.5, 2.5, 2.8}, nOut = 1)
equation
  connect(T2.outPlaces[1], P1.inTransition[1])
end TEnoInput;


within PNlib.Examples.DisTest;

model TEtest
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(nIn = 1, nOut = 1, startTokens = 0)
  PNlib.Components.TE T1(nIn = 1, nOut = 1)
  PNlib.Components.TE T2(event = {0.5, 2.5, 2.8}, nIn = 1, nOut = 1)
  PNlib.Components.PD P2(nIn = 1, nOut = 1, startTokens = 1)
equation
  connect(P2.inTransition[1], T1.outPlaces[1])
  connect(P2.outTransition[1], T2.inPlaces[1])
  connect(T1.inPlaces[1], P1.outTransition[1])
  connect(T2.outPlaces[1], P1.inTransition[1])
end TEtest;


within PNlib.Examples.DisTest;

model TFDinputConflict
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(nIn = 1, nOut = 1, startTokens = 0)
  PNlib.Components.PD P2(enablingPrioIn = {2, 1}, maxTokens = 1, nIn = 2, nOut = 1, startTokens = 0)
  PNlib.Components.TFD T1(nIn = 1, nOut = 1)
  PNlib.Components.TE T2(event = {1, 2.5, 3.8}, nOut = 1)
  PNlib.Components.TE T3(event = {1.8, 2.3, 3.9}, nIn = 1)
  PNlib.Components.TE T4(event = {1.5, 3.5}, nOut = 1)
equation
  connect(T4.outPlaces[1], P2.inTransition[2])
  connect(P2.outTransition[1], T3.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T2.outPlaces[1], P1.inTransition[1])
end TFDinputConflict;


within PNlib.Examples.DisTest;

model TFDoutCap
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(nIn = 1, nOut = 1, startTokens = 0)
  PNlib.Components.PD P2(maxTokens = 1, nIn = 1, nOut = 1, startTokens = 1)
  PNlib.Components.TFD T1(nIn = 1, nOut = 1)
  PNlib.Components.TE T2(event = {1, 2.5, 3.8}, nOut = 1)
  PNlib.Components.TE T3(event = {1.5, 4}, nIn = 1)
equation
  connect(T2.outPlaces[1], P1.inTransition[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(P2.outTransition[1], T3.inPlaces[1])
end TFDoutCap;


within PNlib.Examples.DisTest;

model TFDoutputConflict
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(enablingType = PNlib.Types.EnablingType.Probability, localSeedIn = 1, localSeedOut = 2, nIn = 1, nOut = 2, startTokens = 0)
  PNlib.Components.PD P2(localSeedIn = 3, localSeedOut = 4, nIn = 1)
  PNlib.Components.TFD T1(nIn = 1, nOut = 1)
  PNlib.Components.TD T3(nOut = 1)
  PNlib.Components.TFD T2(nIn = 1, nOut = 1)
  PNlib.Components.PD P3(localSeedIn = 5, localSeedOut = 6, nIn = 1)
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(T2.inPlaces[1], P1.outTransition[2])
  connect(T2.outPlaces[1], P3.inTransition[1])
  connect(T3.outPlaces[1], P1.inTransition[1])
end TFDoutputConflict;


within PNlib.Examples.DisTest;

model TFDtest
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(nIn = 0, nOut = 1, startTokens = 5)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.TFD T1(nIn = 1, nOut = 1)
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
end TFDtest;


within PNlib.Examples.DisTest;

model TTcircle
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(nIn = 1, nOut = 1, startTokens = 1)
  PNlib.Components.TT T1(nIn = 1, nOut = 1, tactIntervall = 1, tactStart = 0)
  PNlib.Components.PD P2(nIn = 1, nOut = 1)
  PNlib.Components.TT T2(nIn = 1, nOut = 1, tactIntervall = 2, tactStart = 1.5)
equation
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(P2.outTransition[1], T2.inPlaces[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T2.outPlaces[1], P1.inTransition[1])
end TTcircle;


within PNlib.Examples.DisTest;

model Ttest
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(nIn = 1, nOut = 1, startTokens = 0)
  PNlib.Components.TE T2(event = {1, 2, 3, 4}, nOut = 1)
  PNlib.Components.PD P2(nIn = 1, nOut = 2)
  PNlib.Components.T T1(arcWeightIn = {2}, arcWeightOut = {3}, nIn = 1, nOut = 1)
  PNlib.Components.T T3(arcWeightIn = {2}, arcWeightOut = {2}, nIn = 1, nOut = 1)
  PNlib.Components.PD P3(nIn = 1)
  PNlib.Components.T T4(arcWeightIn = {2}, arcWeightOut = {2}, nIn = 1, nOut = 1)
  PNlib.Components.PD P4(nIn = 1)
equation
  connect(T4.inPlaces[1], P2.outTransition[2])
  connect(T4.outPlaces[1], P4.inTransition[1])
  connect(T3.outPlaces[1], P3.inTransition[1])
  connect(T3.inPlaces[1], P2.outTransition[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T2.outPlaces[1], P1.inTransition[1])
end Ttest;


within PNlib.Examples.DisTest;

model TTtoPD
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(nIn = 1)
  PNlib.Components.TT T1(nOut = 1)
equation
  connect(T1.outPlaces[1], P1.inTransition[1])
end TTtoPD;


within PNlib.Examples.ExtTest;

model ArcswithPCtoTC
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PC P1(nOut = 1, startMarks = 1)
  PNlib.Components.PC P2(nIn = 1)
  PNlib.Components.PC P3(nOut = 1, startMarks = 1)
  PNlib.Components.PC P4(nIn = 1)
  PNlib.Components.PC P5(nOut = 1, startMarks = 1)
  PNlib.Components.PC P6(nIn = 1)
  PNlib.Components.PC P7(nOut = 1, startMarks = 1)
  PNlib.Components.PC P8(nIn = 1)
  PNlib.Components.TC T1(nIn = 1, nOut = 1)
  PNlib.Components.TC T2(nIn = 1, nOut = 1)
  PNlib.Components.TC T3(nIn = 1, nOut = 1)
  PNlib.Components.TC T4(nIn = 1, nOut = 1)
  PNlib.Components.TA TA1
  PNlib.Components.TA TA2(realTestArc = false)
  PNlib.Components.IA IA1
  PNlib.Components.IA IA2(realInhibitorArc = false)
equation
  connect(T4.outPlaces[1], P8.inTransition[1])
  connect(T3.outPlaces[1], P6.inTransition[1])
  connect(T2.outPlaces[1], P4.inTransition[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(IA2.outTransition, T4.inPlaces[1])
  connect(P7.outTransition[1], IA2.inPlace)
  connect(IA1.outTransition, T3.inPlaces[1])
  connect(P5.outTransition[1], IA1.inPlace)
  connect(TA2.outTransition, T2.inPlaces[1])
  connect(P3.outTransition[1], TA2.inPlace)
  connect(TA1.outTransition, T1.inPlaces[1])
  connect(P1.outTransition[1], TA1.inPlace)
end ArcswithPCtoTC;


within PNlib.Examples.ExtTest;

model ArcswithPCtoTC2
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PC P1(maxMarks = 1, nIn = 1, nOut = 1)
  PNlib.Components.PC P2(nIn = 1)
  PNlib.Components.PC P3(maxMarks = 1, nIn = 1, nOut = 1)
  PNlib.Components.PC P4(nIn = 1)
  PNlib.Components.PC P5(maxMarks = 1, nIn = 1, nOut = 1)
  PNlib.Components.PC P6(nIn = 1)
  PNlib.Components.PC P7(maxMarks = 1, nIn = 1, nOut = 1)
  PNlib.Components.PC P8(nIn = 1)
  PNlib.Components.TC T1(nIn = 1, nOut = 1)
  PNlib.Components.TC T2(nIn = 1, nOut = 1)
  PNlib.Components.TC T3(nIn = 1, nOut = 1)
  PNlib.Components.TC T4(nIn = 1, nOut = 1)
  PNlib.Components.TA TA1
  PNlib.Components.TA TA2(realTestArc = false)
  PNlib.Components.IA IA1
  PNlib.Components.IA IA2(realInhibitorArc = false)
  PNlib.Components.TC T5(nOut = 4)
equation
  connect(T5.outPlaces[4], P7.inTransition[1])
  connect(T5.outPlaces[3], P5.inTransition[1])
  connect(T5.outPlaces[2], P3.inTransition[1])
  connect(T5.outPlaces[1], P1.inTransition[1])
  connect(T4.outPlaces[1], P8.inTransition[1])
  connect(T3.outPlaces[1], P6.inTransition[1])
  connect(T2.outPlaces[1], P4.inTransition[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(IA2.outTransition, T4.inPlaces[1])
  connect(P7.outTransition[1], IA2.inPlace)
  connect(IA1.outTransition, T3.inPlaces[1])
  connect(P5.outTransition[1], IA1.inPlace)
  connect(TA2.outTransition, T2.inPlaces[1])
  connect(P3.outTransition[1], TA2.inPlace)
  connect(TA1.outTransition, T1.inPlaces[1])
  connect(P1.outTransition[1], TA1.inPlace)
end ArcswithPCtoTC2;


within PNlib.Examples.ExtTest;

model ArcswithPCtoTC3
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PC P1(minMarks = 1, nOut = 2, startMarks = 2)
  PNlib.Components.PC P2(nIn = 1)
  PNlib.Components.PC P3(minMarks = 1, nOut = 2, startMarks = 2)
  PNlib.Components.PC P4(nIn = 1)
  PNlib.Components.PC P5(minMarks = 1, nOut = 2, startMarks = 2)
  PNlib.Components.PC P6(nIn = 1)
  PNlib.Components.PC P7(minMarks = 1, nOut = 2, startMarks = 2)
  PNlib.Components.PC P8(nIn = 1)
  PNlib.Components.TC T1(nIn = 1, nOut = 1)
  PNlib.Components.TC T2(nIn = 1, nOut = 1)
  PNlib.Components.TC T3(nIn = 1, nOut = 1)
  PNlib.Components.TC T4(nIn = 1, nOut = 1)
  PNlib.Components.TA TA1
  PNlib.Components.TA TA2(realTestArc = false)
  PNlib.Components.IA IA1
  PNlib.Components.IA IA2(realInhibitorArc = false)
  PNlib.Components.TC T5(nIn = 4, nOut = 0)
equation
  connect(T5.inPlaces[4], P7.outTransition[2])
  connect(T5.inPlaces[3], P5.outTransition[2])
  connect(T5.inPlaces[2], P3.outTransition[2])
  connect(T5.inPlaces[1], P1.outTransition[2])
  connect(T4.outPlaces[1], P8.inTransition[1])
  connect(T3.outPlaces[1], P6.inTransition[1])
  connect(T2.outPlaces[1], P4.inTransition[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(IA2.outTransition, T4.inPlaces[1])
  connect(P7.outTransition[1], IA2.inPlace)
  connect(IA1.outTransition, T3.inPlaces[1])
  connect(P5.outTransition[1], IA1.inPlace)
  connect(TA2.outTransition, T2.inPlaces[1])
  connect(P3.outTransition[1], TA2.inPlace)
  connect(TA1.outTransition, T1.inPlaces[1])
  connect(P1.outTransition[1], TA1.inPlace)
end ArcswithPCtoTC3;


within PNlib.Examples.ExtTest;

model DoubleArcwithPCtoTC
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.IA IA1(testValue = 3, normalArc = false)
  PNlib.Components.PC P1(nOut = 2, startMarks = 5)
  PNlib.Components.PC P2(nIn = 1)
  PNlib.Components.PC P3(nIn = 1)
  PNlib.Components.TA TA1(testValue = 2, normalArc = false)
  PNlib.Components.TC T1(nOut = 1, nIn = 1)
  PNlib.Components.TC T2(nIn = 1, nOut = 1)
equation
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(P1.outTransition[1], TA1.inPlace)
  connect(TA1.outTransition, T2.inPlaces[1])
  connect(T2.outPlaces[1], P3.inTransition[1])
  connect(IA1.outTransition, T1.inPlaces[1])
  connect(IA1.inPlace, P1.outTransition[2])
end DoubleArcwithPCtoTC;


within PNlib.Examples.ExtTest;

model DoubleArcwithPTtoTD
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.IA IA1(testValue = 3, normalArc = false)
  PNlib.Components.PD P1(nOut = 2, startTokens = 5)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.PD P3(nIn = 1)
  PNlib.Components.TA TA1(normalArc = false, testValue = 2)
  PNlib.Components.TD T1(nOut = 1, nIn = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
equation
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(P1.outTransition[1], TA1.inPlace)
  connect(TA1.outTransition, T2.inPlaces[1])
  connect(T2.outPlaces[1], P3.inTransition[1])
  connect(IA1.inPlace, P1.outTransition[2])
  connect(IA1.outTransition, T1.inPlaces[1])
end DoubleArcwithPTtoTD;


within PNlib.Examples.ExtTest;

model DoubleArcwithPTtoTD2
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.IA IA1(normalArc = false, realInhibitorArc = false, testValue = 3)
  PNlib.Components.PD P1(nOut = 2, startTokens = 5)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.PD P3(nIn = 1)
  PNlib.Components.TA TA1(normalArc = false, realTestArc = false, testValue = 2)
  PNlib.Components.TD T1(nOut = 1, nIn = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
equation
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(P1.outTransition[1], TA1.inPlace)
  connect(TA1.outTransition, T2.inPlaces[1])
  connect(T2.outPlaces[1], P3.inTransition[1])
  connect(IA1.inPlace, P1.outTransition[2])
  connect(IA1.outTransition, T1.inPlaces[1])
end DoubleArcwithPTtoTD2;


within PNlib.Examples.ExtTest;

model IATest
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.IA IA1(normalArc = false, testValue = 1)
  PNlib.Components.IA IA2(testValue = 2)
  PNlib.Components.PC P1(nOut = 2, nIn = 1, startMarks = 2)
  PNlib.Components.PC P2(nIn = 1, nOut = 1, startMarks = 1)
  PNlib.Components.PC P3(nIn = 1)
  PNlib.Components.TC T1(nOut = 1, nIn = 1)
  PNlib.Components.TC T2(nOut = 1, maximumSpeed = 1.5)
  PNlib.Components.TC T3(nIn = 2, arcWeightIn = {1, 2}, maximumSpeed = 2, nOut = 1)
equation
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(P1.outTransition[1], IA1.inPlace)
  connect(IA1.outTransition, T1.inPlaces[1])
  connect(T2.outPlaces[1], P1.inTransition[1])
  connect(P2.outTransition[1], IA2.inPlace)
  connect(IA2.outTransition, T3.inPlaces[1])
  connect(P1.outTransition[2], T3.inPlaces[2])
  connect(T3.outPlaces[1], P3.inTransition[1])
end IATest;


within PNlib.Examples.ExtTest;

model IAwithPCtoTC
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.IA TA1(testValue = 3)
  PNlib.Components.PC P1(nOut = 2, startMarks = 5)
  PNlib.Components.PC P2(nIn = 1)
  PNlib.Components.PC P3(nIn = 1)
  PNlib.Components.TC T1(nIn = 1, nOut = 1)
  PNlib.Components.TC T2(nIn = 1, nOut = 1)
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(P1.outTransition[2], TA1.inPlace)
  connect(TA1.outTransition, T2.inPlaces[1])
  connect(T2.outPlaces[1], P3.inTransition[1])
end IAwithPCtoTC;


within PNlib.Examples.ExtTest;

model IAwithPDtoTD
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.IA TA1(testValue = 3)
  PNlib.Components.PD P1(nOut = 2, startTokens = 5)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.PD P3(nIn = 1)
  PNlib.Components.TD T1(nIn = 1, nOut = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(P1.outTransition[2], TA1.inPlace)
  connect(TA1.outTransition, T2.inPlaces[1])
  connect(T2.outPlaces[1], P3.inTransition[1])
end IAwithPDtoTD;


within PNlib.Examples.ExtTest;

model IAwithPDtoTD2
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.IA TA1(realInhibitorArc = false, testValue = 3)
  PNlib.Components.PD P1(nOut = 2, startTokens = 5)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.PD P3(nIn = 1)
  PNlib.Components.TD T1(nIn = 1, nOut = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(P1.outTransition[2], TA1.inPlace)
  connect(TA1.outTransition, T2.inPlaces[1])
  connect(T2.outPlaces[1], P3.inTransition[1])
end IAwithPDtoTD2;


within PNlib.Examples.ExtTest;

model NoTokens
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PC P1(nOut = 1, startMarks = 5)
  PNlib.Components.PC P3(nOut = 1, startMarks = 5)
  PNlib.Components.PC P2(nOut = 2, startMarks = 5)
  PNlib.Components.TC T1(nIn = 2, nOut = 1)
  PNlib.Components.TC T2(nIn = 2, nOut = 1)
  PNlib.Components.PC P4(nIn = 2)
  PNlib.Components.IA IA1
equation
  connect(T2.outPlaces[1], P4.inTransition[2])
  connect(T1.outPlaces[1], P4.inTransition[1])
  connect(P3.outTransition[1], T2.inPlaces[2])
  connect(P2.outTransition[2], IA1.inPlace)
  connect(P2.outTransition[1], T1.inPlaces[2])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(IA1.outTransition, T2.inPlaces[1])
end NoTokens;


within PNlib.Examples.ExtTest;

model TATest
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PC P1(nOut = 2, nIn = 1)
  PNlib.Components.PC P2(nIn = 1, nOut = 1)
  PNlib.Components.TA TA1(normalArc = false, testValue = 1)
  PNlib.Components.TA TA2(testValue = 2)
  PNlib.Components.TC T1(nOut = 1, nIn = 1)
  PNlib.Components.TC T2(nOut = 1, maximumSpeed = 1.5)
  PNlib.Components.TC T3(nIn = 2, arcWeightIn = {1, 2})
equation
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(P1.outTransition[1], TA1.inPlace)
  connect(TA1.outTransition, T1.inPlaces[1])
  connect(T2.outPlaces[1], P1.inTransition[1])
  connect(P2.outTransition[1], TA2.inPlace)
  connect(TA2.outTransition, T3.inPlaces[1])
  connect(P1.outTransition[2], T3.inPlaces[2])
end TATest;


within PNlib.Examples.ExtTest;

model TAwithPCtoTC
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PC P1(nOut = 2, startMarks = 5)
  PNlib.Components.PC P2(nIn = 1)
  PNlib.Components.PC P3(nIn = 1)
  PNlib.Components.TA TA1(testValue = 3)
  PNlib.Components.TC T1(nIn = 1, nOut = 1)
  PNlib.Components.TC T2(nIn = 1, nOut = 1)
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(P1.outTransition[2], TA1.inPlace)
  connect(TA1.outTransition, T2.inPlaces[1])
  connect(T2.outPlaces[1], P3.inTransition[1])
end TAwithPCtoTC;


within PNlib.Examples.ExtTest;

model TAwithPDtoTD
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(nOut = 2, startTokens = 5)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.PD P3(nIn = 1)
  PNlib.Components.TA TA1(testValue = 3)
  PNlib.Components.TD T1(nIn = 1, nOut = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(P1.outTransition[2], TA1.inPlace)
  connect(TA1.outTransition, T2.inPlaces[1])
  connect(T2.outPlaces[1], P3.inTransition[1])
end TAwithPDtoTD;


within PNlib.Examples.ExtTest;

model TAwithPDtoTD2
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(nOut = 2, startTokens = 5)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.PD P3(nIn = 1)
  PNlib.Components.TA TA1(realTestArc = false, testValue = 3)
  PNlib.Components.TD T1(nIn = 1, nOut = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(P1.outTransition[2], TA1.inPlace)
  connect(TA1.outTransition, T2.inPlaces[1])
  connect(T2.outPlaces[1], P3.inTransition[1])
end TAwithPDtoTD2;


within PNlib.Examples.ExtTest;

model TAwithWeaklyActivation
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PC P1(nIn = 1, nOut = 2, startMarks = 4)
  PNlib.Components.PC P2(nIn = 1, maxMarks = 3)
  PNlib.Components.TA TA1(normalArc = false, testValue = 5)
  PNlib.Components.TC T1(nOut = 1, maximumSpeed = if time > 2 then 2 else 1)
  PNlib.Components.TC T2(nOut = 1, nIn = 1)
  PNlib.Components.TC T3(nIn = 1, maximumSpeed = if time > 3 then 2 else 0)
equation
  connect(P1.outTransition[1], TA1.inPlace)
  connect(T1.outPlaces[1], P1.inTransition[1])
  connect(T2.outPlaces[1], P2.inTransition[1])
  connect(T3.inPlaces[1], P1.outTransition[2])
  connect(TA1.outTransition, T2.inPlaces[1])
end TAwithWeaklyActivation;


within PNlib.Examples.ExtTest;

model TDSdiscrete
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(nOut = 1, startTokens = 18)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.TDS T1(distributionType = PNlib.Types.DistributionType.Discrete, localSeed = 1, nIn = 1, nOut = 1)
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
end TDSdiscrete;


within PNlib.Examples.ExtTest;

model TDSTest
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(nOut = 1, startTokens = 8)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.TDS T1(localSeed = 1, nIn = 1, nOut = 1)
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
end TDSTest;


within PNlib.Examples.ExtTest;

model TDSTestinterrupt
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(nIn = 1, nOut = 2, startTokens = 1)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.TDS T1(a = 0.5, b = 1.5, c = 1, distributionType = PNlib.Types.DistributionType.Triangular, localSeed = 1, nIn = 1, nOut = 1)
  PNlib.Components.TE T2(event = {0.4}, nIn = 1)
  PNlib.Components.TE T3(event = {2, 4}, nOut = 1)
equation
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(P1.outTransition[2], T2.inPlaces[1])
  connect(T3.outPlaces[1], P1.inTransition[1])
end TDSTestinterrupt;


within PNlib.Examples.ExtTest;

model TDStriangular
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(nOut = 1, startTokens = 8)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.TDS T1(distributionType = PNlib.Types.DistributionType.Triangular, localSeed = 1, nIn = 1, nOut = 1)
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
end TDStriangular;


within PNlib.Examples.ExtTest;

model TDStruncatednormal
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(nOut = 1, startTokens = 8)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.TDS T1(distributionType = PNlib.Types.DistributionType.TruncatedNormal, localSeed = 1, nIn = 1, nOut = 1)
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
end TDStruncatednormal;


within PNlib.Examples.ExtTest;

model TDSuniform
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(nOut = 1, startTokens = 8)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.TDS T1(a = 2, b = 4, distributionType = PNlib.Types.DistributionType.Uniform, localSeed = 1, nIn = 1, nOut = 1)
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
end TDSuniform;


within PNlib.Examples.ExtTest;

model TESTest
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(nIn = 1, nOut = 1, startTokens = 1)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.TE T2(event = {3, 4, 5, 9}, nOut = 1)
  PNlib.Components.TES T1(distributionType = PNlib.Types.DistributionType.Triangular, nIn = 1, nOut = 1)
equation
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(T1.inPlaces[1], P1.outTransition[1])
  connect(T2.outPlaces[1], P1.inTransition[1])
end TESTest;


within PNlib.Examples.ExtTest;

model TFDStest
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PD P1(nIn = 0, nOut = 1, startTokens = 5)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.TFDS T1(b = 2, c = 1, distributionType = PNlib.Types.DistributionType.Triangular, localSeed = 5, nIn = 1, nOut = 1)
equation
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
end TFDStest;


within PNlib.Examples.HybTest;

model ConflictPrio
  extends Modelica.Icons.Example;
  PNlib.Components.PC P1(nIn = 1, nOut = 2, startMarks = 2)
  PNlib.Components.TD T1(nIn = 1, nOut = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.PD P3(nIn = 1)
  PNlib.Components.TD T3(nOut = 1)
  inner PNlib.Components.Settings settings
equation
  connect(T3.outPlaces[1], P1.inTransition[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(T2.inPlaces[1], P1.outTransition[2])
  connect(T2.outPlaces[1], P3.inTransition[1])
end ConflictPrio;


within PNlib.Examples.HybTest;

model ConflictProb
  extends Modelica.Icons.Example;
  PNlib.Components.PC P1(nIn = 1, nOut = 2, enablingType = PNlib.Types.EnablingType.Probability, startMarks = 2, localSeedIn = 1, localSeedOut = 2)
  PNlib.Components.TD T1(nIn = 1, nOut = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
  PNlib.Components.PD P2(nIn = 1, localSeedIn = 3, localSeedOut = 4)
  PNlib.Components.PD P3(nIn = 1, localSeedIn = 5, localSeedOut = 6)
  PNlib.Components.TD T3(nOut = 1)
  inner PNlib.Components.Settings settings
equation
  connect(T3.outPlaces[1], P1.inTransition[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(T2.inPlaces[1], P1.outTransition[2])
  connect(T2.outPlaces[1], P3.inTransition[1])
end ConflictProb;


within PNlib.Examples.HybTest;

model ConflictType3
  extends Modelica.Icons.Example;
  PNlib.Components.PC P1(nIn = 1, nOut = 2, startMarks = 2)
  PNlib.Components.TC T1(nIn = 1, nOut = 1, maximumSpeed = 2)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
  PNlib.Components.PC P2(nIn = 1)
  PNlib.Components.PD P3(nIn = 1)
  PNlib.Components.TC T3(nOut = 1)
  inner PNlib.Components.Settings settings
equation
  connect(T3.outPlaces[1], P1.inTransition[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(T2.inPlaces[1], P1.outTransition[2])
  connect(T2.outPlaces[1], P3.inTransition[1])
end ConflictType3;


within PNlib.Examples.HybTest;

model ConflictType4
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PC P1(nOut = 1, startMarks = 10)
  PNlib.Components.PC P2(nIn = 1)
  PNlib.Components.PC P3(nOut = 1, startMarks = 10)
  PNlib.Components.PC P4(nIn = 1)
  PNlib.Components.TC T1(nIn = 2, nOut = 2)
  PNlib.Components.TC T2(nIn = 2, nOut = 2)
  PNlib.Components.PD P5(nOut = 2, nIn = 2, startTokens = 1)
equation
  connect(P1.outTransition[1], T2.inPlaces[1])
  connect(T2.outPlaces[1], P2.inTransition[1])
  connect(P5.outTransition[1], T2.inPlaces[2])
  connect(T2.outPlaces[2], P5.inTransition[1])
  connect(P3.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P4.inTransition[1])
  connect(P5.outTransition[2], T1.inPlaces[2])
  connect(P5.inTransition[2], T1.outPlaces[2])
end ConflictType4;


within PNlib.Examples.HybTest;

model EightConflictProb
  extends Modelica.Icons.Example;
  PNlib.Components.PC P1(enablingType = PNlib.Types.EnablingType.Probability, nOut = 8, startMarks = 1, localSeedIn = 1, localSeedOut = 2)
  PNlib.Components.TD T1(nIn = 1)
  PNlib.Components.TD T2(nIn = 1)
  PNlib.Components.TD T3(nIn = 1)
  PNlib.Components.TD T4(nIn = 1)
  PNlib.Components.TD T5(nIn = 1)
  PNlib.Components.TD T6(nIn = 1)
  PNlib.Components.TD T7(nIn = 1)
  PNlib.Components.TD T8(nIn = 1)
  inner PNlib.Components.Settings settings
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T2.inPlaces[1], P1.outTransition[2])
  connect(T3.inPlaces[1], P1.outTransition[3])
  connect(T4.inPlaces[1], P1.outTransition[4])
  connect(T5.inPlaces[1], P1.outTransition[5])
  connect(T6.inPlaces[1], P1.outTransition[6])
  connect(T7.inPlaces[1], P1.outTransition[7])
  connect(T8.inPlaces[1], P1.outTransition[8])
end EightConflictProb;


within PNlib.Examples.HybTest;

model HybLoopAndArcweight
  extends Modelica.Icons.Example;
  PNlib.Components.PC P1(nOut = 1, nIn = 1, startMarks = 2)
  PNlib.Components.TD T1(nIn = 1, nOut = 1, arcWeightIn = {1.5}, arcWeightOut = {2.5})
  inner PNlib.Components.Settings settings
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P1.inTransition[1])
end HybLoopAndArcweight;


within PNlib.Examples.HybTest;

model InputConflictPrio
  extends Modelica.Icons.Example;
  PNlib.Components.PC P1(nIn = 2, nOut = 1, maxMarks = 2)
  PNlib.Components.TD T1(nIn = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
  PNlib.Components.TD T3(nIn = 1, nOut = 1)
  PNlib.Components.PD P2(startTokens = 5, nOut = 1)
  PNlib.Components.PD P3(startTokens = 5, nOut = 1)
  inner PNlib.Components.Settings settings
equation
  connect(P2.outTransition[1], T2.inPlaces[1])
  connect(P3.outTransition[1], T3.inPlaces[1])
  connect(T2.outPlaces[1], P1.inTransition[1])
  connect(T3.outPlaces[1], P1.inTransition[2])
  connect(T1.inPlaces[1], P1.outTransition[1])
end InputConflictPrio;


within PNlib.Examples.HybTest;

model InputConflictProb
  extends Modelica.Icons.Example;
  PNlib.Components.PC P1(nIn = 2, nOut = 1, enablingType = PNlib.Types.EnablingType.Probability, maxMarks = 2, localSeedIn = 1, localSeedOut = 2)
  PNlib.Components.TD T1(nIn = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
  PNlib.Components.TD T3(nIn = 1, nOut = 1)
  PNlib.Components.PD P2(startTokens = 5, nOut = 1, localSeedIn = 3, localSeedOut = 4)
  PNlib.Components.PD P3(startTokens = 5, nOut = 1, localSeedIn = 5, localSeedOut = 6)
  inner PNlib.Components.Settings settings
equation
  connect(P2.outTransition[1], T2.inPlaces[1])
  connect(P3.outTransition[1], T3.inPlaces[1])
  connect(T2.outPlaces[1], P1.inTransition[1])
  connect(T3.outPlaces[1], P1.inTransition[2])
  connect(T1.inPlaces[1], P1.outTransition[1])
end InputConflictProb;


within PNlib.Examples.HybTest;

model InputConflictType3
  extends Modelica.Icons.Example;
  PNlib.Components.PC P1(nIn = 2, nOut = 1, maxMarks = 2)
  PNlib.Components.TC T1(nIn = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
  PNlib.Components.TC T3(nIn = 1, nOut = 1, maximumSpeed = 2)
  PNlib.Components.PD P2(startTokens = 5, nOut = 1)
  PNlib.Components.PC P3(nOut = 1, startMarks = 5)
  inner PNlib.Components.Settings settings
equation
  connect(P2.outTransition[1], T2.inPlaces[1])
  connect(P3.outTransition[1], T3.inPlaces[1])
  connect(T2.outPlaces[1], P1.inTransition[1])
  connect(T3.outPlaces[1], P1.inTransition[2])
  connect(T1.inPlaces[1], P1.outTransition[1])
end InputConflictType3;


within PNlib.Examples.HybTest;

model OutputConflictPrio
  extends Modelica.Icons.Example;
  PNlib.Components.PC P1(nIn = 1, nOut = 2, minMarks = 2, startMarks = 4)
  PNlib.Components.TD T1(nIn = 1, nOut = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
  PNlib.Components.PD P2(nIn = 1)
  PNlib.Components.PD P3(nIn = 1)
  PNlib.Components.TD T3(nOut = 1)
  inner PNlib.Components.Settings settings
equation
  connect(T3.outPlaces[1], P1.inTransition[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(T2.inPlaces[1], P1.outTransition[2])
  connect(T2.outPlaces[1], P3.inTransition[1])
end OutputConflictPrio;


within PNlib.Examples.HybTest;

model OutputConflictProb
  extends Modelica.Icons.Example;
  PNlib.Components.PC P1(nIn = 1, nOut = 2, enablingType = PNlib.Types.EnablingType.Probability, minMarks = 2, startMarks = 4, localSeedIn = 1, localSeedOut = 2)
  PNlib.Components.TD T1(nIn = 1, nOut = 1)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
  PNlib.Components.PD P2(nIn = 1, localSeedIn = 3, localSeedOut = 4)
  PNlib.Components.PD P3(nIn = 1, localSeedIn = 5, localSeedOut = 6)
  PNlib.Components.TD T3(nOut = 1)
  inner PNlib.Components.Settings settings
equation
  connect(T3.outPlaces[1], P1.inTransition[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(T2.inPlaces[1], P1.outTransition[2])
  connect(T2.outPlaces[1], P3.inTransition[1])
end OutputConflictProb;


within PNlib.Examples.HybTest;

model OutputConflictType3
  extends Modelica.Icons.Example;
  PNlib.Components.PC P1(nIn = 1, nOut = 2, startMarks = 2)
  PNlib.Components.TC T1(nIn = 1, nOut = 1, maximumSpeed = 2)
  PNlib.Components.TD T2(nIn = 1, nOut = 1)
  PNlib.Components.PC P2(nIn = 1)
  PNlib.Components.PD P3(nIn = 1)
  PNlib.Components.TC T3(nOut = 1)
  inner PNlib.Components.Settings settings
equation
  connect(T3.outPlaces[1], P1.inTransition[1])
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(T2.inPlaces[1], P1.outTransition[2])
  connect(T2.outPlaces[1], P3.inTransition[1])
end OutputConflictType3;


within PNlib.Examples.HybTest;

model PCtoTD
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PC P1(nOut = 1, startMarks = 8)
  PNlib.Components.TD T1(nIn = 1, delay = 1, arcWeightIn = {1})
equation
  connect(T1.inPlaces[1], P1.outTransition[1])
end PCtoTD;


within PNlib.Examples.HybTest;

model PCtoTDfunction
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PC P1(nOut = 1, startMarks = 5)
  PNlib.Components.TD T1(nIn = 1, arcWeightIn = {P1.t})
equation
  connect(T1.inPlaces[1], P1.outTransition[1])
end PCtoTDfunction;


within PNlib.Examples.HybTest;

model SixConflictProb
  extends Modelica.Icons.Example;
  PNlib.Components.PC P1(enablingType = PNlib.Types.EnablingType.Probability, nOut = 6, startMarks = 1, localSeedIn = 1, localSeedOut = 2)
  PNlib.Components.TD T1(nIn = 1)
  PNlib.Components.TD T2(nIn = 1)
  PNlib.Components.TD T3(nIn = 1)
  PNlib.Components.TD T4(nIn = 1)
  PNlib.Components.TD T5(nIn = 1)
  PNlib.Components.TD T6(nIn = 1)
  inner PNlib.Components.Settings settings
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T2.inPlaces[1], P1.outTransition[2])
  connect(T3.inPlaces[1], P1.outTransition[3])
  connect(T4.inPlaces[1], P1.outTransition[4])
  connect(T5.inPlaces[1], P1.outTransition[5])
  connect(T6.inPlaces[1], P1.outTransition[6])
end SixConflictProb;


within PNlib.Examples.HybTest;

model TCwithPD
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Components.PC P1(nOut = 1, startMarks = 10)
  PNlib.Components.PC P2(nIn = 1)
  PNlib.Components.TC T1(nIn = 2, nOut = 2, arcWeightIn = {2, 1}, firingCon = true)
  PNlib.Components.PD P3(nOut = 1, nIn = 1, startTokens = 10)
equation
  connect(P1.outTransition[1], T1.inPlaces[1])
  connect(T1.outPlaces[1], P2.inTransition[1])
  connect(P3.outTransition[1], T1.inPlaces[2])
  connect(T1.outPlaces[2], P3.inTransition[1])
end TCwithPD;


within PNlib.Examples.HybTest;

model TDtoPC
  extends Modelica.Icons.Example;
  PNlib.Components.PC P1(nOut = 0, nIn = 1)
  PNlib.Components.TD T1(nOut = 1, arcWeightOut = {1})
  inner PNlib.Components.Settings settings
equation
  connect(P1.inTransition[1], T1.outPlaces[1])
end TDtoPC;


within PNlib.Examples.HybTest;

model TDtoPCfunction
  extends Modelica.Icons.Example;
  PNlib.Components.PC P1(nIn = 1, startMarks = 5)
  PNlib.Components.TD T1(nOut = 1, arcWeightOut = {P1.t})
  inner PNlib.Components.Settings settings
equation
  connect(P1.inTransition[1], T1.outPlaces[1])
end TDtoPCfunction;


Model of a flush toilet.

within PNlib.Examples.Models;

model FlushToilet "Model of a flush toilet"
  import PNlib.Components.*;
  extends Modelica.Icons.Example;
  PD Lever(nIn = 1, maxTokens = 1, nOut = 1) "Lever of the toilet"
  TD pushing(nOut = 1, arcWeightIn = {1}, nIn = 1, delay = 3) "visitor pushes the lever"
  TD lifting(nOut = 1, nIn = 1, delay = 0.02) "Lift the flush valve flapper"
  PD FlushValveFlapper(nIn = 1, nOut = 3, maxTokens = 1)
  TC flowing(nOut = 1, nIn = 3, arcWeightIn = {0, 1, 2.5}, maximumSpeed = 5) "Water flows in the bowl"
  PC WaterInBowl(nIn = 1, nOut = 1) "Water in the toilet bowl"
  TA TA1(testValue = 0)
  PC WaterInTank(nOut = 1, nIn = 1, maxMarks = 12, startMarks = 12) "Water in the toilet tank"
  PC LevelOfFloat(nOut = 3, nIn = 1, maxMarks = 30, startMarks = 30) "Level of the float"
  TD opening(nOut = 1, nIn = 1, arcWeightIn = {6}, delay = 0.1) "Open the tank fill valve"
  PD TankFillValve(nIn = 1, nOut = 2, maxTokens = 1)
  TC filling(nIn = 1, nOut = 2, arcWeightOut = {2.5, 1}, arcWeightIn = {0}, maximumSpeed = 6) "Water flows to the toilet tank"
  TA TA3(testValue = 0)
  IA IA1(testValue = 6)
  TA TA2(testValue = 29.9)
  TD closing(nIn = 2, arcWeightIn = {1, 29.999}, delay = 0.1) "Close the tank fill valve"
  TD sinking(nIn = 1, delay = 2) "Sink the flush valve flapper"
  TC Sewer(nIn = 1, maximumSpeed = 4) "Sewer"
  inner Settings settings(scale = 5, timeFire = 0.1)
  PD Visitor(nOut = 1, nIn = 1, startTokens = 1, maxTokens = 1) "Visitor of the toilet"
  TDS entering(nOut = 1, nIn = 1, h = 1/10) "Visitor enters the toilet"
  IA IA2
equation
  connect(pushing.outPlaces[1], Lever.inTransition[1])
  connect(lifting.outPlaces[1], FlushValveFlapper.inTransition[1])
  connect(flowing.outPlaces[1], WaterInBowl.inTransition[1])
  connect(FlushValveFlapper.outTransition[1], TA1.inPlace)
  connect(TA1.outTransition, flowing.inPlaces[1])
  connect(WaterInTank.outTransition[1], flowing.inPlaces[2])
  connect(LevelOfFloat.outTransition[1], flowing.inPlaces[3])
  connect(opening.outPlaces[1], TankFillValve.inTransition[1])
  connect(TankFillValve.outTransition[1], TA3.inPlace)
  connect(TA3.outTransition, filling.inPlaces[1])
  connect(filling.outPlaces[1], LevelOfFloat.inTransition[1])
  connect(IA1.outTransition, opening.inPlaces[1])
  connect(LevelOfFloat.outTransition[2], IA1.inPlace)
  connect(filling.outPlaces[2], WaterInTank.inTransition[1])
  connect(LevelOfFloat.outTransition[3], TA2.inPlace)
  connect(TankFillValve.outTransition[2], closing.inPlaces[1])
  connect(TA2.outTransition, closing.inPlaces[2])
  connect(WaterInBowl.outTransition[1], Sewer.inPlaces[1])
  connect(Lever.outTransition[1], lifting.inPlaces[1])
  connect(FlushValveFlapper.outTransition[2], sinking.inPlaces[1])
  connect(Visitor.outTransition[1], pushing.inPlaces[1])
  connect(entering.outPlaces[1], Visitor.inTransition[1])
  connect(FlushValveFlapper.outTransition[3], IA2.inPlace)
  connect(IA2.outTransition, entering.inPlaces[1])
end FlushToilet;


within PNlib.Examples;

package Models "contains several examples and offers the possibility to structure further Petri net models"
  extends Modelica.Icons.ExamplesPackage;
end Models;


within PNlib.Examples.Models.BicoloredPlaces;

model Aquarium
  extends Modelica.Icons.Example;
  inner PNlib.Components.Settings settings
  PNlib.Examples.Models.BicoloredPlaces.CPC P1(nIn = 1, nOut = 1, startMarks = {50, 0})
  PNlib.Examples.Models.BicoloredPlaces.CPC P2(nIn = 1, startMarks = {0, 0})
  PNlib.Examples.Models.BicoloredPlaces.CTC t1(nOut = 1, arcWeightOut = {{0, 1}})
  PNlib.Examples.Models.BicoloredPlaces.CTC t2(nIn = 1, nOut = 1, arcWeightIn = {{P1.color[1]/(P1.color[1] + P1.color[2]), P1.color[2]/(P1.color[1] + P1.color[2])}}, arcWeightOut = {{P1.color[1]/(P1.color[1] + P1.color[2]), P1.color[2]/(P1.color[1] + P1.color[2])}})
  Real ratio = P1.color[2]/(P1.color[1] + P1.color[2]);
equation
  connect(t1.outPlaces[1], P1.inTransition[1])
  connect(P1.outTransition[1], t2.inPlaces[1])
  connect(t2.outPlaces[1], P2.inTransition[1])
end Aquarium;