Ignore:
Timestamp:
04/01/21 17:07:37 (9 days ago)
Author:
Maciej Komosinski
Message:

Used a local random number generator for full determinism. Introduced a few refactorings for better performance.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/model/similarity/measure-distribution.h

    r1048 r1120  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    88#include "simil-measure-base.h"
    99#include "EMD/emd.h"
     10#include <random>
    1011
    1112class SimilMeasureDistribution : public SimilMeasureBase
     
    1314public:
    1415        SimilMeasureDistribution();
    15         ~SimilMeasureDistribution(){};
     16        ~SimilMeasureDistribution() {};
    1617        int setParams(std::vector<double> params);
    1718        void calculateFuns();
    18         void calculateFun(std::pair<double, float> *fun, Model &sampled);
     19        void calculateFun(std::pair<double, float> *fun, const Model &sampled);
    1920        double compareFuns();
    2021        double EMD(std::pair<double, float> *fun1, std::pair<double, float> *fun2);
     
    2829        std::pair<double, float> *funs[2];
    2930        SolidsShapeTypeModel *sst_models[2];
    30         std::vector<double> (SimilMeasureDistribution::*distribution_fun)(int samples_taken, Model *sampled);
     31        void (SimilMeasureDistribution::*distribution_fun)(int samples_taken, std::uniform_int_distribution<> &distribution, const Model &sampled, std::vector<double> &dist_vect);
    3132
    3233        void fillPointsWeights(std::pair<double, float> *fun, feature_t *points, float *weights);
    3334        double getDistance();
    34         std::vector<double> D2(int samples_taken, Model *sampled);
    35         std::vector<double> D1(int samples_taken, Model *sampled);
    36         std::vector<double> D3(int samples_taken, Model *sampled);
    37         std::vector<double> D4(int samples_taken, Model *sampled);
    38         std::vector<double> A3(int samples_taken, Model *sampled);
     35        void D2(int samples_taken, std::uniform_int_distribution<> &distribution, const Model &sampled, std::vector<double> &dist_vect);
     36        void D1(int samples_taken, std::uniform_int_distribution<> &distribution, const Model &sampled, std::vector<double> &dist_vect);
     37        void D3(int samples_taken, std::uniform_int_distribution<> &distribution, const Model &sampled, std::vector<double> &dist_vect);
     38        void D4(int samples_taken, std::uniform_int_distribution<> &distribution, const Model &sampled, std::vector<double> &dist_vect);
     39        void A3(int samples_taken, std::uniform_int_distribution<> &distribution, const Model &sampled, std::vector<double> &dist_vect);
     40
     41private:
     42        std::mt19937 rndgen;
    3943};
    4044
Note: See TracChangeset for help on using the changeset viewer.