MCPcopy Create free account
hub / github.com/NeuralNetworkVerification/Marabou / processIdenticalVariables

Method processIdenticalVariables

src/engine/Preprocessor.cpp:590–648  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

588}
589
590bool Preprocessor::processIdenticalVariables()
591{
592 List<Equation> &equations( _preprocessed->getEquations() );
593 List<Equation>::iterator equation = equations.begin();
594
595 bool found = false;
596 while ( equation != equations.end() )
597 {
598 // We are only looking for equations of type c(v1 - v2) = 0
599 if ( equation->_addends.size() != 2 || equation->_type != Equation::EQ )
600 {
601 ++equation;
602 continue;
603 }
604
605 Equation::Addend term1 = equation->_addends.front();
606 Equation::Addend term2 = equation->_addends.back();
607
608 if ( FloatUtils::areDisequal( term1._coefficient, -term2._coefficient ) ||
609 !FloatUtils::isZero( equation->_scalar ) )
610 {
611 ++equation;
612 continue;
613 }
614
615 ASSERT( term1._variable != term2._variable );
616
617 // The equation matches the pattern, extract the variables
618 unsigned v1 = term1._variable;
619 unsigned v2 = term2._variable;
620
621 // Input and output variables should not be merged
622 if ( _uneliminableVariables.exists( v1 ) || _uneliminableVariables.exists( v2 ) )
623 {
624 ++equation;
625 continue;
626 }
627
628 // This equation can be removed
629 found = true;
630
631 double bestLowerBound =
632 getLowerBound( v1 ) > getLowerBound( v2 ) ? getLowerBound( v1 ) : getLowerBound( v2 );
633
634 double bestUpperBound =
635 getUpperBound( v1 ) < getUpperBound( v2 ) ? getUpperBound( v1 ) : getUpperBound( v2 );
636
637 equation = equations.erase( equation );
638
639 setLowerBound( v2, bestLowerBound );
640 setUpperBound( v2, bestUpperBound );
641
642 _preprocessed->mergeIdenticalVariables( v1, v2 );
643
644 _mergedVariables[v1] = v2;
645 }
646
647 return found;

Callers

nothing calls this directly

Calls 7

getEquationsMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
existsMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected