-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New transition T without time == 0 out of 93 tests failed [Testing/OpenModelica, time: 1590]
- Loading branch information
Showing
16 changed files
with
597 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
within PNlib.Examples.DisTest; | ||
model Ttest | ||
extends Modelica.Icons.Example; | ||
inner PNlib.Settings settings annotation(Placement(visible = true, transformation(extent = {{-80, 20}, {-60, 40}}, rotation = 0))); | ||
PNlib.PD P1(nIn = 1,nOut = 1, startTokens = 0) annotation(Placement(visible = true, transformation(extent = {{-46, -12}, {-26, 8}}, rotation = 0))); | ||
PNlib.TE T2(event = {1, 2, 3, 4}, nOut = 1) annotation( | ||
Placement(visible = true, transformation(origin = {-62, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); | ||
PNlib.PD P2(nIn = 1, nOut = 2) annotation( | ||
Placement(visible = true, transformation(origin = {12, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); | ||
PNlib.T T1(arcWeightIn = {2}, arcWeightOut = {3}, nIn = 1, nOut = 1) annotation( | ||
Placement(visible = true, transformation(origin = {-12, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); | ||
PNlib.T T3(arcWeightIn = {2}, arcWeightOut = {2},nIn = 1, nOut = 1) annotation( | ||
Placement(visible = true, transformation(origin = {40, 22}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); | ||
PNlib.PD P3(nIn = 1) annotation( | ||
Placement(visible = true, transformation(origin = {64, 22}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); | ||
PNlib.T T4(arcWeightIn = {2}, arcWeightOut = {2},nIn = 1, nOut = 1) annotation( | ||
Placement(visible = true, transformation(origin = {42, -22}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); | ||
PNlib.PD P4(nIn = 1) annotation( | ||
Placement(visible = true, transformation(origin = {66, -22}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); | ||
equation | ||
connect(T4.inPlaces[1], P2.outTransition[2]) annotation( | ||
Line(points = {{38, -22}, {30, -22}, {30, -2}, {22, -2}, {22, -2}}, thickness = 0.5)); | ||
connect(T4.outPlaces[1], P4.inTransition[1]) annotation( | ||
Line(points = {{47, -22}, {56, -22}}, thickness = 0.5)); | ||
connect(T3.outPlaces[1], P3.inTransition[1]) annotation( | ||
Line(points = {{44.8, 22}, {54.8, 22}, {54.8, 22}, {54.8, 22}}, thickness = 0.5)); | ||
connect(T3.inPlaces[1], P2.outTransition[1]) annotation( | ||
Line(points = {{35, 20}, {29, 20}, {29, -2}, {22, -2}}, thickness = 0.5)); | ||
connect(T1.outPlaces[1], P2.inTransition[1]) annotation( | ||
Line(points = {{-7, -2}, {-1, -2}}, thickness = 0.5)); | ||
connect(P1.outTransition[1], T1.inPlaces[1]) annotation( | ||
Line(points = {{-25, -2}, {-15, -2}}, thickness = 0.5)); | ||
connect(T2.outPlaces[1], P1.inTransition[1]) annotation( | ||
Line(points = {{-57.2, -2}, {-45, -2}})); | ||
annotation(Diagram(coordinateSystem(preserveAspectRatio = false, extent={{-80, -40}, | ||
{80, 40}}), graphics), experiment(StartTime=0.0, StopTime=5.0, Tolerance = 1e-6)); | ||
end Ttest; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,4 @@ EightConflictProb | |
PrioTest | ||
NoInputConflict | ||
FiveTimes | ||
Ttest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
within PNlib.Functions.Enabling; | ||
function benefitBaBConIn "Enabling Input Transition by Benefit and Branch and Bound" | ||
extends Modelica.Icons.Function; | ||
input Integer depth; | ||
input Integer nIn "number of input transitions"; | ||
input Real benefit[:] "enabling benefit of input transitions"; | ||
input Integer arcWeight[:] "arc weights of input transitions"; | ||
input Real Quotient[:] "benefit Quotient"; | ||
input Integer t "current token number"; | ||
input Real benefitMaxIn "theoretical benefit input"; | ||
input Integer maxTokens "maximum capacity"; | ||
input Boolean TEinIn[:] "enabled input transitions input"; | ||
input Integer TokenIn "used token input"; | ||
input Real benefitLimitIn "best valid benefit input"; | ||
input Boolean TAein[:] "active previous transitions which are already enabled by their input places"; | ||
input Boolean disTransition[:] "discrete input transition"; | ||
output Boolean TEinOut[nIn] "enabled input transitions output"; | ||
output Integer TokenOut "used token output"; | ||
output Real benefitMaxOut "theoretical benefit output"; | ||
output Boolean valid "valid solution"; | ||
output Real benefitLimitOut "best valid benefit Output"; | ||
protected | ||
Real benefitLimit "best valid benefit"; | ||
Real Quotient_[nIn] "new benefitb Quotient"; | ||
Real MaxBenefit "max benefit Quotient"; | ||
Integer Index "index of max benefit Quotient"; | ||
Boolean TEinOut1[nIn] "enabled input transitions output of partial solution 1"; | ||
Integer TokenOut1 "used token output of partial solution 1"; | ||
Real benefitMaxOut1 "theoretical benefit output of partial solution 1"; | ||
Boolean valid1"valid solution of partial solution 1"; | ||
Boolean TEinOut2[nIn] "enabled output transitions output of partial solution 2"; | ||
Integer TokenOut2 "used token output of partial solution 2"; | ||
Real benefitMaxOut2 "theoretical benefit output of partial solution 2"; | ||
Boolean valid2 "valid solution of partial solution 2"; | ||
algorithm | ||
// starting values | ||
benefitLimitOut:=benefitLimitIn; | ||
benefitLimit:=benefitLimitIn; | ||
TEinOut:= TEinIn; | ||
TEinOut1:= TEinIn; | ||
TEinOut2:= TEinIn; | ||
Quotient_:=Quotient; | ||
TokenOut :=TokenIn; | ||
// max benefit Quotient | ||
MaxBenefit:=max(Quotient_); | ||
Index:=Modelica.Math.Vectors.find(MaxBenefit,Quotient_); | ||
// quotient update | ||
Quotient_[Index]:=-1; | ||
if not TAein[Index] or not disTransition[Index] then | ||
(TEinOut,TokenOut ,benefitMaxOut, valid, benefitLimitOut):=benefitBaBConIn(depth+1, nIn, benefit, arcWeight, Quotient_, t, benefitMaxIn-benefit[Index], maxTokens, TEinOut, TokenOut, benefitLimit, TAein, disTransition); | ||
return; | ||
end if; | ||
// partial solution 1 | ||
TEinOut1[Index] := true; | ||
TokenOut1 := TokenIn + arcWeight[Index]; | ||
benefitMaxOut1:= benefitMaxIn; | ||
// partial solution 2 | ||
TEinOut2[Index] := false; | ||
benefitMaxOut2:= benefitMaxIn-benefit[Index]; | ||
TokenOut2 := TokenIn; | ||
// branch solution | ||
if depth < nIn then // no finished solution | ||
if t+TokenOut1 <=maxTokens and benefitMaxOut1>=benefitLimit then | ||
(TEinOut1,TokenOut1 ,benefitMaxOut1, valid1, benefitLimit):=benefitBaBConIn(depth+1, nIn, benefit, arcWeight, Quotient_, t, benefitMaxOut1, maxTokens, TEinOut1, TokenOut1, benefitLimit, TAein, disTransition); | ||
else | ||
valid1:=false; | ||
end if; | ||
if t+TokenOut2 <= maxTokens and benefitMaxOut2>=benefitLimit then | ||
(TEinOut2,TokenOut2 ,benefitMaxOut2, valid2 , benefitLimit):=benefitBaBConIn(depth+1, nIn, benefit, arcWeight, Quotient_, t, benefitMaxOut2, maxTokens, TEinOut2, TokenOut2, benefitLimit, TAein, disTransition); | ||
else | ||
valid2:=false; | ||
end if; | ||
else // finished solution | ||
if t+TokenOut1 <= maxTokens and benefitMaxOut1>=benefitLimit then | ||
valid1:=true; | ||
benefitLimit:=benefitMaxOut1; | ||
else | ||
valid1:=false; | ||
end if; | ||
if t+TokenOut2 <= maxTokens and benefitMaxOut2>=benefitLimit then | ||
valid2:=true; | ||
benefitLimit:=benefitMaxOut2; | ||
else | ||
valid2:=false; | ||
end if; | ||
end if; | ||
// output the solution | ||
if valid1 and benefitMaxOut1>=benefitLimit then | ||
TEinOut:=TEinOut1; | ||
TokenOut:=TokenOut1; | ||
benefitMaxOut:=benefitMaxOut1; | ||
valid:=true; | ||
benefitLimitOut:=benefitLimit; | ||
elseif valid2 and benefitMaxOut2>=benefitLimit then | ||
TEinOut:=TEinOut2; | ||
TokenOut:=TokenOut2; | ||
benefitMaxOut:=benefitMaxOut2; | ||
valid:=true; | ||
benefitLimitOut:=benefitLimit; | ||
end if; | ||
end benefitBaBConIn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
within PNlib.Functions.Enabling; | ||
function benefitBaBConOut "Enabling Output Transition by Benefit and Branch and Bound" | ||
extends Modelica.Icons.Function; | ||
input Integer depth; | ||
input Integer nOut "number of output transitions"; | ||
input Real benefit[:] "enabling benefit of output transitions"; | ||
input Integer arcWeight[:] "arc weights of output transitions"; | ||
input Real Quotient[:] "benefit Quotient"; | ||
input Integer t "current token number"; | ||
input Real benefitMaxIn "theoretical benefit input"; | ||
input Integer minTokens "minimum capacity"; | ||
input Boolean TEoutIn[:] "enabled output transitions input"; | ||
input Integer TokenIn "used token input"; | ||
input Real benefitLimitIn "best valid benefit input"; | ||
input Boolean TAout[:] "active output transitions with passed delay"; | ||
input Boolean disTransition[:] "discrete output transition"; | ||
output Boolean TEoutOut[nOut] "enabled output transitions output"; | ||
output Integer TokenOut "used token output"; | ||
output Real benefitMaxOut "theoretical benefit output"; | ||
output Boolean valid "valid solution"; | ||
output Real benefitLimitOut "best valid benefit Output"; | ||
protected | ||
Real benefitLimit "best valid benefit"; | ||
Real Quotient_[nOut] "new benefitb Quotient"; | ||
Real MaxBenefit "max benefit Quotient"; | ||
Integer Index "index of max benefit Quotient"; | ||
Boolean TEoutOut1[nOut] "enabled output transitions output of partial solution 1"; | ||
Integer TokenOut1 "used token output of partial solution 1"; | ||
Real benefitMaxOut1 "theoretical benefit output of partial solution 1"; | ||
Boolean valid1 "valid solution of partial solution 1"; | ||
Boolean TEoutOut2[nOut] "enabled output transitions output of partial solution 2"; | ||
Integer TokenOut2 "used token output of partial solution 2"; | ||
Real benefitMaxOut2 "theoretical benefit output of partial solution 2"; | ||
Boolean valid2 "valid solution of partial solution 2"; | ||
algorithm | ||
// starting values | ||
benefitLimitOut:=benefitLimitIn; | ||
benefitLimit:=benefitLimitIn; | ||
TEoutOut:= TEoutIn; | ||
TEoutOut1:= TEoutIn; | ||
TEoutOut2:= TEoutIn; | ||
Quotient_:=Quotient; | ||
TokenOut :=TokenIn; | ||
// max benefit Quotient | ||
MaxBenefit:=max(Quotient_); | ||
Index:=Modelica.Math.Vectors.find(MaxBenefit,Quotient_); | ||
// quotient update | ||
Quotient_[Index]:=-1; | ||
if not TAout[Index] or not disTransition[Index] then | ||
(TEoutOut,TokenOut ,benefitMaxOut, valid, benefitLimitOut):=benefitBaBConOut(depth+1, nOut, benefit, arcWeight, Quotient_, t, benefitMaxIn-benefit[Index], minTokens, TEoutOut, TokenOut, benefitLimit, TAout, disTransition); | ||
return; | ||
end if; | ||
// partial solution 1 | ||
TEoutOut1[Index] := true; | ||
TokenOut1 := TokenIn + arcWeight[Index]; | ||
benefitMaxOut1:= benefitMaxIn; | ||
// partial solution 2 | ||
TEoutOut2[Index] := false; | ||
benefitMaxOut2:= benefitMaxIn-benefit[Index]; | ||
TokenOut2 := TokenIn; | ||
// branch solution | ||
if depth < nOut then // no finished solution | ||
if t-TokenOut1 >= minTokens and benefitMaxOut1>=benefitLimit then | ||
(TEoutOut1,TokenOut1 ,benefitMaxOut1, valid1, benefitLimit):=benefitBaBConOut(depth+1, nOut, benefit, arcWeight, Quotient_, t, benefitMaxOut1, minTokens, TEoutOut1, TokenOut1, benefitLimit, TAout, disTransition); | ||
else | ||
valid1:=false; | ||
end if; | ||
if t-TokenOut2 >= minTokens and benefitMaxOut2>=benefitLimit then | ||
(TEoutOut2,TokenOut2 ,benefitMaxOut2, valid2 , benefitLimit):=benefitBaBConOut(depth+1, nOut, benefit, arcWeight, Quotient_, t, benefitMaxOut2, minTokens, TEoutOut2, TokenOut2, benefitLimit, TAout, disTransition); | ||
else | ||
valid2:=false; | ||
end if; | ||
else // finished solution | ||
if t-TokenOut1 >= minTokens and benefitMaxOut1>=benefitLimit then | ||
valid1:=true; | ||
benefitLimit:=benefitMaxOut1; | ||
else | ||
valid1:=false; | ||
end if; | ||
if t-TokenOut2 >= minTokens and benefitMaxOut2>=benefitLimit then | ||
valid2:=true; | ||
benefitLimit:=benefitMaxOut2; | ||
else | ||
valid2:=false; | ||
end if; | ||
end if; | ||
// output the solution | ||
if valid1 and benefitMaxOut1>=benefitLimit then | ||
TEoutOut:=TEoutOut1; | ||
TokenOut:=TokenOut1; | ||
benefitMaxOut:=benefitMaxOut1; | ||
valid:=true; | ||
benefitLimitOut:=benefitLimit; | ||
elseif valid2 and benefitMaxOut2>=benefitLimit then | ||
TEoutOut:=TEoutOut2; | ||
TokenOut:=TokenOut2; | ||
benefitMaxOut:=benefitMaxOut2; | ||
valid:=true; | ||
benefitLimitOut:=benefitLimit; | ||
end if; | ||
end benefitBaBConOut; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
within PNlib.Functions.Enabling; | ||
function benefitGreedyConIn "Enabling Input Transition by Benefit and Greedy" | ||
extends Modelica.Icons.Function; | ||
input Integer nIn "number of input transitions"; | ||
input Real arcWeight[:] "arc weights of input transitions"; | ||
input Real t "current token number"; | ||
input Real maxTokens "maximum capacity"; | ||
input Boolean TAein[:] "active previous transitions which are already enabled by their input places"; | ||
input Real enablingBene[:] "enabling benefit of input transitions"; | ||
input Boolean disTransition[:] "type of input transitions"; | ||
output Boolean TEin[nIn] "enabled input transitions"; | ||
protected | ||
Real arcWeightSum "arc weight sum"; | ||
Integer Index "priority Index"; | ||
Real MaxBenefit "Max Benefit"; | ||
Real enablingBene_[nIn] "Benefit"; | ||
algorithm | ||
TEin:=fill(false, nIn); | ||
enablingBene_:=enablingBene; | ||
arcWeightSum := 0; | ||
for i in 1: nIn loop //discrete transitions are proven at first | ||
MaxBenefit:=max(enablingBene_); | ||
Index:=Modelica.Math.Vectors.find(MaxBenefit,enablingBene_); | ||
if Index>0 and TAein[Index] and disTransition[Index] and t+arcWeightSum+arcWeight[Index]-maxTokens <= Constants.almost_eps then | ||
TEin[Index] := true; | ||
arcWeightSum := arcWeightSum + arcWeight[Index]; | ||
end if; | ||
enablingBene_[Index]:=-1; | ||
end for; | ||
enablingBene_:=enablingBene; | ||
for i in 1: nIn loop //continuous transitions afterwards (discrete transitions have priority over continuous transitions) | ||
MaxBenefit:=max(enablingBene_); | ||
Index:=Modelica.Math.Vectors.find(MaxBenefit,enablingBene_); | ||
if Index>0 and TAein[Index] and not disTransition[Index] and t+arcWeightSum+arcWeight[Index]-maxTokens <= Constants.almost_eps then | ||
TEin[Index] := true; | ||
arcWeightSum := arcWeightSum + arcWeight[Index]; | ||
end if; | ||
enablingBene_[Index]:=-1; | ||
end for; | ||
end benefitGreedyConIn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
within PNlib.Functions.Enabling; | ||
function benefitGreedyConOut "Enabling Output Transition by Benefit and Greedy" | ||
extends Modelica.Icons.Function; | ||
input Integer nOut "number of output transitions"; | ||
input Real arcWeight[:] "arc weights of output transitions"; | ||
input Real t "current token number"; | ||
input Real minTokens "minimum capacity"; | ||
input Boolean TAout[:] "active output transitions with passed delay"; | ||
input Real enablingBene[:] "enabling benefit of output transitions"; | ||
input Boolean disTransition[:] "discrete output transition"; | ||
output Boolean TEout[nOut] "enabled output transitions"; | ||
protected | ||
Real arcWeightSum "arc weight sum"; | ||
Integer Index "priority Index"; | ||
Real MaxBenefit "Max Benefit"; | ||
Real enablingBene_[nOut] "Benefit"; | ||
algorithm | ||
TEout:=fill(false, nOut); | ||
enablingBene_:=enablingBene; | ||
arcWeightSum := 0; | ||
for i in 1: nOut loop //discrete transitions are proven at first | ||
MaxBenefit:=max(enablingBene_); | ||
Index:=Modelica.Math.Vectors.find(MaxBenefit,enablingBene_); | ||
if Index>0 and TAout[Index] and disTransition[Index] and t-arcWeightSum-arcWeight[Index]-minTokens >= -Constants.almost_eps then | ||
TEout[Index] := true; | ||
arcWeightSum := arcWeightSum + arcWeight[Index]; | ||
end if; | ||
enablingBene_[Index]:=-1; | ||
end for; | ||
enablingBene_:=enablingBene; | ||
for i in 1: nOut loop //continuous transitions afterwards (discrete transitions have priority over continuous transitions) | ||
MaxBenefit:=max(enablingBene_); | ||
Index:=Modelica.Math.Vectors.find(MaxBenefit,enablingBene_); | ||
if Index>0 and TAout[Index] and not disTransition[Index] and t-arcWeightSum-arcWeight[Index]-minTokens >= -Constants.almost_eps then | ||
TEout[Index] := true; | ||
arcWeightSum := arcWeightSum + arcWeight[Index]; | ||
end if; | ||
enablingBene_[Index]:=-1; | ||
end for; | ||
end benefitGreedyConOut; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
within PNlib.Functions.Enabling; | ||
function benefitQuotientConIn "Enabling Input Transition by Benefit and Quotient" | ||
extends Modelica.Icons.Function; | ||
input Integer nIn "number of input transitions"; | ||
input Real arcWeight[:] "arc weights of input transitions"; | ||
input Real t "current token number"; | ||
input Real maxTokens "maximum capacity"; | ||
input Boolean TAein[:] "active previous transitions which are already enabled by their input places"; | ||
input Real enablingBene[:] "enabling benefit of input transitions"; | ||
input Boolean disTransition[:] "type of input transitions"; | ||
output Boolean TEin[nIn] "enabled input transitions"; | ||
protected | ||
Real arcWeightSum "arc weight sum"; | ||
Integer Index "priority Index"; | ||
Real MaxBenefit "Max Benefit"; | ||
Real enablingBeneQuo[nIn] "Benefit Quotient"; | ||
algorithm | ||
TEin:=fill(false, nIn); | ||
enablingBeneQuo:=enablingBene ./arcWeight; | ||
arcWeightSum := 0; | ||
for i in 1: nIn loop //discrete transitions are proven at first | ||
MaxBenefit:=max(enablingBeneQuo); | ||
Index:=Modelica.Math.Vectors.find(MaxBenefit,enablingBeneQuo); | ||
if Index>0 and TAein[Index] and disTransition[Index] and t+arcWeightSum+arcWeight[Index]-maxTokens <= Constants.almost_eps then | ||
TEin[Index] := true; | ||
arcWeightSum := arcWeightSum + arcWeight[Index]; | ||
end if; | ||
enablingBeneQuo[Index]:=-1; | ||
end for; | ||
enablingBeneQuo:=enablingBene ./arcWeight; | ||
for i in 1: nIn loop //continuous transitions afterwards (discrete transitions have priority over continuous transitions) | ||
MaxBenefit:=max(enablingBeneQuo); | ||
Index:=Modelica.Math.Vectors.find(MaxBenefit,enablingBeneQuo); | ||
if Index>0 and TAein[Index] and not disTransition[Index] and t+arcWeightSum+arcWeight[Index]-maxTokens <= Constants.almost_eps then | ||
TEin[Index] := true; | ||
arcWeightSum := arcWeightSum + arcWeight[Index]; | ||
end if; | ||
enablingBeneQuo[Index]:=-1; | ||
end for; | ||
end benefitQuotientConIn; |
Oops, something went wrong.