WilliamsGMMReducer.cpp
Go to the documentation of this file.
1/*
2* This file is part of ArmarX.
3*
4* ArmarX is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License version 2 as
6* published by the Free Software Foundation.
7*
8* ArmarX is distributed in the hope that it will be useful, but
9* WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details.
12*
13* You should have received a copy of the GNU General Public License
14* along with this program. If not, see <http://www.gnu.org/licenses/>.
15*
16* @package MemoryX::GaussianMixtureHelpers
17* @author Alexey Kozlov <kozlov@kit.edu>
18* @copyright 2013 Alexey Kozlov
19* @license http://www.gnu.org/licenses/gpl-2.0.txt
20* GNU General Public License
21*/
22
23#include "WilliamsGMMReducer.h"
24
25#include "ISDDistance.h"
26
27namespace memoryx
28{
30 {
31 isdDistance.reset(new ISDDistance());
32 // gmmDistance.reset(isdDistance.get());
33 }
34
35 float
36 WilliamsGMMReducer::getMergingCost(const GaussianMixtureDistributionBasePtr& gmm,
37 int c1,
38 int c2)
39 {
40 // TODO this could be calculated a way more efficient
42 GaussianMixtureDistributionPtr::dynamicCast(gmm->clone());
43 mergeGMMComponents(reducedGMM, c1, c2);
44 return gmmDistance->getDistance(gmm, reducedGMM);
45 }
46
47 void
48 WilliamsGMMReducer::fillMergingCostVector(const GaussianMixtureDistributionBasePtr& gmm,
50 {
52 GaussianMixtureDistributionPtr::dynamicCast(gmm->clone());
53 float d11 = isdDistance->calcSelfLikeness(gmm);
54 const int GMM_SIZE = gmm->size();
55
56 for (int i = 0; i < GMM_SIZE - 1; ++i)
57 for (int j = i + 1; j < GMM_SIZE; ++j)
58 {
59 // GaussianMixtureDistributionPtr reducedGMM = GaussianMixtureDistributionPtr::dynamicCast(gmm->clone());
60 GaussianMixtureComponent c1 = reducedGMM->getComponent(i);
61 GaussianMixtureComponent c2 = reducedGMM->getComponent(j);
62 mergeGMMComponents(reducedGMM, i, j);
63 const float cost = isdDistance->getDistance(gmm, reducedGMM, d11);
64 const int index = i * GMM_SIZE + j;
65 costVec.push_back(GMMCompPairDistance(index, cost));
66 reducedGMM->setComponent(i, c1);
67 reducedGMM->addComponent(c2);
68 }
69 }
70} // namespace memoryx
uint8_t index
GMMDistancePtr gmmDistance
Definition GMMReducer.h:85
GMMReducer()
Creates a new GMMReducer.
Definition GMMReducer.h:57
void mergeGMMComponents(const GaussianMixtureComponent &comp1, const GaussianMixtureComponent &comp2, GaussianMixtureComponent &mergedComp)
void fillMergingCostVector(const GaussianMixtureDistributionBasePtr &gmm, GMMCompPairDistanceVector &costVec) override
float getMergingCost(const GaussianMixtureDistributionBasePtr &gmm, int c1, int c2) override
VirtualRobot headers.
IceInternal::Handle< GaussianMixtureDistribution > GaussianMixtureDistributionPtr
std::vector< GMMCompPairDistance > GMMCompPairDistanceVector
Definition GMMReducer.h:45
std::pair< int, float > GMMCompPairDistance
Definition GMMReducer.h:44