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

Method constructNetworkLevelReasoner

src/engine/InputQuery.cpp:733–852  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

731}
732
733bool InputQuery::constructNetworkLevelReasoner( List<Equation> &unhandledEquations,
734 Set<unsigned> &varsInUnhandledConstraints )
735{
736 INPUT_QUERY_LOG( "PP: constructing an NLR... " );
737
738 if ( _networkLevelReasoner )
739 delete _networkLevelReasoner;
740 NLR::NetworkLevelReasoner *nlr = new NLR::NetworkLevelReasoner;
741
742 Map<unsigned, unsigned> handledVariableToLayer;
743
744 // First, put all the input neurons in layer 0
745 List<unsigned> inputs = getInputVariables();
746 // If there is no input variable, don't construct the nlr
747 if ( inputs.empty() )
748 {
749 INPUT_QUERY_LOG( "unsuccessful\n" );
750 delete nlr;
751 return false;
752 }
753
754 nlr->addLayer( 0, NLR::Layer::INPUT, inputs.size() );
755 unsigned index = 0;
756
757 NLR::Layer *inputLayer = nlr->getLayer( 0 );
758 for ( const auto &inputVariable : inputs )
759 {
760 nlr->setNeuronVariable( NLR::NeuronIndex( 0, index ), inputVariable );
761 handledVariableToLayer[inputVariable] = 0;
762
763 inputLayer->setLb( index,
764 _lowerBounds.exists( inputVariable ) ? _lowerBounds[inputVariable]
765 : FloatUtils::negativeInfinity() );
766 inputLayer->setUb( index,
767 _upperBounds.exists( inputVariable ) ? _upperBounds[inputVariable]
768 : FloatUtils::infinity() );
769
770 ++index;
771 }
772
773 unsigned newLayerIndex = 1;
774 Set<unsigned> handledEquations;
775 Set<PiecewiseLinearConstraint *> handledPLConstraints;
776 Set<NonlinearConstraint *> handledNLConstraints;
777 // Now, repeatedly attempt to construct additional layers
778 while (
779 constructWeighedSumLayer( nlr, handledVariableToLayer, newLayerIndex, handledEquations ) ||
780 constructReluLayer( nlr, handledVariableToLayer, newLayerIndex, handledPLConstraints ) ||
781 constructRoundLayer( nlr, handledVariableToLayer, newLayerIndex, handledNLConstraints ) ||
782 constructLeakyReluLayer(
783 nlr, handledVariableToLayer, newLayerIndex, handledPLConstraints ) ||
784 constructAbsoluteValueLayer(
785 nlr, handledVariableToLayer, newLayerIndex, handledPLConstraints ) ||
786 constructSignLayer( nlr, handledVariableToLayer, newLayerIndex, handledPLConstraints ) ||
787 constructSigmoidLayer( nlr, handledVariableToLayer, newLayerIndex, handledNLConstraints ) ||
788 constructMaxLayer( nlr, handledVariableToLayer, newLayerIndex, handledPLConstraints ) ||
789 constructBilinearLayer(
790 nlr, handledVariableToLayer, newLayerIndex, handledNLConstraints ) ||

Calls 15

StringfClass · 0.85
addLayerMethod · 0.80
getLayerMethod · 0.80
setLbMethod · 0.80
setUbMethod · 0.80
getNumberOfLayersMethod · 0.80
asciiMethod · 0.80
NeuronIndexClass · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
setNeuronVariableMethod · 0.45
existsMethod · 0.45