Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit 78b2007d authored by frey_m's avatar frey_m
Browse files

Closes #266

parent b7b30609
No related branches found
No related tags found
1 merge request!46Issue 266
......@@ -22,10 +22,8 @@ class SampleGaussianSequence : public SamplingMethod
public:
SampleGaussianSequence(double lower, double upper, size_t modulo, int nSample)
: sampleNr_m(0)
, numSamples_m(nSample)
: numSamples_m(nSample)
, volumeLowerDimensions_m(modulo)
, individualCounter_m(0)
{
double mean = 0.5 * (lower + upper);
double sigma = (upper - lower) / 10; // +- 5 sigma
......@@ -39,13 +37,13 @@ public:
}
void create(boost::shared_ptr<SampleIndividual>& ind, size_t i) {
ind->genes[i] = getNext();
ind->genes[i] = getNext(ind->id);
}
double getNext() {
double sample = sampleChain_m[sampleNr_m];
incrementCounter();
double getNext(unsigned int id) {
int bin = int(id / volumeLowerDimensions_m) % numSamples_m;
double sample = sampleChain_m[bin];
return sample;
}
......@@ -54,18 +52,8 @@ private:
FRIEND_TEST(GaussianSampleTest, ChainTest);
#endif
std::vector<double> sampleChain_m;
unsigned int sampleNr_m;
unsigned int numSamples_m; // size of this "dimension"
size_t volumeLowerDimensions_m; // the "volume" of the sampling space of the lower "dimensions"
size_t individualCounter_m; // counts how many "individuals" have been created
void incrementCounter() {
++ individualCounter_m;
if (individualCounter_m % volumeLowerDimensions_m == 0)
++ sampleNr_m;
sampleNr_m = sampleNr_m % numSamples_m;
}
};
#endif
\ No newline at end of file
......@@ -17,77 +17,24 @@ public:
SampleSequence(T lower, T upper, size_t modulo, int nSample)
: lowerLimit_m(lower)
, stepSize_m( (upper - lower) / double(nSample - 1) )
, sampleNr_m(0)
, numSamples_m(nSample)
, volumeLowerDimensions_m(modulo)
, individualCounter_m(0)
, idim_m(nSequenceSamplers++)
, shift_m(0)
{ }
void create(boost::shared_ptr<SampleIndividual>& ind, size_t i) {
unsigned int id = ind->id;
sampleNr_m = int(id / volumeLowerDimensions_m) % numSamples_m;
int bin = int(id / volumeLowerDimensions_m) % numSamples_m;
ind->genes[i] = static_cast<T>(lowerLimit_m + stepSize_m * sampleNr_m);
// incrementCounter();
ind->genes[i] = static_cast<T>(lowerLimit_m + stepSize_m * bin);
}
void allocate(const CmdArguments_t& args, const Comm::Bundle_t& comm) {
// int nMasters = args->getArg<int>("num-masters", true);
//
// std::cout << "idim: " << idim_m << std::endl;
//
// if ( nMasters > 1 && idim_m == 0 ) {
// int nLocSamples = numSamples_m / nMasters;
// int rest = numSamples_m - nMasters * nLocSamples;
//
// int id = comm.island_id;
//
// if ( id < rest )
// nLocSamples++;
//
// if ( rest == 0 )
// shift_m = nLocSamples * id;
// else {
// if ( id < rest ) {
// shift_m = nLocSamples * id;
// } else {
// shift_m = (nLocSamples + 1) * rest + (id - rest) * nLocSamples;
// }
// }
// numSamples_m = nLocSamples;
//
// sampleNr_m = shift_m;
//
// std::cout << "shift:" << shift_m << std::endl;
// } else {
//
// }
}
private:
void incrementCounter() {
++ individualCounter_m;
if (individualCounter_m % volumeLowerDimensions_m == 0)
++ sampleNr_m;
sampleNr_m = sampleNr_m % numSamples_m + shift_m;
// std::cout << idim_m << " " << sampleNr_m << " " << numSamples_m
// << " " << shift_m << " " << volumeLowerDimensions_m << std::endl;
}
T lowerLimit_m;
double stepSize_m;
unsigned int sampleNr_m;
unsigned int numSamples_m; // size of this "dimension"
size_t volumeLowerDimensions_m; // the "volume" of the sampling space of the lower "dimensions"
size_t individualCounter_m; // counts how many "individuals" have been created
int idim_m;
int shift_m;
};
#endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment