Model bath tub

Description

A qualitative model of bath tub.

Source: PROLOG programming for artificial intelligence, 3rd Edition, Harlow, 2001, ISBN 0-201-40375-7.

Download

Program source code: model_bath_tub.pl

Listing

% Figure 20.9  A qualitative model of bath tub.
 
:- op( 900, fy, not).
:-  op( 220, xfy, ..).
 
% not Goal): negation as failure; 
%   Note: This is often available as a built-in predicate,
%   often written as prefix operator "\+", e.g. \+ likes(mary,snakes)
 
not Goal  :-
  Goal, !, fail
  ; 
  true.
 
% A bath tub model 
 
landmarks( amount, [ zero, full, inf]).
landmarks( level, [ zero, top, inf]).
landmarks( flow, [ minf, zero, inflow, inf]).
 
correspond( amount:zero, level:zero).
correspond( amount:full, level:top).
 
legalstate( [ Level, Amount, Outflow, Netflow])  :-
  mplus( Amount, Level),
  mplus( Level, Outflow),
  Inflow = flow:inflow/std,           % Constant in-flow
  sum( Outflow, Netflow, Inflow),     % Netflow = Inflow - Outflow
  deriv( Amount, Netflow),
  not overflowing( Level).            % Water not over the top
 
overflowing( level:top..inf/_).       % Over the top
 
initial( [ level: zero/inc,
           amount: zero/inc, 
           flow: zero/inc,
           flow: inflow/dec ] ).

Comments

pl/prolog/pllib/model_bath_tub.txt · ostatnio zmienione: 2017/07/17 08:08 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0