Пример #1
0
// Constructor, intended for root node
Node::Node(ConstraintPtr constraints)
    : constraints(constraints->clone(true)), // Deep copy
      nodeId(getNextNodeId())
{
    objLowerBound = -INF;
    objUpperBound = INF;
    solLowerBound = std::vector<double>(constraints->getNumVariables(), 0.0);
    solUpperBound = std::vector<double>(constraints->getNumVariables(), 0.0);
    depth = 0;
    parentBranchingVariable = -1; // -1 for root node

    auto bvars = findBranchingVariables(this->constraints);

    // Initialize branching/pseudo costs
    double cost = 1.0;
    for (auto var : bvars)
    {
        if (var->getType() == VariableType::CONTINUOUS)
        {
            // Continuous
            pCostsContinuous.emplace(getVariableIndex(var), cost);
        }
        else
        {
            // Integer
            pCostsInteger.emplace(getVariableIndex(var), 1.0);
        }
    }

    assert(bvars.size() == pCostsInteger.size() + pCostsContinuous.size());
}
Пример #2
0
int getVariable()
{
    if ( !getVariableIndex ) return 0;
    Ivar = getVariableIndex(Token);
    if (Ivar >= 0) return 8;
    return 0;
}
void test_getVariableIndex_given_4096_should_return_13()
{
    int numberofbits;
    
    //initialize dictionary
    Dictionary *dict = initDictionary(10);
    dict->currentIndex = 4095;
    
    numberofbits = getVariableIndex(dict);
    TEST_ASSERT_EQUAL(13 , numberofbits);
}