Oscillator

Description

An oscillator model with energy constraint.

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

Download

Program source code: oscillator.pl

Listing

% File energy.pl: An oscillator model with energy constraint 
% (alternative to one in Fig. 20.14).
 
:-  op( 200, xfy, [:, ::]).
:-  op( 220, xfy, ..).
 
legalstate( [ X, V, A])  :-
     deriv( X, V),
     deriv( V, A),
     MinusA = a:_,
     sum( A, MinusA, a:zero/std),              % MinusA = -A
     mplus( X, MinusA),                        % Spring pulling block back
     energy( X, V).                            % Weak energy conserv. constraint
 
   energy( X, V)  :-  
      V = v:v0/_, !, X = x:zero/_              % If V=v0, X must be zero
      ;
      X = x:zero/_, !, V = v:minf..zero/_      % Here V must be -v0
      ;
      true.                                    % Otherwise X non-zero, no constraint on V

Comments

pl/prolog/pllib/oscillator.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