Package org.ptolemy.machineImprovisation
Class FactorOracle
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,Initializable
,TypedActor
,ExplicitChangeContext
,RefinementActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,DropTargetHandler
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class FactorOracle extends ModalController
Build a factor oracle (FO) data structure that represents a finite acyclic automaton that contains at least all the suffixes of a given input sequence. The actor accepts a name for the Factor oracle, an Object array, representing the input trainingSequence on which the suffix tree will be built, and a repetitionFactor that is a double in range [0.0,1.0], which is a measure of the probability of the training sequence to be repeated at each transition. The output Factor Oracle will be a probabilistic automaton that can generate at least all the suffixes of the training string. If the validatePitch Parameter is set to true, the factor oracle interprets the input string as a sequence of notes and adds a check to the transitions to validate the note against a specification.As an example, if a transition that would generate a "C4" upon firing, the guard expression would look like: validatePitch("C4") && probability(p) , where p is a double in range [0.0,1.0]. This transition would be taken (i) if the probability() transition evaluates to true AND (ii) if validatePitch() returns true.
References
[1] C. Allauzen, M. Crochemore, and M. Raffinot. "Factor oracle: A new structure for pattern matching." SOFSEM'99: Theory and Practice of Informatics . Springer Berlin Heidelberg, 1999.
- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Ilge Akkaya
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Red (ilgea)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
FactorOracle.ChordFunction
A function that evaluates to true if the "pitch" that would be produced as a result of taking this transition satisfies chord specifications.protected class
FactorOracle.ChordFunctionToken
An inner class that defines a Chord Function Token, which is used in pitch validation.-
Nested classes/interfaces inherited from class ptolemy.domains.modal.kernel.FSMActor
FSMActor.PortScope
-
Nested classes/interfaces inherited from class ptolemy.kernel.CompositeEntity
CompositeEntity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description TypedIOPort
currentChord
Current chord in improvisation.Parameter
repetitionFactor
The repetition probability P(moving along the original sequence rather than taking a jump along a suffix link).Parameter
validatePitch
Boolean that when set to true, enables the transitions to have a condition that validates each pitch against a specification.-
Fields inherited from class ptolemy.domains.modal.modal.ModalController
_mirrorDisable
-
Fields inherited from class ptolemy.domains.modal.kernel.FSMActor
_currentState, _disabledRefinements, _initializables, _inputTokenMap, _lastChosenTransition, _lastChosenTransitions, _lastTakenTransitions, _stateRefinementsToPostfire, _stopRequested, errorCause, errorClass, errorMessage, finalStateNames, initialStateName, probability, resetOnEachRun, seed, stateDependentCausality, timeout
-
Fields inherited from class ptolemy.kernel.CompositeEntity
_levelCrossingLinks
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description FactorOracle(CompositeEntity container, java.lang.String name)
Constructs a FactorOracle object.FactorOracle(CompositeEntity container, java.lang.String name, java.lang.Object[] trainingSequence, double repetitionFactor)
Construct an actor with the given container and name.FactorOracle(CompositeEntity container, java.lang.String name, java.lang.Object[] trainingSequence, double repetitionFactor, boolean symbolicOutput, boolean validateSymbols)
Constructs a FactorOracle object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.List<java.lang.Integer>
_getTransitionsFrom(java.lang.Integer node)
Get a list of transitions originating from node.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.-
Methods inherited from class ptolemy.domains.modal.modal.ModalController
_addPort, _checkContainer, _getRefinementClasses, addRefinement, dropObject, getRefinedState, newPort, setMirrorDisable
-
Methods inherited from class ptolemy.domains.modal.kernel.FSMActor
_addEntity, _addRelation, _areAllImmediateTransitionsDisabled, _chooseTransitions, _destinationState, _getChannelForIdentifier, _getPortForIdentifier, _getStateRefinementsToPostfire, _getTransitionRefinementsToPostfire, _init, _initializeRefinements, _isRefinementOutput, _isSafeToClear, _readInputs, _schedule, _setCurrentConnectionMap, _setTimeForRefinement, addChosenTransition, addInitializable, attributeChanged, createReceivers, currentState, enabledTransitions, exportSubmodel, fire, foundUnknown, getCausalityInterface, getContext, getDirector, getExecutiveDirector, getInitialState, getLastChosenTransition, getLastChosenTransitions, getLastTakenTransitions, getManager, getModifiedVariables, getPortScope, handleModelError, hasInput, hasInput, initialize, inputPortList, isBackwardTypeInferenceEnabled, isFireFunctional, isOpaque, isStrict, iterate, newReceiver, newRelation, outputPortList, postfire, prefire, preinitialize, readInputs, readOutputsFromRefinement, removeInitializable, reset, setLastChosenTransition, setNewIteration, setSupportMultirate, stop, stopFire, terminate, typeConstraints, wasTransitionTaken, wrapup
-
Methods inherited from class ptolemy.kernel.CompositeEntity
_adjustDeferrals, _containedDecorators, _deepOpaqueEntityList, _description, _exportMoMLContents, _finishedAddEntity, _removeEntity, _removeRelation, _validateSettables, allAtomicEntityList, allowLevelCrossingConnect, classDefinitionList, connect, connect, containedObjectsIterator, deepCompositeEntityList, deepEntityList, deepGetEntities, deepNamedObjList, deepOpaqueEntityList, deepRelationSet, entityList, entityList, exportLinks, exportMoML, getAttribute, getEntities, getEntity, getPort, getRelation, getRelations, isAtomic, lazyAllAtomicEntityList, lazyAllCompositeEntityList, lazyAllCompositeTransparentAndOpaqueEntityList, lazyClassDefinitionList, lazyDeepEntityList, lazyEntityList, lazyRelationList, numberOfEntities, numberOfRelations, numEntities, numRelations, relationList, removeAllEntities, removeAllRelations, setClassDefinition, setContainer, statistics, uniqueName
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
-
Methods inherited from class ptolemy.kernel.Entity
_removePort, connectedPortList, connectedPorts, connectionsChanged, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
fire, isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, initialize, preinitialize, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
Methods inherited from interface ptolemy.actor.TypedActor
isBackwardTypeInferenceEnabled, typeConstraints
-
-
-
-
Field Detail
-
repetitionFactor
public Parameter repetitionFactor
The repetition probability P(moving along the original sequence rather than taking a jump along a suffix link).
-
validatePitch
public Parameter validatePitch
Boolean that when set to true, enables the transitions to have a condition that validates each pitch against a specification.
-
currentChord
public TypedIOPort currentChord
Current chord in improvisation.
-
-
Constructor Detail
-
FactorOracle
public FactorOracle(CompositeEntity container, java.lang.String name, java.lang.Object[] trainingSequence, double repetitionFactor) throws NameDuplicationException, IllegalActionException
Construct an actor with the given container and name.- Parameters:
container
- The container.name
- The name of this actortrainingSequence
- The input string that the oracle is built fromrepetitionFactor
- a double indicating the factor repetition probability- Throws:
IllegalActionException
- If the actor cannot be contained by the proposed container.NameDuplicationException
- If the container already has an actor with this name.
-
FactorOracle
public FactorOracle(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
Constructs a FactorOracle object.- Parameters:
container
- The containername
- The name- Throws:
NameDuplicationException
IllegalActionException
-
FactorOracle
public FactorOracle(CompositeEntity container, java.lang.String name, java.lang.Object[] trainingSequence, double repetitionFactor, boolean symbolicOutput, boolean validateSymbols) throws IllegalActionException, NameDuplicationException
Constructs a FactorOracle object.- Parameters:
container
- The Containername
- The nametrainingSequence
- An object array containing the training sequencerepetitionFactor
- a double indicating the factor repetition probabilitysymbolicOutput
- a boolean that determines whether symbolic outputs should be producedvalidateSymbols
- a boolean -- true if symbol validation should be included in guard expressions- Throws:
IllegalActionException
- repetition factor range checkingNameDuplicationException
-
-
Method Detail
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Description copied from class:FSMActor
Clone the actor into the specified workspace. This calls the base class and then sets the attribute public members to refer to the attributes of the new actor.- Overrides:
clone
in classFSMActor
- Parameters:
workspace
- The workspace for the new actor.- Returns:
- A new FSMActor.
- Throws:
java.lang.CloneNotSupportedException
- If a derived class contains an attribute that cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
_getTransitionsFrom
protected java.util.List<java.lang.Integer> _getTransitionsFrom(java.lang.Integer node)
Get a list of transitions originating from node.- Parameters:
node
- Node index- Returns:
- a List of states which can be reached from current node
-
-