home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / prolog / 1533 < prev    next >
Encoding:
Internet Message Format  |  1992-08-13  |  1.3 KB

  1. Path: sparky!uunet!mcsun!uknet!bcc.ac.uk!link-1.ts.bcc.ac.uk!ucjtrjf
  2. From: ucjtrjf@ucl.ac.uk (Jonny Farringdon)
  3. Newsgroups: comp.lang.prolog
  4. Subject: Re: fuzzy unification of floating point numbers
  5. Message-ID: <1992Aug14.093549.5088@bas-a.bcc.ac.uk>
  6. Date: 14 Aug 92 09:35:49 GMT
  7. References: <1992Aug12.210954.15241@cs.ucla.edu>
  8. Organization: Bloomsbury Computing Consortium
  9. Lines: 36
  10.  
  11. Mike,
  12.  
  13. I think i mis-understood what you were after, ie equality matching rather than
  14. unification. So  (ummm) is this the kind of thing you want?
  15.  
  16. That the kind of thing, so you can supply constants or variables?
  17. how about ....
  18.  
  19. fuzzy_unify(A,B) :-
  20.     fuzzy_range(FR),
  21.     not( var(A) ),
  22.     not( var(B) ), !,
  23.     Diff is A - B,
  24.     absolute_value(Diff,Abs_Diff),
  25.     Abs_Diff < FR.
  26.  
  27. fuzzy_unify(A,B) :-
  28.     fuzzy_range(FR),
  29.     not( var(A) ),
  30.     var(B), !,
  31.     random(Rand),   
  32.     Addition is FR * Rand,
  33.     random_sign(Sign),           % returns -1 or +1
  34.     B is (Sign*Addition) + A.
  35.     
  36. fuzzy_unify(A,B) :-
  37.     fuzzy_range(FR),
  38.     var(A),
  39.     not( var(B) ), !,
  40.     fuzzy_unify(B,A).       % allows A or B it be variables
  41.     
  42. fuzzy_unify(A,A), !.
  43.  
  44.  
  45. so  either A or B or Both can be variable, plus it works if NO fuzzy_range is
  46. specified.  Hope that is of more help,  J.  ucjtrjf@ucl.ac.uk
  47.