- java.lang.Object
-
- fr.inria.mochy.core.abstractClass.PhysicalModel
-
- fr.inria.mochy.core.mochysim.Net
-
public class Net extends PhysicalModel
A classic Net model with transitions, places and their state. It is loaded from a net file. A net contains transitions (actions) places (place holders for objects that are moved, consumed or produced) control places : they are used to allow or conversely disable transitions. the semantics is the following : as soon as a transition has all its places in its presset filled, a value is sampled. This is the time to fire (TTF, clock) of the transition. The time to fire decreases over time When the TTF reaches 0, the transition is firable. However, it can fire only if its control place is filled, and if the postset places of the net are free
-
-
Field Summary
Fields Modifier and Type Field Description HashMap<Integer,Transition>
blocked
list of blocked transitions : previous places marked, and at least one next place is marked and clock = 0HashMap<Integer,Transition>
enabled
list of enabled transitions : previous places marked and clock != 0HashMap<Integer,Transition>
firable
list of firable transitions : previous places marked, free next places, clock=0HashMap<Integer,Place>
places
the list of the places which have a content "marked" if there is one token or none then its content is "null"HashMap<Integer,Transition>
transitions
the list of the transitions which manage the time a token will stay at a place-
Fields inherited from class fr.inria.mochy.core.abstractClass.PhysicalModel
discreteStep, fname, nbDiscreteSteps, nbTokens, startLogs, stepsNb, timeElapsed, tokens
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Boolean
addControlToken(int pnum)
Adds a token in a control placeprotected void
addInFlow1(int tnum, int pnum)
adds a place in the preset of a transitionprotected void
addOutFlow(int tnum, int pnum)
adds a place in the postset of a transitionBoolean
addToken(int pnum)
Add a token in a standard placevoid
blockTransition(Transition t)
boolean
busyPostSet(Integer tnum)
boolean
controlAllowsFiring(Transition t)
Checks if the control places used as input to the current transition allow firing of tvoid
discreteMove()
perform a discrete move e.g.String
discreteMove(TransitionAbstract trans, String pathLogs, float elapsedTime, boolean enableLogs)
perform a discrete move e.g.boolean
discreteMove(String pathLogs, long elapsedTime, boolean enableLogs)
perform a discrete move e.g.boolean
discreteMoveWithControl(String pathLogs, long elapsedTime, boolean enableLogs)
void
drop()
display informations of the network modelString
dropConfig()
A method to display the contents of places in a StringPlace
findPlace(int pnum)
return the place as specified by its number in parameterTransition
findTransition(Integer tnum)
return the transition as specified by its number in parameterTransition
findTransition(String name)
return the transition as specified by its name in parameterArrayList<TransitionAbstract>
fireableTransition()
return the list of fireable transitionsHashMap<Integer,Transition>
getBlocked()
Place
getControlPlace(int pnum)
return a control place as specified by its number in parameterHashMap<Integer,Place>
getControlPlaces()
return the list of the control places which can be recovered by their id numberMarking
getCurrentMarking()
HashMap<Integer,Transition>
getEnabled()
get the list of the enabled transitions which can be retrieved by their id numberHashMap<Integer,Transition>
getFirable()
get the list of the fireable transitions which can be retrieved by their id numberString
getFname()
Place
getPlace(int pnum)
Find a place from its number This place can be a standard place or a control placeHashMap<Integer,Place>
getPlaces()
list the places which can be recovered with their numberLinkedHashMap<Integer,Token>
getTokens()
HashMap<Integer,Transition>
getTransitions()
list the transitions which can be recovered with their numberint
getWeibullCoef()
get the coefficient used for the weibull prob.protected String
handleLine(String line, int lineNb)
load a line of the input fileboolean
isAControlPace(int pnum)
Returns true if pnum is the number of a control placeboolean
isAControlPlace(int pnum)
Checks is a place is a control placesboolean
isBlocked(int tnum)
return true if the transition specified in parameter by its number is blockedboolean
isEnabled(Transition t)
boolean
isFirable(Transition t)
boolean
isGaussian()
return true if the prob.boolean
isWeibull()
return true if the prob.void
listEnabled()
String
loadFile()
Loads a net from a filefloat
maxAllowedTimedMove()
return the allowed timed move to be elapsed to perform a stepfloat
minimumClock()
return the minimum time to advance in order to update the status of tokens or transitionsvoid
multipleSteps(int steps)
perform the number of steps specified in parameter (timed move, discrete move, ...)ArrayList<Transition>
newlyEnabled(Marking m1, Marking m2, Transition t)
int
numberBlocked()
return the number of blocked transitionsint
numberFireable()
return the number of fireable transitionsvoid
progressTime(Float delta)
advance the time of the delta parameter value and update the status of the transitions (blocked, fireable...)void
reset(boolean init)
reset the network model to its initial statusvoid
setBlocked(HashMap<Integer,Transition> list)
void
setConfig(HashMap<Integer,Float> config)
void
setCurrentMarking(Marking currentMarking)
void
setEnabled(HashMap<Integer,Transition> list)
void
setFirable(HashMap<Integer,Transition> firable)
void
setFireable(HashMap<Integer,Transition> list)
void
setMarking(ArrayList<Place> l, ArrayList<Float> vallist)
int
size()
void
timedMove(Float f)
-
Methods inherited from class fr.inria.mochy.core.abstractClass.PhysicalModel
getNbDiscreteSteps, getStepsNb, getTimeElapsed, isDiscreteStep
-
-
-
-
Field Detail
-
places
public HashMap<Integer,Place> places
the list of the places which have a content "marked" if there is one token or none then its content is "null"
-
transitions
public HashMap<Integer,Transition> transitions
the list of the transitions which manage the time a token will stay at a place
-
enabled
public HashMap<Integer,Transition> enabled
list of enabled transitions : previous places marked and clock != 0
-
blocked
public HashMap<Integer,Transition> blocked
list of blocked transitions : previous places marked, and at least one next place is marked and clock = 0
-
firable
public HashMap<Integer,Transition> firable
list of firable transitions : previous places marked, free next places, clock=0
-
-
Constructor Detail
-
Net
public Net(String fname)
take the path of the input file as parameter
-
-
Method Detail
-
loadFile
public String loadFile()
Loads a net from a file- Specified by:
loadFile
in classPhysicalModel
- Returns:
- The method returns a strings to diplay success/failure in the log area of the interface.
-
handleLine
protected String handleLine(String line, int lineNb)
load a line of the input file- Parameters:
line
- the line to readlineNb
- the number of the line in the input file- Returns:
- the errors which occur as a String
-
addInFlow1
protected void addInFlow1(int tnum, int pnum)
adds a place in the preset of a transition- Parameters:
tnum
- the id number of the transitionpnum
- the id number of the place
-
addOutFlow
protected void addOutFlow(int tnum, int pnum)
adds a place in the postset of a transition- Parameters:
tnum
- the transition id numberpnum
- the place id number
-
getPlace
public Place getPlace(int pnum)
Find a place from its number This place can be a standard place or a control place- Parameters:
pnum
-- Returns:
- the place found
-
getControlPlace
public Place getControlPlace(int pnum)
Description copied from class:PhysicalModel
return a control place as specified by its number in parameter- Specified by:
getControlPlace
in classPhysicalModel
- Parameters:
the
- control place id number- Returns:
- the control place with this id number
-
addToken
public Boolean addToken(int pnum)
Add a token in a standard place- Specified by:
addToken
in classPhysicalModel
- Parameters:
pnum
- the place number- Returns:
- true if the place exist
-
addControlToken
public Boolean addControlToken(int pnum)
Adds a token in a control place- Parameters:
pnum
-- Returns:
-
isAControlPlace
public boolean isAControlPlace(int pnum)
Checks is a place is a control places- Parameters:
pnum
- : the place number- Returns:
- true if pnum is a control place, false otherwise
-
findTransition
public Transition findTransition(Integer tnum)
Description copied from class:PhysicalModel
return the transition as specified by its number in parameter- Specified by:
findTransition
in classPhysicalModel
-
findTransition
public Transition findTransition(String name)
Description copied from class:PhysicalModel
return the transition as specified by its name in parameter- Specified by:
findTransition
in classPhysicalModel
-
isFirable
public boolean isFirable(Transition t)
-
controlAllowsFiring
public boolean controlAllowsFiring(Transition t)
Checks if the control places used as input to the current transition allow firing of t- Parameters:
t
-- Returns:
-
isEnabled
public boolean isEnabled(Transition t)
-
findPlace
public Place findPlace(int pnum)
Description copied from class:PhysicalModel
return the place as specified by its number in parameter- Specified by:
findPlace
in classPhysicalModel
-
isAControlPace
public boolean isAControlPace(int pnum)
Returns true if pnum is the number of a control place- Parameters:
pnum
-- Returns:
-
busyPostSet
public boolean busyPostSet(Integer tnum)
-
newlyEnabled
public ArrayList<Transition> newlyEnabled(Marking m1, Marking m2, Transition t)
-
blockTransition
public void blockTransition(Transition t)
-
maxAllowedTimedMove
public float maxAllowedTimedMove()
Description copied from class:PhysicalModel
return the allowed timed move to be elapsed to perform a step- Specified by:
maxAllowedTimedMove
in classPhysicalModel
-
timedMove
public void timedMove(Float f)
-
progressTime
public void progressTime(Float delta)
Description copied from class:PhysicalModel
advance the time of the delta parameter value and update the status of the transitions (blocked, fireable...)- Specified by:
progressTime
in classPhysicalModel
-
discreteMove
public void discreteMove()
Description copied from class:PhysicalModel
perform a discrete move e.g. a transition will be fired and a token will change of place- Specified by:
discreteMove
in classPhysicalModel
-
discreteMove
public boolean discreteMove(String pathLogs, long elapsedTime, boolean enableLogs)
Description copied from class:PhysicalModel
perform a discrete move e.g. a transition will be fired and a token will change of place- Specified by:
discreteMove
in classPhysicalModel
-
discreteMoveWithControl
public boolean discreteMoveWithControl(String pathLogs, long elapsedTime, boolean enableLogs)
-
discreteMove
public String discreteMove(TransitionAbstract trans, String pathLogs, float elapsedTime, boolean enableLogs)
Description copied from class:PhysicalModel
perform a discrete move e.g. a transition will be fired and a token will change of place- Specified by:
discreteMove
in classPhysicalModel
-
multipleSteps
public void multipleSteps(int steps)
Description copied from class:PhysicalModel
perform the number of steps specified in parameter (timed move, discrete move, ...)- Specified by:
multipleSteps
in classPhysicalModel
-
listEnabled
public void listEnabled()
-
getFirable
public HashMap<Integer,Transition> getFirable()
Description copied from class:PhysicalModel
get the list of the fireable transitions which can be retrieved by their id number- Specified by:
getFirable
in classPhysicalModel
-
getEnabled
public HashMap<Integer,Transition> getEnabled()
Description copied from class:PhysicalModel
get the list of the enabled transitions which can be retrieved by their id number- Specified by:
getEnabled
in classPhysicalModel
-
setFirable
public void setFirable(HashMap<Integer,Transition> firable)
-
size
public int size()
-
dropConfig
public String dropConfig()
A method to display the contents of places in a String- Specified by:
dropConfig
in classPhysicalModel
- Returns:
- a string with the contents of all places
-
isGaussian
public boolean isGaussian()
Description copied from class:PhysicalModel
return true if the prob. distribution is gaussian. used for the sampling of the transitions- Specified by:
isGaussian
in classPhysicalModel
-
isWeibull
public boolean isWeibull()
Description copied from class:PhysicalModel
return true if the prob. distribution is weibull. used for the sampling of the transitions- Specified by:
isWeibull
in classPhysicalModel
-
getWeibullCoef
public int getWeibullCoef()
Description copied from class:PhysicalModel
get the coefficient used for the weibull prob. distribution. used for the sampling of the transitions- Specified by:
getWeibullCoef
in classPhysicalModel
-
reset
public void reset(boolean init)
Description copied from class:PhysicalModel
reset the network model to its initial status- Overrides:
reset
in classPhysicalModel
-
numberFireable
public int numberFireable()
Description copied from class:PhysicalModel
return the number of fireable transitions- Specified by:
numberFireable
in classPhysicalModel
-
numberBlocked
public int numberBlocked()
Description copied from class:PhysicalModel
return the number of blocked transitions- Specified by:
numberBlocked
in classPhysicalModel
-
isBlocked
public boolean isBlocked(int tnum)
Description copied from class:PhysicalModel
return true if the transition specified in parameter by its number is blocked- Specified by:
isBlocked
in classPhysicalModel
-
getFname
public String getFname()
-
getTransitions
public HashMap<Integer,Transition> getTransitions()
Description copied from class:PhysicalModel
list the transitions which can be recovered with their number- Specified by:
getTransitions
in classPhysicalModel
-
getPlaces
public HashMap<Integer,Place> getPlaces()
Description copied from class:PhysicalModel
list the places which can be recovered with their number- Specified by:
getPlaces
in classPhysicalModel
-
getBlocked
public HashMap<Integer,Transition> getBlocked()
-
getControlPlaces
public HashMap<Integer,Place> getControlPlaces()
Description copied from class:PhysicalModel
return the list of the control places which can be recovered by their id number- Specified by:
getControlPlaces
in classPhysicalModel
-
getCurrentMarking
public Marking getCurrentMarking()
-
setCurrentMarking
public void setCurrentMarking(Marking currentMarking)
-
setEnabled
public void setEnabled(HashMap<Integer,Transition> list)
-
setFireable
public void setFireable(HashMap<Integer,Transition> list)
-
setBlocked
public void setBlocked(HashMap<Integer,Transition> list)
-
minimumClock
public float minimumClock()
Description copied from class:PhysicalModel
return the minimum time to advance in order to update the status of tokens or transitions- Specified by:
minimumClock
in classPhysicalModel
-
fireableTransition
public ArrayList<TransitionAbstract> fireableTransition()
Description copied from class:PhysicalModel
return the list of fireable transitions- Specified by:
fireableTransition
in classPhysicalModel
-
drop
public void drop()
Description copied from class:PhysicalModel
display informations of the network model- Specified by:
drop
in classPhysicalModel
-
getTokens
public LinkedHashMap<Integer,Token> getTokens()
- Specified by:
getTokens
in classPhysicalModel
-
-