in api/model.cpp [1013:1096]
bool Model::mapExclusionsToPseudoParameters()
{
bool ret = false;
// for each pseudoparameter
for( size_t index = 0; index < GetParameters().size(); ++index )
{
Parameter* param = GetParameters()[ index ];
ParamCollection* comps = param->GetComponents();
if( comps )
{
// orepare a temporary collection for all exclusions being added
ExclusionCollection newExcls;
// this parameter is really a pseudoparameter
for( ExclusionCollection::iterator iexcls = m_exclusions.begin(); iexcls != m_exclusions.end(); )
{
// partition exclusion terms into related, unrelated (to pseudoparam)
Exclusion relatedTerms;
Exclusion unrelatedTerms;
for( Exclusion::iterator iexcl = iexcls->begin(); iexcl != iexcls->end(); ++iexcl )
{
if( find( comps->begin(), comps->end(), iexcl->first ) == comps->end() )
{
unrelatedTerms.insert( *iexcl );
}
else
{
relatedTerms.insert( *iexcl );
}
}
// if any of exclusion's terms relate to underlying parameters
if( !relatedTerms.empty() )
{
// Get rid of the exclusion, since we'll replace it
m_exclusions.erase( iexcls++ );
// for each value of the pseudoparameter
for( int vidx = 0; vidx < param->GetValueCount(); ++vidx )
{
Exclusion::iterator irel;
for( irel = relatedTerms.begin(); irel != relatedTerms.end(); ++irel )
{
vector<Parameter*>::iterator ip = find( comps->begin(), comps->end(), irel->first );
if( comps->end() == ip )
{
break;
}
int nParam = static_cast<int>( distance( comps->begin(), ip ) );
size_t nRealVal = param->GetModel()->GetResults()[ vidx ][ nParam ];
if( nRealVal != irel->second )
{
break;
}
}
// if value is excluded in overlapping underlying params
if( relatedTerms.end() == irel )
{
// generate a new exclusion using unrelated + this pseudo/value
Exclusion newExclusion( unrelatedTerms );
newExclusion.insert( make_pair( param, vidx ) );
// Put it into a temporary collection so we don't hit it again on this iteration
newExcls.insert( newExclusion );
ret = true;
}
}
}
else
{
// no new exclusion, just increment loop iterator
++iexcls;
}
}
// copy all new exclusions to the main collection
__insert( m_exclusions, newExcls.begin(), newExcls.end() );
}
}
return( ret );
}