Ejemplo n.º 1
0
void IOracle::extract(DoubleVector const & x, Column & column) {
  for (int v(0); v < _input->nV(); ++v) {
    if (x[v] > 0.5) {
      column.insert(v);
    }
  }
  column.cost() = column.computeCost();
}
Ejemplo n.º 2
0
Column* GameTable::GenerateColumn(Uint32 col)
{
    Column* iCol = new Column();

    // The number of blocks to create
    auto rows = rowNum;//randColNum();

    for (Uint32 row = 0; row < rows; row++)
    {
        // Generate new block
        auto bColour = static_cast<BlockColour>(randBlockColor());
        auto bType = static_cast<BlockType>(randBlockType());
        Block* block = new Block(bColour, bType, col, row, 1, 1, ulPos);

        // Generate the pair to populate the column
        auto pair = std::make_pair(row, block);

        // Insert pair
        iCol->insert(pair);
    }

    return iCol;
}
Ejemplo n.º 3
0
int Variable::genColumn(
	Active<Constraint, Variable> *actCon,
	Column &col) const
{
	double eps      = master_->machineEps();
	double minusEps = -eps;
	int    n        = actCon->number();

	expand();

	for (int i = 0; i < n; i++) {
		double co = (*actCon)[i]->coeff(this);
		if (co > eps || co < minusEps) col.insert(i,co);
	}

	col.obj(obj());
	col.lBound(lBound());
	col.uBound(uBound());

	compress();

	return col.nnz();

}
Ejemplo n.º 4
0
void GameTable::UpdateTable()
{
    Uint32 lastRow = 0, lastCol = colLimit - 1;
    Column colMap;
    bool shouldSwap = false;
    bool shouldMoveCol = false;

    // Let's traverse this in the reverse order
    for (auto rit = table->rbegin(); rit != table->rend(); ++rit)
    {
        auto col = rit->first;
        auto colRow = rit->second;

        shouldMoveCol = lastCol != col;
        shouldSwap = false;
        colMap.clear();
        lastRow = 0;
        // For each block in the current column
        for (auto& p2 : *colRow)
        {
            auto row = p2.first;
            auto block = p2.second;

            auto finalRow = (lastRow != row) ? lastRow : row;
            auto finalCol = (lastCol != col) ? lastCol : col;
            if (finalRow != row || finalCol != col)
            {
                // If there is a gap, then recreate the pair
                block->MoveTo(finalCol, finalRow);
                // Generate the pair to populate the column
                auto pair = std::make_pair(finalRow, block);

                // Insert pair
                colMap.insert(pair);
                shouldSwap = true;
            }
            else
            {
                // If there is no gap, then maintain the pair
                // Insert pair
                colMap.insert(p2);
            }

            lastRow++;
        }

        if (shouldSwap)
        {
            colRow->swap(colMap);
        }

        if (shouldMoveCol)
        {
            table->erase(col);
            table->insert(std::make_pair(lastCol, colRow));
        }

        lastCol--;
    }

    // Clean up
    colMap.clear();
}