-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathPolygonalTightening.h
More file actions
101 lines (87 loc) · 2.71 KB
/
PolygonalTightening.h
File metadata and controls
101 lines (87 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/********************* */
/*! \file PolygonalTightening.h
** \verbatim
** Top contributors (to current version):
** Duligur Ibeling, Guy Katz, Ido Shmuel
** This file is part of the Marabou project.
** Copyright (c) 2017-2024 by the authors listed in the file AUTHORS
** in the top-level source directory) and their institutional affiliations.
** All rights reserved. See the file COPYING in the top-level source
** directory for licensing information.\endverbatim
**
** [[ Add lengthier description here ]]
**/
#ifndef __PolygonalTightening_h__
#define __PolygonalTightening_h__
#include "Map.h"
#include "NeuronIndex.h"
#include <cstdio>
class PolygonalTightening
{
public:
enum PolygonalBoundType {
LB = 0,
UB = 1,
};
PolygonalTightening( Map<NLR::NeuronIndex, double> neuronToCoefficient,
double value,
PolygonalBoundType type )
: _neuronToCoefficient( neuronToCoefficient )
, _value( value )
, _type( type )
{
}
/*
The coefficient of each neuron.
*/
Map<NLR::NeuronIndex, double> _neuronToCoefficient;
/*
Its new value.
*/
double _value;
/*
Whether the tightening tightens the
lower bound or the upper bound.
*/
PolygonalBoundType _type;
/*
Equality operator.
*/
bool operator==( const PolygonalTightening &other ) const
{
bool allFound = true;
for ( const auto &pair : _neuronToCoefficient )
{
bool currentFound = false;
for ( const auto &otherPair : other._neuronToCoefficient )
{
currentFound |= ( pair.first._layer == otherPair.first._layer &&
pair.first._neuron == otherPair.first._neuron &&
pair.second == otherPair.second );
}
allFound &= currentFound;
}
bool result = allFound && _value == other._value && _type == other._type &&
_neuronToCoefficient.size() == other._neuronToCoefficient.size();
return result;
}
void dump() const
{
printf( "PolygonalTightening: x %s %.2lf\n", _type == LB ? ">=" : "<=", _value );
for ( const auto &pair : _neuronToCoefficient )
{
printf( "NeuronIndex: (layer %u, neuron %u), Coefficient: %.2lf )\n",
pair.first._layer,
pair.first._neuron,
pair.second );
}
}
};
#endif // __PolygonalTightening_h__
//
// Local Variables:
// compile-command: "make -C ../.. "
// tags-file-name: "../../TAGS"
// c-basic-offset: 4
// End:
// s