Diagonal Trajectories
4.9 Controlling The Simulation
Section 4.4 described how the simulator starts a step of simulation from a known set of initial conditions. Section 4.5 described how the simulator determines when an event changes the nature of the forces and hence terminates the current step of simulation.
Section 4.8 described how the simulator determines which pairs of engagement faces are engaged in the next step of simulation.
In this section we add the last two details that tie all of these pieces together, allowing us to compute a complete simulation: we describe how the simulator selects the appropriate external inputs to drive the simulation and how it selects the initial conditions to start it in the rst place.
4.9.1 External Inputs
In a conventional (numerical) simulation, external inputs are commonly specied as a function of time. In our qualitative world, however, this is not possible because time is not a well dened quantity. Instead, we specify the external inputs as a function of the device state using a state transition diagram. Each node in the diagram is a list of the pairs of faces that are engaged and the springs that are relaxed. (The pairs of faces not listed at a node are by default disengaged, the springs not listed are by default not relaxed.) The arcs are the external inputs that drive the device.
Figure 1-3b, for instance, describes how the circuit breaker should behave in the face of heating and cooling the hook and pressing the reset pushrod.
Because the external inputs are specied as a function of state, the simulator can compute the complete simulation in a piecewise fashion by simulating each arc in the diagram independently. For the circuit breaker, for example, the program simulates the \hook heats," \hook cools", and \reset" arcs as three separate simulations.
4.9. CONTROLLINGTHE SIMULATION 99 To simulate an arc, the program rst computes initial positions for each body from the state specied by the node at the tail of the arc. The program then applies the external inputs of the arc and simulates the behavior until the motion either reaches steady state or stops. Later, the tester (Chapter 5) checks to see if the states at the end of the simulation of one arc match the initial conditions for the next arc, and so on. If so, the candidate qc-space is capable of producing the desired behavior and is accepted.
4.9.2 Computing Initial Positions
To start the simulation of an arc, the program must rst compute initial positions for each body. The program derives the initial positions from the list of engaged faces and relaxed springs specied by the node at the head of the arc. The program does this using the same kind of constraint propagation it uses in Section 4.5.2 to compute the next events.
For each pair of engaged faces, the program constructs algebraic constraints that ensure the initial positions of the corresponding pair of bodies are inside the bounding box of the qcs-curve for the pair of faces. For each relaxed spring, the program constructs a constraint that ensures the body attached to the movable end of spring is located at the spring's neutral position.
By solving these constraints, the program obtains a range of values for the initial position of each body. The range for a particular body may be large enough that its initial position is not ordered with respect to the landmarks of the end points and i-points of the qcs-curves. If this happens, the simulator must branch in order to consider all possible orderings (see Section 4.5.3), and hence all possible initial positions consistent with the specied initial state.20
If the constraints on the initial positions are inconsistent (i.e., cannot be satised), the candidate qc-space is incapable of producing the desired behavior and is rejected.
4.9.3 Will The Simulation Terminate?
One concern in running a simulation is how long the simulation should continue. For conventional (numerical) simulations, one usually species a time interval. In our qualitative world, however, it is not possible to specify a time interval because time is not well dened in our qualitative representation. Instead, we simulate until the motion either reaches steady state or terminates. In this section, we demonstrate that the simulation will always reach one of these two conditions.
There are three ways in which the motion of a device can continue indenitely in response to a single set of inputs (i.e., the set of inputs applied at a node in the
20Currently, the program enumerates the possible orderings and prompts the user to select one of the possibilities. This is convenient for debugging purposes. It is a simple extension to have the program branch to consider all of the enumerated choices rather than prompting the user.
state transition diagram): the device could exhibit cyclic behavior, the device could asymptotically approach some rest state, or the motion of the parts could reach a steady state.
First, we consider cyclicbehavior. There are three kinds of cyclicbehavior: free os-cillations, such as the oscillation of a mass-spring oscillator; forced oscillations caused by an oscillating input; and forced oscillations caused by a cycle of engagements, such as the oscillation of a ratchet pawl that occurs when the ratchet wheel is continuously rotated.
Because SketchIT's world is inertia-free, there can be no free oscillations. In
SketchIT's world external inputs do not oscillate (they either apply a constant direction force, apply a constant direction motion, or select a temperature). Hence, there can be no oscillations caused by oscillating inputs. The application of asequence of external inputs with alternating magnitudes can produce forced oscillations. (For example, thesequence of inputs applied to the circuit breaker causes cyclic behavior.) However, the single set of inputs applied at a particular node in the state transition diagram cannot cause forced oscillations.
A device constructed such that its qc-space has periodic boundary conditions can produce cycles of engagements that lead to forced oscillations. For example, the yoke and rotor device's qc-space has a periodic boundary condition, and as a result continuous rotation of the yoke causes a continuous cycle of engagements. Once
SketchIT detects this kind of cycle, it can terminate the simulation because no new behavior will occur. SketchITcan detect this kind of cycle by checking if the current state of the device is the same as a previous state. For two states to be the same, the same engagement pairs must be engaged, the same springs must be relaxed, and the same inputs must be active.21 For the yoke and rotor, this denition of same state correctly identies the behavior of the device as cyclic. An open question is if there are devices for which this denition produces false positives.
To summarize, in SketchIT's world, the only way a device can produce cyclic behavior in response to a single set of inputs is if the device's qc-space has periodic boundary conditions. BecauseSketchITcan detect and terminate this kind of cycle, the simulation of an arc will never continue indenitely as a result of cyclic behavior.
Second, we consider the asymptotic approach to a rest state. A step of simulation ends because an event occurs, not because a xed amount of time has elapsed. The simulator's qualitative representation abstracts away the notion of time duration.
Hence, the time required to asymptotically approach a rest state is abstracted away and the simulation terminates after a nite number of steps. Thus, the simulation of a device that asymptotically approaches a rest state will not continue indenitely.
If there are no cycles, the only way that motion can reach a steady state is if the motion is unbounded, that is, the trajectory in qc-space continues forever without
21Although our procedure for detecting cycles is a simple extension of the current program, we have not yet implemented it.