Esempio n. 1
0
const std::vector<Row>& CsvGenerator::generate(int nbRowGenerate) {
    this->_rows.clear();
    std::vector<Category> categories = this->normalizeCategories();
    for (int y = 0; y < nbRowGenerate; ++y) {
        Row newRow;
        int x = 0;
        std::vector<Category>::iterator current_category = categories.begin();
        while (current_category != categories.end()) {
            Node newNode;
            const std::pair<std::string, float> value =
                current_category->getRandomValue();
            if (current_category->isMaximazed())
                newNode.setParams(value.first, value.second,
                                  std::pair<int, int>(x, y));
            else
                newNode.setParams(value.first,
                                  current_category->maxNodeWeight() - value.second,
                                  std::pair<int, int>(x, y));
            current_category->addNode(newNode);
            newRow.addNode(newNode);
            current_category++;
        }
        this->_rows.push_back(newRow.normalize());
    }
    return this->_rows;
}
Esempio n. 2
0
bool  CsvGenerator::isControlate(const std::vector<std::string>& values) {
    std::vector<Category> categories = this->normalizeCategories();
    std::vector<Category>::const_iterator begin_categories = categories.begin();
    std::vector<Category>::const_iterator end_categories = categories.end();
    Row	newRow;
    unsigned int 	i = 0;
    while (begin_categories != end_categories && i < values.size())
    {
        std::string name = values[i];
        float weight = begin_categories->findWeightByNameValue(name);
        Node	new_node(name, weight, i, 0);
        newRow.addNode(new_node);
        i++;
        begin_categories++;
    }
    newRow = newRow.normalize();
    CalcPondarateRow pondarateAlgo(categories, this->_controleValue);
    pondarateAlgo.operator()(newRow);
    if ( pondarateAlgo.getTotal() > this->_controleValue)
        return false;
    return true;
}