Package ptolemy.domains.metroII.kernel
Class MappingConstraintSolver
- java.lang.Object
-
- ptolemy.domains.metroII.kernel.MappingConstraintSolver
-
- All Implemented Interfaces:
java.lang.Cloneable
,ConstraintSolver
public class MappingConstraintSolver extends java.lang.Object implements ConstraintSolver, java.lang.Cloneable
The constraint solver is used to enforce the user defined constraints on the scheduling via updating the event status. The mapping constraint solver updates the event status based on mapping constraints. The mapping constraint is a type of rendezvous constraint. Each mapping constraint is a event pair, which requires the events are scheduled at the same time. More precisely, the mapping constraint is satisfied when both events are in presence. An event status is updated to NOTIFIED when it satisfies the constraints. Otherwise the event status is updated to WAITING. The mapping constraint resolution has three steps:- Step 1: reset() is called to initialize the solver.
- Step 2: presentMetroIIEvent(event id) is called for each PROPOSED or WAITING event.
- Step 3: isSatisfied(event id) is called for each event. It returns true if the event satisfies all the mapping constraints.
- Since:
- Ptolemy II 11.0
- Version:
- $Id$
- Author:
- Liangpeng Guo
- Pt.AcceptedRating:
- Red (glp)
- Pt.ProposedRating:
- Red (glp)
-
-
Constructor Summary
Constructors Constructor Description MappingConstraintSolver()
Constructs a mapping constraint solver.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMapping(java.lang.String eventName1, java.lang.String eventName2)
Adds a mapping constraint.void
clear()
Clears all the mapping constraints.MappingConstraintSolver
clone()
Clones MappingConstraintSolver.boolean
debugging()
Checks if the debugging option is checked.int
numConstraints()
Returns the number of mapping constraints.void
readMapping(java.lang.String filename)
Reads mapping constraints from a file.void
reset()
Initializes the constraint solver.void
resolve(java.lang.Iterable<metroIIcomm.Event.Builder> metroIIEventList)
Resolves the MetroII event list, updating the event status based on the mapping constraints.java.lang.String
toString()
Returns the adjacency matrix of mapping constraints as a string.void
turnOffDebugging()
Turns off debugging option.void
turnOnDebugging()
Turns on debugging option.
-
-
-
Method Detail
-
clone
public MappingConstraintSolver clone() throws java.lang.CloneNotSupportedException
Clones MappingConstraintSolver.- Overrides:
clone
in classjava.lang.Object
- Throws:
java.lang.CloneNotSupportedException
- the object's class does not implement the Cloneable interface.
-
clear
public void clear()
Clears all the mapping constraints.
-
toString
public java.lang.String toString()
Returns the adjacency matrix of mapping constraints as a string.- Overrides:
toString
in classjava.lang.Object
- Returns:
- the adjacency matrix.
-
debugging
public boolean debugging()
Checks if the debugging option is checked.- Returns:
- the state of debugging option
-
turnOnDebugging
public void turnOnDebugging()
Turns on debugging option.
-
turnOffDebugging
public void turnOffDebugging()
Turns off debugging option.
-
resolve
public void resolve(java.lang.Iterable<metroIIcomm.Event.Builder> metroIIEventList)
Resolves the MetroII event list, updating the event status based on the mapping constraints. The mapping constraint is a type of rendezvous constraint. Each mapping constraint is a event pair, which requires the events are scheduled at the same time. More precisely, the mapping constraint is satisfied when both events are in presence. An event status is updated to NOTIFIED when it satisfies the constraints. Otherwise the event status is updated to WAITING.- Specified by:
resolve
in interfaceConstraintSolver
- Parameters:
metroIIEventList
- a list of MetroII events to be updated.
-
numConstraints
public int numConstraints()
Returns the number of mapping constraints.- Returns:
- the number of mapping constraints.
-
reset
public void reset()
Initializes the constraint solver.
-
addMapping
public void addMapping(java.lang.String eventName1, java.lang.String eventName2)
Adds a mapping constraint.- Parameters:
eventName1
- first event in the mapping.eventName2
- second event in the mapping.
-
readMapping
public void readMapping(java.lang.String filename) throws java.io.IOException
Reads mapping constraints from a file.- Parameters:
filename
- Filename of the mapping constraint file.- Throws:
java.io.IOException
- a failed or interrupted I/O operations has occurred.
-
-