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

Method constructWeighedSumLayer

src/engine/InputQuery.cpp:879–1000  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

877}
878
879bool InputQuery::constructWeighedSumLayer( NLR::NetworkLevelReasoner *nlr,
880 Map<unsigned, unsigned> &handledVariableToLayer,
881 unsigned newLayerIndex,
882 Set<unsigned> &handledEquations )
883{
884 INPUT_QUERY_LOG( "Attempting to construct weightedSumLayer..." );
885 struct NeuronInformation
886 {
887 public:
888 NeuronInformation( unsigned variable, unsigned neuron, const Equation *eq )
889 : _variable( variable )
890 , _neuron( neuron )
891 , _eq( eq )
892 {
893 }
894
895 NeuronInformation()
896 : _eq( NULL )
897 {
898 }
899
900 unsigned _variable;
901 unsigned _neuron;
902 const Equation *_eq;
903 };
904
905 List<NeuronInformation> newNeurons;
906
907 // Look for equations where all variables except one have already been handled
908 const List<Equation> &equations = getEquations();
909 unsigned index = 0;
910 for ( const auto &eq : equations )
911 {
912 if ( handledEquations.exists( index++ ) )
913 continue;
914
915 // Only consider equalities
916 if ( eq._type != Equation::EQ )
917 continue;
918
919 List<unsigned> eqVariables = eq.getListParticipatingVariables();
920 auto it = eqVariables.begin();
921 while ( it != eqVariables.end() )
922 {
923 if ( handledVariableToLayer.exists( *it ) )
924 it = eqVariables.erase( it );
925 else
926 ++it;
927 }
928
929 if ( eqVariables.size() == 1 )
930 {
931 // Add the surviving variable to the new layer
932 newNeurons.append( NeuronInformation( *eqVariables.begin(), newNeurons.size(), &eq ) );
933 handledEquations.insert( index - 1 );
934 }
935 }
936

Callers

nothing calls this directly

Calls 15

NeuronInformationClass · 0.85
addLayerMethod · 0.80
getLayerMethod · 0.80
setLbMethod · 0.80
setUbMethod · 0.80
getCoefficientMethod · 0.80
variableToNeuronMethod · 0.80
addLayerDependencyMethod · 0.80
NeuronIndexClass · 0.50
existsMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected