15

I was looking at some code and saw an out of context comment about 'hysteresis.' I think I have figured out what the code does so my question doesn't involve anything specific. I simply do not understand what the term means or how it is applicable in programming. I looked around and saw some mathmatic definitions but would like some more information. From what I can tell Hysteresis has something to do with predicting or assuming a given state for X based on what has happened to X in the past?

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
Bjorn
  • 69,215
  • 39
  • 136
  • 164
  • 2
    First, include the definition you found. It helps to know what definitions you've read so far. We don't want to repeat stuff. – S.Lott Mar 18 '11 at 21:18

6 Answers6

28

Hysteresis characterizes a system whose behavior (output) does not only depend on its input at time t, but also on its past behavior, on the path it has followed.

A well-known device that exhibits hysteresis is a thermostat. Imagine a thermostat that would switch on and off heating at 70°F. When temperature is around 70°F, while fluctuating a bit, the thermostat would continually switch heating on and off. Generally, a thermostat is built with hysteresis: it will switch on heating at (say) 69°F, but switch off heating at 71°F. This avoids the continual switches.

EDIT: have a look at Wikipedia's article.

ChrisJ
  • 5,161
  • 25
  • 20
16

Thermostat example:

heatPointLow = 8°C
heatPointHeight = 10°C
heater = off

while(true){
    if(temperature < heatPointLow)
        heater = on
    if(temperature > heatPointHeight)   
        heater = off
}

If there where just one point the system coul'd oscillate around that single point. Between the points height and low it depends on the last value of the heater if it is on or off.

moritz
  • 5,094
  • 1
  • 26
  • 33
2

Google was my friend:

The principle in general refers to the behavior of any system's change, based on previous states. Thus you can model hysteresis with a state machine diagram or a graph.

In user interface design it refers to the practice of making a user interface lag behind user input events or other events. Clicking a button might not immediately display a details window; instead an animation is started which gradually changes the user interface.

I think of those "Device Driver Configured" bubbles in Windows 7's task bar as exhibiting hysteresis: the bubble appears in response to a completion event from the OS, and begins to fade away. A mouse-over event from the user will reset that timer, giving the user time to click on the bubble for details about the event; it delays the fading animation even if the mouse events are thereafter outside the region of the bubble.

Rob Perkins
  • 3,088
  • 1
  • 30
  • 51
1

Good answers. In practical integration layers, this is very important. An integration layer with hysteresis is itself a subsystem. Clearly, the ideal is no hysteresis (a Moore machine); but, typically there is a mismatch in the state machines of each of the systems and this can only be solved by a translator using hysteresis. For instance, Microsoft Dynamics/Great Plains Field Service module records state in its SVC00210 Service Master Audit Trail table. Each Call is in some SRVSTAT. When integrating a scheduler like ClickSoftware's service optimization scheduler then one needs to work with its state. The state of CS is determined by the custom implementation. E.g. Open, InRoute, OnSite, Incomplete, Cancelled, Complete. Additionally, it also has a state of Incomplete with Parts Pending although this is implemented as a sub- State Machine within Incomplete. So, transitions in GP must be mapped into CS. Unfortunately, GP allows (does record on screen input for a call) transitions from one state to itself; so, thus, the transition event cannot be used solely for triggering the state change in GP. Therefore, the new trigger event is a combination of the GP state transition as well as a meta-state defined by some logic on the set of past events. As you can see, hysteresis quickly takes the problem from simple to complex. In computer science terms the ideal is a Moore Machine but the practical is the Mealy Machine. I prefer to think of it like Mealy flour with bugs living in it and all! I think its possible to produce a Moore machine from any Mealy machine, the Moore machine will simply have more states. See: Mealy v/s. Moore

Community
  • 1
  • 1
maxweber
  • 576
  • 1
  • 5
  • 12
1

It's also used a lot in engineering. For example in video games if there is logic that is causing a lot of switching without a good result you can add hysteresis to the problem, and cause the objects to commit to a particular direction for a period of time which can avoid twitching issues. Similar to what is done in electronics with Schmidt triggers - to avoid constant switching that does not push the system into a new state, but causes the system to vibrate in one state and not be able to get out. Very simple concept that is helpful.

Search 'berserk hysteresis' in youtube for an example. Without hysteresis the robots in the game would literally just twitch around and not hardly move at all (when there is a lot of activity going on).

1

Can't put it more succinctly, than first sentence of Wikipedia article:

Hysteresis is the dependence of the state of a system on its history.


TS;NM

An interesting view on the notion of hysteresis is expressed in Hysteresis As Life article:

Invariably associated with all the real uses of hysteresis is this shape or graph — it looks like this:

A Typical Hysteresis Curve

If we name the x-axis “time” & the y-axis “events” then we can say, in poetic rather than scientific terms, that all lives start exactly the same. As time progresses each individual experiences events. While the events are unique they still fall within the limited range of “all human experience”.

A Hysteresis Labeled

Eventually, the individual dies. So the facts of birth and death are a given but the events in between are up to the individual — to a degree.

Community
  • 1
  • 1