int CMNet::GetFactors( int numberOfNodes, const int *nodes,
		               pFactorVector *params ) const
{
    // the function is to find all the factors which are set on
	// the domains	which contain "nodes" as a subset

	// bad-args check
    PNL_CHECK_LEFT_BORDER( numberOfNodes, 1 );
    PNL_CHECK_IS_NULL_POINTER(nodes);
    PNL_CHECK_IS_NULL_POINTER(params);
	// bad-args check end

    params->clear();


    int       numOfClqs;
    const int *clqsNums;

    GetClqsNumsForNode( *nodes, &numOfClqs, &clqsNums );

    assert( numOfClqs > 0 );

    intVector factsNums( clqsNums, clqsNums + numOfClqs );

    const int *ndsIt   = nodes + 1,
              *nds_end = nodes + numberOfNodes;

    for( ; ndsIt != nds_end; ++ndsIt )
    {
        GetClqsNumsForNode( *ndsIt, &numOfClqs, &clqsNums );

        intVector::iterator       factsNumsIt = factsNums.end() - 1;
        intVector::const_iterator factsNums_before_begin
            = factsNums.begin() - 1;

        for( ; factsNumsIt != factsNums_before_begin; --factsNumsIt )
        {
            if( std::find( clqsNums, clqsNums + numOfClqs, *factsNumsIt )
                == clqsNums + numOfClqs )
            {
                factsNums.erase(factsNumsIt);
            }

            if( factsNums.empty() )
            {
                return 0;
            }
        }
    }

    intVector::const_iterator factsNumsIt   = factsNums.begin(),
	factsNums_end = factsNums.end();

    for( ; factsNumsIt != factsNums_end; ++factsNumsIt )
    {
	params->push_back(GetFactor(*factsNumsIt));
    }

    return 1;
}
Exemple #2
0
std::vector<ExperimentPoint> UiController::experimentalResponcesRequester(const std::vector<ExperimentPoint> &centerVals)
{
    assert((size_t)_experimentTable->x().count() == centerVals.at(centerVals.size() - 1).xs.size());
    std::vector<int> factsNums(_experimentTable->x().count());

    for(size_t i = 0; i < factsNums.size(); i++)
        factsNums[i] = i + 1;

    ImaginarySteps stepsDialog(factsNums, centerVals); //<vector<vector<>> + ExperimentPoints
    std::vector<ExperimentPoint> retPts = stepsDialog.getYp();
    return retPts;
}