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

Method constructBilinearLayer

src/engine/InputQuery.cpp:1718–1823  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1716}
1717
1718bool InputQuery::constructBilinearLayer( NLR::NetworkLevelReasoner *nlr,
1719 Map<unsigned, unsigned> &handledVariableToLayer,
1720 unsigned newLayerIndex,
1721 Set<NonlinearConstraint *> &handledNLConstraints )
1722{
1723 INPUT_QUERY_LOG( "Attempting to construct BilinearLayer..." );
1724 struct NeuronInformation
1725 {
1726 public:
1727 NeuronInformation( unsigned variable,
1728 unsigned neuron,
1729 const Vector<unsigned> &sourceVariables )
1730 : _variable( variable )
1731 , _neuron( neuron )
1732 , _sourceVariables( sourceVariables )
1733 {
1734 }
1735
1736 unsigned _variable;
1737 unsigned _neuron;
1738 Vector<unsigned> _sourceVariables;
1739 };
1740
1741 List<NeuronInformation> newNeurons;
1742
1743 // Look for Bilinear constaints where all the element variables have already been handled
1744 const List<NonlinearConstraint *> &nlConstraints = getNonlinearConstraints();
1745
1746 for ( const auto &nlc : nlConstraints )
1747 {
1748 if ( handledNLConstraints.exists( nlc ) )
1749 continue;
1750
1751 // Only consider bilinear
1752 if ( nlc->getType() != BILINEAR )
1753 continue;
1754
1755 const BilinearConstraint *bilinear = (const BilinearConstraint *)nlc;
1756
1757 // Have all elements been handled?
1758 bool missingElement = false;
1759 for ( const auto &element : bilinear->getBs() )
1760 {
1761 if ( !handledVariableToLayer.exists( element ) )
1762 {
1763 missingElement = true;
1764 break;
1765 }
1766 }
1767
1768 if ( missingElement )
1769 continue;
1770
1771 // If the f variable has also been handled, ignore this constraint
1772 unsigned f = bilinear->getF();
1773 if ( handledVariableToLayer.exists( f ) )
1774 continue;
1775

Callers

nothing calls this directly

Calls 15

NeuronInformationClass · 0.85
getBsMethod · 0.80
addLayerMethod · 0.80
getLayerMethod · 0.80
setLbMethod · 0.80
setUbMethod · 0.80
variableToNeuronMethod · 0.80
addLayerDependencyMethod · 0.80
NeuronIndexClass · 0.50
existsMethod · 0.45
getTypeMethod · 0.45
getFMethod · 0.45

Tested by

no test coverage detected