home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / FUZZY.ZIP / CITY.PRO < prev    next >
Encoding:
Text File  |  1988-02-03  |  1.7 KB  |  59 lines

  1.  
  2. /*
  3.    City -- This is a simple Turbo Prolog program which uses fuzzy logic to
  4.            determine how "nice" various cities are.
  5.                                                               */
  6.                                                               
  7.  
  8. include "fuzzy.pro"   /* Include the fuzzy logic module */
  9.  
  10.  
  11. predicates
  12.   nice_city(symbol)  location(symbol)
  13.   city(symbol)       climate(symbol)
  14.   warm(symbol)       dry(symbol)
  15.   characteristics(symbol)
  16.   population(symbol, integer)
  17.   expensive(symbol)
  18.  
  19.  
  20. clauses
  21.  
  22.   nice_city(X) :- init_fuzzy, location(X), fuzzy(0.5), p_AND,
  23.                   characteristics(X), fuzzy(0.9), p_AND, p_OR,
  24.                   fuzzy(Rating),
  25.                   write(X, " has a rating of ", Rating), nl.
  26.                 
  27.   location(X) :- city(X), climate(X), f_AND.
  28.  
  29.   climate(X) :- warm(X), dry(X), f_AND.
  30.  
  31.   characteristics(X) :- population(X,Pop), Val = Pop/2500.0,
  32.                         fuzzy(Val), fuzzy(0.9), p_AND,
  33.                         expensive(X), f_NOT, fuzzy(0.5), p_AND,
  34.                         p_OR, f_AND.
  35.  
  36.  
  37.   /*  Data on various cities  */
  38.   
  39.   city(albuquerque) :- fuzzy(1.0).
  40.   city(boston) :- fuzzy(1.0).
  41.   city(ft_worth) :- fuzzy(1.0).
  42.  
  43.   warm(albuquerque) :- fuzzy(0.9).
  44.   warm(boston) :- fuzzy(0.5).
  45.   warm(ft_worth) :- fuzzy(0.9).
  46.  
  47.   dry(albuquerque) :- fuzzy(0.9).
  48.   dry(boston) :- fuzzy(0.6).
  49.   dry(ft_worth) :- fuzzy(0.7).
  50.  
  51.   population(albuquerque, 500) :- fuzzy(1.0).
  52.   population(boston, 2000) :- fuzzy(1.0).
  53.   population(ft_worth, 1500) :- fuzzy(1.0).
  54.  
  55.   expensive(albuquerque) :- fuzzy(0.6).
  56.   expensive(boston) :- fuzzy(0.9).
  57.   expensive(ft_worth) :- fuzzy(0.8).
  58.  
  59.