示例#1
0
 void MultiThreadedSplitter<Heuristic,PrimRefBlockList>::task_split_parallel_reduce(size_t threadIndex, size_t threadCount, TaskScheduler::Event* event)
 {
   Heuristic lheuristic; Heuristic::reduce(lheuristics,numTasks,lheuristic); linfo = split.linfo; lheuristic.best(lsplit); 
   Heuristic rheuristic; Heuristic::reduce(rheuristics,numTasks,rheuristic); rinfo = split.rinfo; rheuristic.best(rsplit); 
   assert(linfo.size());
   assert(rinfo.size());
   cfun(cptr,threadIndex,threadCount,event);
 }
示例#2
0
 void PrimRefGen<Heuristic>::task_gen_parallel_reduce(size_t threadIndex, size_t threadCount, TaskScheduler::Event* event) 
 {
   /* reduce geometry and centroid bounds */
   size_t numAddedPrims = 0;
   BBox3fa geomBound = empty;
   BBox3fa centBound = empty;
   for (size_t i=0; i<numTasks; i++) {
     geomBound = merge(geomBound,geomBounds[i]);
     centBound = merge(centBound,centBounds[i]);
     numAddedPrims += work[i].numPrims;
   }
   new (&pinfo) PrimInfo(numAddedPrims,geomBound,centBound,pinfo);
   
   /* reduce heuristic and find best split */
   Heuristic heuristic; 
   Heuristic::reduce(heuristics,numTasks,heuristic); 
   heuristic.best(split);
 }
示例#3
0
    void Machinery::setup(const kerberos::StringMap & settings)
    {
        // -----------------------------------------------------------
        // Creates condition, algorithms, expositors, heuristics and io handlers.
        
        LINFO << "Starting conditions: " + settings.at("condition");
        std::vector<Condition *> conditions = Factory<Condition>::getInstance()->createMultiple(settings.at("condition"));
        for(int i = 0; i < conditions.size(); i++)
        {
            conditions[i]->setup(settings);
        }
        setCondition(conditions);

        LINFO << "Starting algorithm: " + settings.at("algorithm");
        Algorithm * algorithm = Factory<Algorithm>::getInstance()->create(settings.at("algorithm"));
        algorithm->setup(settings);
        setAlgorithm(algorithm);

        LINFO << "Starting expositor: " + settings.at("expositor");
        Expositor * expositor = Factory<Expositor>::getInstance()->create(settings.at("expositor"));
        expositor->setup(settings);
        setExpositor(expositor);

        LINFO << "Starting heuristic: " + settings.at("heuristic");
        Heuristic * heuristic = Factory<Heuristic>::getInstance()->create(settings.at("heuristic"));
        heuristic->setup(settings);
        setHeuristic(heuristic);  

        LINFO << "Starting io devices: " + settings.at("io");
        std::vector<Io *> ios = Factory<Io>::getInstance()->createMultiple(settings.at("io"));
        for(int i = 0; i < ios.size(); i++)
        {
            ios[i]->setup(settings);
        }
        setIo(ios);
    }
TEST(SEQUENCE_HEURISTIC, IS_VALID)
{
    Heuristic * heuristic = Factory<Heuristic>::getInstance()->create("Sequence");

    StringMap settings;
    settings["heuristics.Sequence.minimumChanges"] = "1";
    settings["heuristics.Sequence.minimumDuration"] = "2";
    settings["heuristics.Sequence.motionDelayTime"] = "1000";
    settings["heuristics.Sequence.noMotionDelayTime"] = "1000";
    heuristic->setup(settings);

    // ----------------------------
    // Mocking image

    Image image;
    ImageVector images;

    JSON json;
    JSON::AllocatorType& allocator = json.GetAllocator();

    json.SetObject();
    json.AddMember("numberOfChanges", 0, allocator);

    // --------------------
    // Nothing changed thus false.
    bool isValid = heuristic->isValid(image, images, json);
    EXPECT_EQ(false, isValid);

    // ---------------------
    // Changed, but this is only the first occurence thus again false.
    json.RemoveMember ("numberOfChanges");
    json.AddMember("numberOfChanges", 1, allocator);
    isValid = heuristic->isValid(image, images, json);
    EXPECT_EQ(false, isValid);

    // ---------------------
    // Changed and the second occurence thus true.
    isValid = heuristic->isValid(image, images, json);
    EXPECT_EQ(true, isValid);
}