Fuzzy Extension of some classical concepts
This commit is contained in:
parent
286dd256de
commit
bc686f7023
11 changed files with 1143 additions and 100 deletions
|
|
@ -1,95 +0,0 @@
|
|||
/*
|
||||
<BertDistance.h>
|
||||
Oumayma BAHRI
|
||||
|
||||
Author:
|
||||
Oumayma BAHRI <oumaymabahri.com>
|
||||
|
||||
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef BERTDISTANCE_H_
|
||||
#define BERTDISTANCE_H_
|
||||
|
||||
#include <math.h>
|
||||
#include <distance/moeoObjSpaceDistance.h>
|
||||
#include "ObjectiveVectorNormalizer.h"
|
||||
|
||||
/**
|
||||
* A class allowing to compute an Bert distance between two fuzzy solutions in the objective space
|
||||
with normalized objective values (i.e. between 0 and 1).
|
||||
* A distance value then lies between 0 and sqrt(nObjectives).
|
||||
*/
|
||||
template < class MOEOT>
|
||||
class BertDistance : public moeoObjSpaceDistance < MOEOT >
|
||||
{
|
||||
public:
|
||||
|
||||
/** the objective vector type of the solutions */
|
||||
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
|
||||
/** the fitness type of the solutions */
|
||||
typedef typename MOEOT::Fitness Fitness;
|
||||
|
||||
/**
|
||||
default ctr
|
||||
*/
|
||||
/* BertDistance ()
|
||||
{}*/
|
||||
/**
|
||||
ctr with a normalizer
|
||||
@param _normalizer the normalizer used for every ObjectiveVector
|
||||
*/
|
||||
/**
|
||||
default ctr
|
||||
*/
|
||||
BertDistance ():normalizer(defaultNormalizer)
|
||||
{}
|
||||
|
||||
|
||||
double calculateBertDistance(std::triple<double, double, double> A, std::triple<double, double, double> B)
|
||||
{
|
||||
double midA = 0.5 * (A.first + A.third);
|
||||
double midB = 0.5 * (B.first + B.third);
|
||||
double sprA = 0.5 * (A.first - A.third);
|
||||
double sprB = 0.5 * (B.first - B.third);
|
||||
|
||||
double theta = 0.5;
|
||||
|
||||
return sqrt((midA -midB) * (midA -midB) + theta * (sprA - sprB) * (sprA - sprB));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* tmp1 and tmp2 take the Expected values of Objective vectors
|
||||
* Returns the Bert distance between _obj1 and _obj2 in the objective space
|
||||
* @param _obj1 the first objective vector
|
||||
* @param _obj2 the second objective vector
|
||||
*/
|
||||
const Fitness operator()(const ObjectiveVector & _obj1, const ObjectiveVector & _obj2)
|
||||
{
|
||||
vector<double> v_BD;
|
||||
double dist=0.0;
|
||||
|
||||
for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)
|
||||
{
|
||||
dist +=calculateBertDistance(normalizer(_obj1)[i], normalizer(_obj2)[i]);
|
||||
}
|
||||
|
||||
//dist += normalizer(v_BD);
|
||||
|
||||
return dist/ObjectiveVector::nObjectives();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
ObjectiveVectorNormalizer<MOEOT> Normalizer;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif /*BERTDISTANCE_H_*/
|
||||
|
|
@ -16,12 +16,11 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
|||
|
||||
#include <math.h>
|
||||
#include <distance/moeoObjSpaceDistance.h>
|
||||
#include "ObjectiveVectorNormalizer.h"
|
||||
#include <utils/moeoFuzzyObjectiveVectorNormalizer.h>
|
||||
|
||||
/**
|
||||
* A class allowing to compute an Bert distance between two fuzzy solutions in the objective space
|
||||
with normalized objective values (i.e. between 0 and 1).
|
||||
* A distance value then lies between 0 and sqrt(nObjectives).
|
||||
* A class allowing to compute the bertoluzza distance between two fuzzy solutions in the objective space with normalized objective values.
|
||||
* A distance value lies between 0 and sqrt(nObjectives).
|
||||
*/
|
||||
template < class MOEOT>
|
||||
class moeoBertDistance : public moeoObjSpaceDistance < MOEOT >
|
||||
|
|
@ -86,7 +85,7 @@ const Fitness operator()(const ObjectiveVector & _obj1, const ObjectiveVector &
|
|||
|
||||
|
||||
private:
|
||||
ObjectiveVectorNormalizer<MOEOT> Normalizer;
|
||||
moeoFuzzyObjectiveVectorNormalizer<MOEOT> Normalizer;
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
66
moeo/src/distance/moeoExpectedFuzzyDistance.h
Normal file
66
moeo/src/distance/moeoExpectedFuzzyDistance.h
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
<moeoExpectedFuzzyDistance.h>
|
||||
Oumayma BAHRI
|
||||
|
||||
Author:
|
||||
Oumayma BAHRI <oumaymabahri.com>
|
||||
|
||||
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef MOEOEXPECTEDFUZZYDISTANCE_H_
|
||||
#define MOEOEXPECTEDFUZZYDISTANCE_H_
|
||||
|
||||
#include <math.h>
|
||||
#include <distance/moeoObjSpaceDistance.h>
|
||||
#include <utils/moeoFuzzyObjectiveVectorNormalizer.h>
|
||||
|
||||
/**
|
||||
* An expected euclidian distance between two fuzzy solutions in the objective space
|
||||
* Every solution value is expressed by a triangular fuzzy number
|
||||
*/
|
||||
template < class MOEOT>
|
||||
class moeoExpectedFuzzyDistance : public moeoObjSpaceDistance < MOEOT >
|
||||
{
|
||||
public:
|
||||
|
||||
/** the objective vector type of the solutions */
|
||||
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
|
||||
/** the fitness type of the solutions */
|
||||
typedef typename MOEOT::Fitness Fitness;
|
||||
|
||||
/**
|
||||
default ctr
|
||||
*/
|
||||
moeoExpectedFuzzyDistance ()
|
||||
{}
|
||||
|
||||
/**
|
||||
* tmp1 and tmp2 take the Expected values of Objective vectors
|
||||
* Returns the expected distance between _obj1 and _obj2 in the objective space
|
||||
* @param _obj1 the first objective vector
|
||||
* @param _obj2 the second objective vector
|
||||
*/
|
||||
const Fitness operator()(const ObjectiveVector & _obj1, const ObjectiveVector & _obj2)
|
||||
{
|
||||
Fitness result = 0.0;
|
||||
Fitness tmp1, tmp2;
|
||||
for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)
|
||||
{
|
||||
|
||||
tmp1 = ((_obj1)[i].first + (_obj1)[i].third + 2 *(_obj1)[i].second ) /4 ;
|
||||
tmp2 = ((_obj2)[i].first + (_obj2)[i].third + 2* (_obj2)[i].second ) /4 ;
|
||||
|
||||
|
||||
result += (tmp1-tmp2) * (tmp1-tmp2);
|
||||
}
|
||||
return sqrt(result);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif /*MOEOEXPECTEDFUZZYDISTANCE_H_*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue