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 9d0d36cb authored by frey_m's avatar frey_m
Browse files

Issue #266: Sequence trial. Does not work properly.

modified:   CMakeLists.txt
modified:   SampleCmd.cpp
modified:   SampleSequence.h
new file:   SamplingMethod.cpp
modified:   SamplingMethod.h
parent 40505a19
No related branches found
No related tags found
1 merge request!46Issue 266
......@@ -3,6 +3,7 @@ set (_SRCS
RNGStream.cpp
SampleCmd.cpp
Sampler.cpp
SamplingMethod.cpp
)
include_directories (
......
......@@ -232,6 +232,7 @@ void SampleCmd::execute() {
bool raster = Attributes::getBool(itsAttr[RASTER]);
size_t modulo = 1;
size_t tmp = 1;
unsigned int nSample = std::numeric_limits<unsigned int>::max();
std::set<std::string> names; // check if all unique variables
......@@ -262,9 +263,14 @@ void SampleCmd::execute() {
modulo,
raster);
if ( raster )
if ( raster ) {
modulo *= s->getSize();
tmp *= s->getSize();
}
if ( SamplingMethod::nSequenceSamplers == 1)
modulo = 1;
nSample = std::min(nSample, s->getSize());
sampleMethods[name] = s->sampleMethod_m;
......@@ -320,7 +326,7 @@ void SampleCmd::execute() {
}
if ( raster )
nSample = modulo;
nSample = tmp/*modulo*/;
arguments.push_back("--nsamples=" + std::to_string(nSample));
......
......@@ -21,12 +21,47 @@ public:
, 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) {
ind->genes[i] = static_cast<T>(lowerLimit_m + stepSize_m * sampleNr_m);
incrementCounter();
}
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() {
......@@ -34,7 +69,9 @@ private:
if (individualCounter_m % volumeLowerDimensions_m == 0)
++ sampleNr_m;
sampleNr_m = sampleNr_m % numSamples_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;
......@@ -43,6 +80,8 @@ private:
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
#include "SamplingMethod.h"
int SamplingMethod::nSequenceSamplers = 0;
......@@ -31,6 +31,9 @@ public:
* the memory
*/
}
// number of sequence sampling methods (important for multi-master case)
static int nSequenceSamplers;
};
#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