Code Comments
Programming Forum and web based access to our favorite programming groups.Hi,
after several searches i'm using Ciao Prolog for my thesis, because it
contain an extension for Fuzzy Theory.
I must apply the Fuzzy Theory to Constraint Programming and i've
chosen like example the knapsack problem without the maximization.
I've defined one list of objects
K = [oggetto('A',3,402),oggetto('B',1,422),o
ggetto('C',2.3,80),
oggetto('D',0.7,145),oggetto('E',0.3,611)]
where 'A' is the name, 3 the volume, 402 the price, etc...
The rest of code is:
knapsack(O, Vu, Pu) :-
K = [oggetto('A',3,402),oggetto('B',1,422),o
ggetto('C',2.3,80),
oggetto('D',0.7,145),oggetto('E',0.3,611)],
vincolo(K,O,Vu, Pu).
vincolo(K,O,Vu,Pu):~
subseq(O, K),
volume(O, V),
prezzo(O, P),
volfuzzy(V,Vu),
prefuzzy(P,Pu),
{Vu .=<. 1.0},
{Pu .>=. 0.5}.
% alto se > 10
volfuzzy :# fuzzy_predicate([(0,0),(5,0.5),(10,1)]).
% alto se > 2500 €
prefuzzy :# fuzzy_predicate([(0,0),(1500,0.5),(3000,1)]).
where
sublist(A,B) return all the sublist of K, volume(X,Y) return in Y the
sum of volumes of the list X, prezzo(X,P) the price.
The constraint that i've defined are:
{Vu .=<. 1.0},
{Pu .>=. 0.5}.
Now i would want that the values of the objects of the list K were
fuzzy value, that is i would want to say that the object ' A' does not
have a
volume of 3 liters but a fuzzy value.
How can be made this thing in Hello Prolog?
Can you help me, please?
Thanks a lot,
Paul.
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.