Re: Fuzzy Union in C++
- From: Seweryn Habdank-Wojewódzki <habdank@xxxxxxxxx>
- Date: Thu, 18 Jan 2007 16:19:08 +0100
Hi!
Dmitry A. Kazakov wrote:
OK, the problem is that C does not have arrays, so you would need to wrap
your "pointers-to-pointers-to-double" thingy into a C++ class anyway. Just
to be able to return it as the result of a function. Doing so you will
loose nice array aggregates as above. Which aren't that nice, BTW.
Consider:
double RubbishSet [1][2] = {{1.0, 1000.0}};
// This is OK for the compiler, but meaningless
If I can add little.
Better in C++ is to prepare dedicated class that works for that purpose.
single fuzzy element can be
std::pair < element_type, real_type >
This will force user/programmer to make operation respectively to the types
of elements e.g. if element_type is int or std::string.
And the error checking will be done in compilation time, so it is very fast
recognition if all is done properly, there are some possibilities to set
some checking mechanizm, that will set that real_type will be a range_type
from 0.0 to 1.0. And you can throw exception (or other kind of error) if
values are outside boundaries.
You should do at least:
class TruthValue
{
public:
friend TruthValue operator & ... // And
friend TruthValue operator | ... // Or
friend TruthValue operator ~ ... // Not
TruthValue (double Value) ... // Constructor from double
operator double ... // Conversion to double
...
private:
double Value; // The range 0.0..1.0 is enforced,
// You could consider a integer type as well,
// as a poor-man's implementation
// of a fixed-point numeric type.
};
This is not as complicated. You do not need declare any friend functions.
You could do simpler design.
TruthValue can be just a type with range. You could use:
http://www.msobczak.com/prog/typegen/
or directly
http://www.msobczak.com/prog/bin/range.tar.gz
Operators you can define externally, there is no need of frienship.
class Pair
{
...
private:
double Point;
TruthValue Level;
};
typedef std::pair < element_type /*e.g. double, int, std::string */,
TruthValue > fuzzy_elem_type; // should be enough
class FuzzySetOfSingletons
{
public:
friend FuzzySetOfSingletons operator & ... // Intersection
friend FuzzySetOfSingletons operator | ... // Union
...
private:
... // Some sorted container of Pairs
};
You do not need friendship. Just define pure class with container and define
externally functions. You can do it as a template, so probably similar will
be the code for std::String elements and double and int.
Last note. Weighted singletons is a quite poor class of fuzzy sets. It is
not closed on set-complement. So I would propose you to switch from
singletons to almost everywhere continuous functions. I am using functions
linear on a finite number of intervals.
But it is still possible to remember not a constant value, but a
coefficients of the linear approximation in the case when TruthValue shoud
be continue. Isn't it?
Regards.
--
|\/\/| Seweryn Habdank-Wojewódzki
`\/\/'
.
- Follow-Ups:
- Re: Fuzzy Union in C++
- From: Dmitry A. Kazakov
- Re: Fuzzy Union in C++
- From: Evyn
- Re: Fuzzy Union in C++
- References:
- Fuzzy Union in C++
- From: Evyn
- Re: Fuzzy Union in C++
- From: Dmitry A. Kazakov
- Re: Fuzzy Union in C++
- From: Evyn
- Re: Fuzzy Union in C++
- From: Dmitry A. Kazakov
- Fuzzy Union in C++
- Prev by Date: Re: Fuzzy Union in C++
- Next by Date: Re: Fuzzy Union in C++
- Previous by thread: Re: Fuzzy Union in C++
- Next by thread: Re: Fuzzy Union in C++
- Index(es):