🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #635

Re: fuzzy unification of floating point numbers

#635
From: Jonny Farringdon
Date: Fri, 14 Aug 1992 09:35
36 lines
1329 bytes
Mike,

I think i mis-understood what you were after, ie equality matching rather than
unification. So  (ummm) is this the kind of thing you want?

That the kind of thing, so you can supply constants or variables?
how about ....

fuzzy_unify(A,B) :-
    fuzzy_range(FR),
    not( var(A) ),
    not( var(B) ), !,
    Diff is A - B,
    absolute_value(Diff,Abs_Diff),
    Abs_Diff < FR.

fuzzy_unify(A,B) :-
    fuzzy_range(FR),
    not( var(A) ),
    var(B), !,
    random(Rand),   
    Addition is FR * Rand,
    random_sign(Sign),           % returns -1 or +1
    B is (Sign*Addition) + A.
    
fuzzy_unify(A,B) :-
    fuzzy_range(FR),
    var(A),
    not( var(B) ), !,
    fuzzy_unify(B,A).       % allows A or B it be variables
    
fuzzy_unify(A,A), !.


so  either A or B or Both can be variable, plus it works if NO fuzzy_range is
specified.  Hope that is of more help,  J.  ucjtrjf@ucl.ac.uk
Technical Details
Message-ID: <1992Aug14.093549.5088@bas-a.bcc.ac.uk>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!bcc.ac.uk!link-1.ts.bcc.ac.uk!ucjtrjf
References: <1992Aug12.210954.15241@cs.ucla.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!bcc.ac.uk!link-1.ts.bcc.ac.uk!ucjtrjf
From: ucjtrjf@ucl.ac.uk (Jonny Farringdon)
Newsgroups: comp.lang.prolog
Subject: Re: fuzzy unification of floating point numbers
Message-ID: <1992Aug14.093549.5088@bas-a.bcc.ac.uk>
Date: 14 Aug 92 09:35:49 GMT
References: <1992Aug12.210954.15241@cs.ucla.edu>
Organization: Bloomsbury Computing Consortium
Lines: 36