public class AlgebraicLoopDirector extends StaticSchedulingDirector
The errorTolerance may be given as a parameter to an individual port (just add a parameter named "errorTolerance" to the port). For any port for which there is no such parameter, the errorTolerance parameter of this director will be used. Note that if the errorTolerance of a port is changed during a run, the new value is ignored until the next run.
In all cases, the problem being solved has the form:
----------- | ----- | -->| g |--- x -----where x is initially the vector of values corresponding to input ports that have a non-null defaultValue parameter, and g is the network of actors connecting these ports.
This class solves an algebraic loop of the form x=g(x)
----------- | ----- | -->| g |--- x -----where x is initially the vector of values corresponding to input ports that have a non-null defaultValue parameter, and g is the network of actors connecting these ports.
For the SuccessiveSubstitution, we simply evaluate g repeatedly until either all signals do not change by more than the errorTolerance, or until there have been maxIterations. Note that it is possible to reach a fixed point where some or all signals are infinite.
For NewtonRaphson, we solve for g(x)=x by solving f(x)=0, where f(x) = x-g(x). This is done by iterating as follows:
x_n+1 = x_n - f(x_n)/f'(x_n) = x_n - (x_n - g(x_n))/(1 - g'(x_n)) .To estimate g'(x_n), we do
g'(x_n) = (g(x_n + d) - g(x_n))/dwhere d is the delta parameter.
For Homotopy, we solve f(x) = x - g(x).
The problem is reformulated as H(s, lambda, x0) = s - lambda (g(s+x0)-x0),
where lambda has an initial value of 0 and is successively increased to 1,
s is a coordinate transformation defined so that x = s+x0, where
x0 is the initial iterate.
The implementation is equal to Program 3 of
Eugene L. Allgower and Kurt Georg,
Introduction to Numerical Continuation Methods,
Classics in Applied Mathematics, Vol. 45, SIAM, 2003.
However, the implementation by Allgower and Georg assumes an initial iterate of 0,
which is the reason for the above coordinate transformation.
FIXME: Questions:
Red (pwhitake) |
Yellow (eal) |
Modifier and Type | Class and Description |
---|---|
(package private) class |
AlgebraicLoopDirector.AlgebraicLoopSolver
A class for solving algebraic loops.
|
(package private) class |
AlgebraicLoopDirector.Homotopy
Class for solving algebraic loops using a homotopy method.
|
(package private) class |
AlgebraicLoopDirector.NewtonRaphson
Class for solving algebraic loops using the Newton-Raphson method.
|
(package private) class |
AlgebraicLoopDirector.SuccessiveSubstitution
Class for solving algebraic loops using the su method.
|
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected java.util.List<AlgebraicLoopReceiver> |
_breakVariables
The list of receivers for all break variables.
|
protected double[] |
_g_n
Current value of the loop function g(x_n).
|
protected int |
_nVars
Number of break variables.
|
(package private) AlgebraicLoopDirector.AlgebraicLoopSolver |
_solver
Algebraic loop solver.
|
protected double[] |
_tolerance
Tolerance for each iteration variable.
|
protected double[] |
_x_n
Current value of the iteration variables x_n.
|
Parameter |
errorTolerance
The default tolerance for determining when convergence has occurred.
|
Parameter |
maxIterations
The maximum number of allowed iterations before the director
will declare a failure to converge.
|
StringParameter |
method
The method to be used to solve algebraic loops.
|
_postfireReturns, _prefire
_actorsFinishedExecution, _aspectForActor, _aspectsPresent, _defaultMicrostep, _executionAspects, _finishRequested, _initializables, _nextScheduleTime, _stopRequested, _tokenSentToCommunicationAspect, _zeroTime, localClock, startTime, stopTime
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
COMPLETED, NOT_READY, STOP_ITERATING
Constructor and Description |
---|
AlgebraicLoopDirector(CompositeEntity container,
java.lang.String name)
Construct a director in the given container with the given name.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_clearAllDestinationReceivers(Actor actor)
Call the send(index, null) method of each output port of the specified actor.
|
protected void |
_evaluateLoopFunction(double[] x,
double[] g)
Evaluate the loop function for x and save the result in g.
|
protected void |
_fireActor(Actor actor)
Fire an actor.
|
java.lang.Object |
clone(Workspace workspace)
Clone the object into the specified workspace.
|
void |
fire()
Prefire and fire actors in the order given by the scheduler
until the iteration converges.
|
void |
initialize()
Initialize the director and all deeply contained actors by calling
the super.initialize() method, then identify all the break variables
(where an input port has a defaultValue set) and adjust the I/O
dependencies.
|
Receiver |
newReceiver()
Return a new FixedPointReceiver.
|
boolean |
postfire()
Postfire all contained actors.
|
_setScheduler, addDebugListener, getScheduler, invalidateSchedule, isScheduleValid, prefire, removeDebugListener, resumeActor, setScheduler
_actorFinished, _consultTimeRegulators, _description, _isEmbedded, _isTopLevel, _schedule, _transferInputs, _transferOutputs, addInitializable, attributeChanged, createSchedule, defaultDependency, delayDependency, finish, fireAt, fireAt, fireAt, fireAtCurrentTime, fireContainerAt, fireContainerAt, getCausalityInterface, getCurrentTime, getDeadline, getEnvironmentTime, getErrorTolerance, getExecutionAspect, getGlobalTime, getModelNextIterationTime, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, implementsStrictActorSemantics, initialize, invalidateResolvedTypes, isEmbedded, isFireFunctional, isStopRequested, isStrict, iterate, mutexLockObject, notifyTokenSentToCommunicationAspect, preinitialize, preinitialize, removeInitializable, requestInitialization, resume, scheduleContainedActors, setContainer, setCurrentTime, setEmbedded, setModelTime, setTimeResolution, stop, stopFire, suggestedModalModelDirectors, supportMultirateFiring, suspend, terminate, transferInputs, transferOutputs, transferOutputs, wrapup
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
public Parameter errorTolerance
public Parameter maxIterations
public StringParameter method
protected java.util.List<AlgebraicLoopReceiver> _breakVariables
protected double[] _g_n
protected int _nVars
AlgebraicLoopDirector.AlgebraicLoopSolver _solver
protected double[] _tolerance
protected double[] _x_n
public AlgebraicLoopDirector(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- Container of the director.name
- Name of this director.IllegalActionException
- If the director is not compatible
with the specified container.NameDuplicationException
- If the name collides with an
attribute in the container.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class StaticSchedulingDirector
workspace
- The workspace for the cloned object.java.lang.CloneNotSupportedException
- Not thrown in this base classNamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public void fire() throws IllegalActionException
fire
in interface Executable
fire
in class StaticSchedulingDirector
IllegalActionException
- If an actor violates the
monotonicity constraints, or the prefire() or fire() method
of the actor throws it.protected void _evaluateLoopFunction(double[] x, double[] g) throws IllegalActionException
x
- Input to the loop function.g
- Double vector of the same size as x. The result will be stored in this function.IllegalActionException
- If the prefire() method
returns false having previously returned true in the same
iteration, or if the prefire() or fire() method of the actor
throws it, or if evaluating the function yields a value that
is not a double.public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class StaticSchedulingDirector
IllegalActionException
- If the superclass throws it.public Receiver newReceiver()
newReceiver
in class Director
public boolean postfire() throws IllegalActionException
postfire
in interface Executable
postfire
in class StaticSchedulingDirector
IllegalActionException
- If the superclass throws it, or
if any of the contained actors throw it.protected void _clearAllDestinationReceivers(Actor actor) throws IllegalActionException
actor
- The actor.IllegalActionException
- If thrown while getting
the width of a port, determining if a port is known
or while sending data.protected void _fireActor(Actor actor) throws IllegalActionException
actor
- The actor to be fired.IllegalActionException
- If the prefire() method
returns false having previously returned true in the same
iteration, or if the prefire() or fire() method of the actor
throws it.