in api/model.cpp [593:659]
bool Model::excludeConflictingParamValues()
{
bool ret = false;
// for each pair of submodels (pseudoparams)
for( size_t pseudo1 = 0; pseudo1 < GetParameters().size(); ++pseudo1 )
{
Parameter* s1 = GetParameters()[ pseudo1 ];
assert( s1 );
if( nullptr == s1 || nullptr == s1->GetComponents() ) continue;
for( size_t pseudo2 = pseudo1 + 1; pseudo2 < GetParameters().size(); ++pseudo2 )
{
Parameter* s2 = GetParameters()[ pseudo2 ];
assert( s2 );
if( nullptr == s2 || nullptr == s2->GetComponents() ) continue;
// for each param p1 in s1
ParamCollection::iterator p1;
ParamCollection::iterator p2;
for( p1 = s1->GetComponents()->begin(); p1 != s1->GetComponents()->end(); ++p1 )
{
// find corresponsing param p2 in s2 by name
for( p2 = s2->GetComponents()->begin(); p2 != s2->GetComponents()->end(); ++p2 )
{
// compare by name, names are unique
if( *p1 == *p2 ) break;
}
// if p2 does not exist, continue
if( p2 == s2->GetComponents()->end() ) continue;
int np1 = static_cast<int>( distance( s1->GetComponents()->begin(), p1 ) );
int np2 = static_cast<int>( distance( s2->GetComponents()->begin(), p2 ) );
// for each row r1 in s1
// for each row r2 in s2
for( int v1 = 0; v1 < s1->GetValueCount(); ++v1 )
{
for( int v2 = 0; v2 < s2->GetValueCount(); ++v2 )
{
// if r1.p1 != r2.p2
// add r1, r2 to exlusions
if( s1->GetModel()->GetResults()[ v1 ][ np1 ] !=
s2->GetModel()->GetResults()[ v2 ][ np2 ] )
{
Exclusion excl;
excl.insert( make_pair( s1, v1 ) );
excl.insert( make_pair( s2, v2 ) );
m_exclusions.insert( excl );
ret = true;
}
}
}
}
}
}
DOUT( L"-- exclusions for submodels -- size: " << (int) m_exclusions.size() << endl );
for( auto & exclusion : m_exclusions )
{
exclusion.Print();
}
DOUT( L"------------------------------ " << endl );
return( ret );
}