org.gcn.plinguacore.util.psystem
Class Psystem

java.lang.Object
  extended by org.gcn.plinguacore.util.psystem.Psystem
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
CellLikePsystem

public abstract class Psystem
extends java.lang.Object
implements java.io.Serializable

An abstract class for a P System

Author:
Research Group on Natural Computing (http://www.gcn.us.es)
See Also:
Serialized Form

Constructor Summary
Psystem()
          The constructor
 
Method Summary
 boolean addRule(Rule r)
          adds a rule to the existing rule set
 java.util.Iterator<AlphabetObject> alphabetIterator()
          Returns an iterator over the alphabet
 ISimulator createSimulator(boolean stepBackSupported, boolean alternativeStepsSupported)
          Creates a simulator to simulate this P-system.
 ISimulator createSimulator(boolean stepBackSupported, boolean alternativeStepsSupported, java.lang.String id)
          Creates a simulator to simulate this P-system.
 IPsystemFactory getAbstractPsystemFactory()
          Gets the current AbstractPsystemFactory instance
 java.util.SortedSet<AlphabetObject> getAlphabet()
          Returns the P-system alphabet
abstract  Configuration getFirstConfiguration()
           
 java.util.Map<java.lang.String,MultiSet<java.lang.String>> getInitialMultiSets()
          Returns the initial P-system multisets
abstract  java.util.Collection<? extends Membrane> getMembranes()
           
 RulesSet getRules()
           
 java.util.Iterator<java.lang.String> getSimulatorsIDs()
          Gets an iterator on all possible simulators IDs for the Psystem
 void setAbstractPsystemFactory(IPsystemFactory apf)
          Sets an specific instance of PsystemFactotyInterface as the current factory to be used
 boolean supportsAlternativeStep(java.lang.String id)
          Returns a boolean representing if the simulator related to id could be created capable of performing alternative steps
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Psystem

public Psystem()
The constructor

Method Detail

setAbstractPsystemFactory

public void setAbstractPsystemFactory(IPsystemFactory apf)
                               throws PlinguaCoreException
Sets an specific instance of PsystemFactotyInterface as the current factory to be used

Parameters:
apf - the PsystemFactoryInterface instance to be held
Throws:
PlinguaCoreException - if any error ocurred during the instantiation of the CreateSimulator instance

getAbstractPsystemFactory

public IPsystemFactory getAbstractPsystemFactory()
Gets the current AbstractPsystemFactory instance

Returns:
the AbstractPsystemFactory instance currently held

getInitialMultiSets

public java.util.Map<java.lang.String,MultiSet<java.lang.String>> getInitialMultiSets()
Returns the initial P-system multisets

Returns:
the initial P-system multisets

getAlphabet

public java.util.SortedSet<AlphabetObject> getAlphabet()
Returns the P-system alphabet

Returns:
the current alphabet

alphabetIterator

public java.util.Iterator<AlphabetObject> alphabetIterator()
Returns an iterator over the alphabet

Returns:
an iterator on the current P-system alphabet

getRules

public RulesSet getRules()
Returns:
The rules set of the p system

addRule

public boolean addRule(Rule r)
adds a rule to the existing rule set

Parameters:
r - the rule to be added
Returns:
if the rule has been successfully added

getMembranes

public abstract java.util.Collection<? extends Membrane> getMembranes()
Returns:
A Collection of all membranes of the P system

getFirstConfiguration

public abstract Configuration getFirstConfiguration()
Returns:
The first configuration of the P system

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

createSimulator

public ISimulator createSimulator(boolean stepBackSupported,
                                  boolean alternativeStepsSupported,
                                  java.lang.String id)
                           throws PlinguaCoreException
Creates a simulator to simulate this P-system. The parameters specify if this simulator will be able to take steps back, take alternative steps (among different, possible steps) and which specific class will implement the simulator, specified by ID

Parameters:
stepBackSupported - sets if the simulator created supports steps back
alternativeStepsSupported - sets if the simulator created supports alternate steps
id - the Simulator id which references the specific Simulator class to be instantiated
Returns:
a simulator which complies with the parameter conditions
Throws:
PlinguaCoreException - if there are rules which doesn't match the model specification previously defined by setting the AbstractPsystemFactory instance

createSimulator

public ISimulator createSimulator(boolean stepBackSupported,
                                  boolean alternativeStepsSupported)
                           throws PlinguaCoreException
Creates a simulator to simulate this P-system. The parameters specify if this simulator will be able to take steps back and/or take alternative steps (among different, possible steps). As no ID is passed as parameter the class implemented by the simulator will be the first available one, taken by default

Parameters:
stepBackSupported - sets if the simulator created supports steps back
alternativeStepsSupported - sets if the simulator created supports alternate steps
Returns:
a simulator which complies with the parameter conditions
Throws:
PlinguaCoreException - if there are rules which doesn't match the model specification previously defined by setting the AbstractPsystemFactory instance

getSimulatorsIDs

public java.util.Iterator<java.lang.String> getSimulatorsIDs()
                                                      throws PlinguaCoreException
Gets an iterator on all possible simulators IDs for the Psystem

Returns:
an iterator on all possible simulators IDs for the Psystem
Throws:
PlinguaCoreException - if the simulators IDs provider hasn't set yet

supportsAlternativeStep

public boolean supportsAlternativeStep(java.lang.String id)
                                throws PlinguaCoreException
Returns a boolean representing if the simulator related to id could be created capable of performing alternative steps

Parameters:
id - the simulator identifier
Returns:
if the simulator related to id could be created capable of performing alternative steps
Throws:
PlinguaCoreException - if the simulators IDs provider hasn't set yet