24.11.2014 Views

flex Expert System Toolkit - LPIS

flex Expert System Toolkit - LPIS

flex Expert System Toolkit - LPIS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4. Data-Driven Programming 44<br />

Constraining the Values of Slots<br />

A constraint is attached to an individual slot, and is designed to constrain<br />

the contents of a slot to valid values. It is activated whenever the current<br />

value of that slot is updated, and the activation occurs immediately before<br />

the update.<br />

A constraint has three main parts:<br />

• context<br />

• check<br />

• error<br />

A test to see whether certain conditions hold.<br />

A test to see whether the update is valid.<br />

A series of commands to be performed for an invalid update.<br />

The check will only be made if the context holds. If the check is successful<br />

then the update is allowed, otherwise the error commands are invoked and<br />

the update is not allowed.<br />

Example<br />

If we had a frame system representing instances of water containers, we<br />

could put a constraint on the contents slot of any jug, such that when<br />

the value for the particular slot is being updated, a test is performed making<br />

sure that the new value is less than the value of the jug`s capacity, thus<br />

ensuring the jug does not overflow!<br />

In the example the constraint is activated if the contents attribute of any<br />

jug changes. The prospective new value for the slot is then tested to see if it<br />

is less than that jug's capacity. If the test succeeds the update is allowed. If<br />

the test fails the update is not allowed and a message is displayed.<br />

<strong>flex</strong> toolkit

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!