Skip to content

Commit d9774b7

Browse files
Fix formatting in Constraint classes and tests
1 parent 619a909 commit d9774b7

11 files changed

+92
-100
lines changed

src/engine/AbsoluteValueConstraint.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void AbsoluteValueConstraint::notifyLowerBound( unsigned variable, double bound
126126

127127
if ( _boundManager == nullptr && existsLowerBound( variable ) &&
128128
!FloatUtils::gt( bound, getLowerBound( variable ) ) )
129-
return;
129+
return;
130130

131131
setLowerBound( variable, bound );
132132

@@ -180,7 +180,7 @@ void AbsoluteValueConstraint::notifyUpperBound( unsigned variable, double bound
180180
!FloatUtils::lt( bound, getUpperBound( variable ) ) )
181181
return;
182182

183-
setUpperBound( variable, bound );
183+
setUpperBound( variable, bound );
184184
// Check whether the phase has become fixed
185185
fixPhaseIfNeeded();
186186

@@ -321,7 +321,7 @@ List<PiecewiseLinearConstraint::Fix> AbsoluteValueConstraint::getPossibleFixes()
321321
return fixes;
322322
}
323323

324-
List<PiecewiseLinearConstraint::Fix> AbsoluteValueConstraint::getSmartFixes( ITableau */* tableau */ ) const
324+
List<PiecewiseLinearConstraint::Fix> AbsoluteValueConstraint::getSmartFixes( ITableau * /* tableau */ ) const
325325
{
326326
return getPossibleFixes();
327327
}
@@ -601,8 +601,7 @@ void AbsoluteValueConstraint::getEntailedTightenings( List<Tightening> &tighteni
601601
}
602602
}
603603

604-
void AbsoluteValueConstraint::transformToUseAuxVariables( InputQuery
605-
&inputQuery )
604+
void AbsoluteValueConstraint::transformToUseAuxVariables( InputQuery &inputQuery )
606605
{
607606
/*
608607
We want to add the two equations
@@ -661,7 +660,7 @@ void AbsoluteValueConstraint::getCostFunctionComponent( LinearExpression &cost,
661660
PhaseStatus phase ) const
662661
{
663662
// If the constraint is not active or is fixed, it contributes nothing
664-
if( !isActive() || phaseFixed() )
663+
if ( !isActive() || phaseFixed() )
665664
return;
666665

667666
ASSERT( phase == ABS_PHASE_NEGATIVE || phase == ABS_PHASE_POSITIVE );

src/engine/AbsoluteValueConstraint.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
** * context dependent mode, used during the search.
2424
**
2525
** Invoking initializeCDOs method activates the context dependent mode, and the
26-
** AbsoluteValueConstraint object synchronizes its state automatically with the central
27-
** Context object.
26+
** AbsoluteValueConstraint object synchronizes its state automatically with the
27+
** central Context object.
2828
**/
2929

3030
#ifndef __AbsoluteValueConstraint_h__
@@ -34,7 +34,6 @@
3434

3535
class AbsoluteValueConstraint : public PiecewiseLinearConstraint
3636
{
37-
3837
public:
3938
/*
4039
The f variable is the absolute value of the b variable:
@@ -61,8 +60,8 @@ class AbsoluteValueConstraint : public PiecewiseLinearConstraint
6160
/*
6261
Register/unregister the constraint with a talbeau.
6362
*/
64-
void registerAsWatcher( ITableau *tableau) override;
65-
void unregisterAsWatcher( ITableau *tableau) override;
63+
void registerAsWatcher( ITableau *tableau ) override;
64+
void unregisterAsWatcher( ITableau *tableau ) override;
6665

6766
/*
6867
These callbacks are invoked when a watched variable's value
@@ -114,8 +113,8 @@ class AbsoluteValueConstraint : public PiecewiseLinearConstraint
114113

115114
/*
116115
Returns a list of all cases - { ABS_POSITIVE, ABS_NEGATIVE }
117-
The order of returned cases affects the search, and this method is where related
118-
heuristics should be implemented.
116+
The order of returned cases affects the search, and this method is where
117+
related heuristics should be implemented.
119118
*/
120119
List<PhaseStatus> getAllCases() const override;
121120

@@ -232,4 +231,3 @@ class AbsoluteValueConstraint : public PiecewiseLinearConstraint
232231
};
233232

234233
#endif // __AbsoluteValueConstraint_h__
235-

src/engine/DisjunctionConstraint.cpp

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,24 @@ DisjunctionConstraint::DisjunctionConstraint( const String &serializedDisjunctio
4949
( 5, serializedDisjunction.length() - 5 );
5050
List<String> values = serializedValues.tokenize( "," );
5151
auto val = values.begin();
52-
unsigned numDisjuncts = atoi(val->ascii());
52+
unsigned numDisjuncts = atoi( val->ascii() );
5353
++val;
5454
for ( unsigned i = 0; i < numDisjuncts; ++i )
5555
{
5656
PiecewiseLinearCaseSplit split;
57-
unsigned numBounds = atoi(val->ascii());
57+
unsigned numBounds = atoi( val->ascii() );
5858
++val;
5959
for ( unsigned bi = 0; bi < numBounds; ++bi )
6060
{
61-
Tightening::BoundType type = ( *val == "l") ? Tightening::LB : Tightening::UB;
61+
Tightening::BoundType type = ( *val == "l" ) ? Tightening::LB : Tightening::UB;
6262
++val;
63-
unsigned var = atoi(val->ascii());
63+
unsigned var = atoi( val->ascii() );
6464
++val;
65-
double bd = atof(val->ascii());
65+
double bd = atof( val->ascii() );
6666
++val;
67-
split.storeBoundTightening( Tightening(var, bd, type) );
67+
split.storeBoundTightening( Tightening( var, bd, type ) );
6868
}
69-
unsigned numEquations = atoi(val->ascii());
69+
unsigned numEquations = atoi( val->ascii() );
7070

7171
++val;
7272
for ( unsigned ei = 0; ei < numEquations; ++ei )
@@ -78,29 +78,29 @@ DisjunctionConstraint::DisjunctionConstraint( const String &serializedDisjunctio
7878
type = Equation::GE;
7979
else
8080
{
81-
ASSERT( *val == "e");
81+
ASSERT( *val == "e" );
8282
}
83-
Equation eq(type);
83+
Equation eq( type );
8484
++val;
85-
unsigned numAddends = atoi(val->ascii());
85+
unsigned numAddends = atoi( val->ascii() );
8686
++val;
8787
for ( unsigned ai = 0; ai < numAddends; ++ai )
8888
{
89-
double coef = atof(val->ascii());
89+
double coef = atof( val->ascii() );
9090
++val;
91-
unsigned var = atoi(val->ascii());
91+
unsigned var = atoi( val->ascii() );
9292
++val;
9393
eq.addAddend( coef, var );
9494
}
95-
eq.setScalar(atof(val->ascii()));
95+
eq.setScalar( atof( val->ascii() ) );
9696
++val;
97-
split.addEquation(eq);
97+
split.addEquation( eq );
9898
}
99-
disjuncts.append(split);
99+
disjuncts.append( split );
100100
}
101101
_disjuncts = disjuncts;
102102

103-
for ( unsigned ind = 0; ind < disjuncts.size(); ++ind )
103+
for ( unsigned ind = 0; ind < disjuncts.size(); ++ind )
104104
_feasibleDisjuncts.append( ind );
105105

106106
extractParticipatingVariables();
@@ -151,11 +151,11 @@ void DisjunctionConstraint::notifyLowerBound( unsigned variable, double bound )
151151

152152
if ( _boundManager == nullptr && existsLowerBound( variable ) &&
153153
!FloatUtils::gt( bound, getLowerBound( variable ) ) )
154-
return;
154+
return;
155155

156156
setLowerBound( variable, bound );
157157

158-
//TODO: Maintain a mapping from variables to disjuncts and only check relevant
158+
// TODO: Maintain a mapping from variables to disjuncts and only check relevant
159159
// disjuncts for feasibility
160160
updateFeasibleDisjuncts();
161161
}
@@ -167,11 +167,11 @@ void DisjunctionConstraint::notifyUpperBound( unsigned variable, double bound )
167167

168168
if ( _boundManager == nullptr && existsUpperBound( variable ) &&
169169
!FloatUtils::lt( bound, getUpperBound( variable ) ) )
170-
return;
170+
return;
171171

172172
setUpperBound( variable, bound );
173173

174-
//TODO: Maintain a mapping from variables to disjuncts and only check relevant
174+
// TODO: Maintain a mapping from variables to disjuncts and only check relevant
175175
// disjuncts for feasibility
176176
updateFeasibleDisjuncts();
177177
}
@@ -207,7 +207,7 @@ List<PiecewiseLinearConstraint::Fix> DisjunctionConstraint::getPossibleFixes() c
207207
return List<PiecewiseLinearConstraint::Fix>();
208208
}
209209

210-
List<PiecewiseLinearConstraint::Fix> DisjunctionConstraint::getSmartFixes( ITableau */* tableau */ ) const
210+
List<PiecewiseLinearConstraint::Fix> DisjunctionConstraint::getSmartFixes( ITableau * /* tableau */ ) const
211211
{
212212
// Reluplex does not currently work with Gurobi.
213213
ASSERT( _gurobi == NULL );
@@ -230,29 +230,28 @@ List<PhaseStatus> DisjunctionConstraint::getAllCases() const
230230

231231
PiecewiseLinearCaseSplit DisjunctionConstraint::getCaseSplit( PhaseStatus phase ) const
232232
{
233-
ASSERT ( phase != PHASE_NOT_FIXED );
234-
return _disjuncts.get( phaseStatusToInd( phase ) );
233+
ASSERT( phase != PHASE_NOT_FIXED );
234+
return _disjuncts.get( phaseStatusToInd( phase ) );
235235
}
236236

237237
PhaseStatus DisjunctionConstraint::getPhaseStatus() const
238238
{
239-
ASSERT ( phaseFixed() );
239+
ASSERT( phaseFixed() );
240240
return indToPhaseStatus( *_feasibleDisjuncts.begin() );
241241
}
242242

243243
PiecewiseLinearCaseSplit DisjunctionConstraint::getImpliedCaseSplit() const
244244
{
245-
ASSERT ( isImplication() );
246-
return _disjuncts.get( phaseStatusToInd ( getImpliedCase() ) );
245+
ASSERT( isImplication() );
246+
return _disjuncts.get( phaseStatusToInd( getImpliedCase() ) );
247247
}
248248

249249
PiecewiseLinearCaseSplit DisjunctionConstraint::getValidCaseSplit() const
250250
{
251251
return getImpliedCaseSplit();
252252
}
253253

254-
void DisjunctionConstraint::transformToUseAuxVariables( InputQuery
255-
&inputQuery )
254+
void DisjunctionConstraint::transformToUseAuxVariables( InputQuery &inputQuery )
256255
{
257256
Vector<PiecewiseLinearCaseSplit> newDisjuncts;
258257
for ( const auto &disjunct : _disjuncts )
@@ -390,39 +389,39 @@ bool DisjunctionConstraint::constraintObsolete() const
390389
return false; // A Disjunction is obsolete only when a literal is always true.
391390
}
392391

393-
void DisjunctionConstraint::getEntailedTightenings( List<Tightening> &/* tightenings */ ) const
392+
void DisjunctionConstraint::getEntailedTightenings( List<Tightening> & /* tightenings */ ) const
394393
{
395394
}
396395

397396
String DisjunctionConstraint::serializeToString() const
398397
{
399398
String s = "disj,";
400-
s += Stringf("%u,", _disjuncts.size());
399+
s += Stringf( "%u,", _disjuncts.size() );
401400
for ( const auto &disjunct : _disjuncts )
402401
{
403-
s += Stringf("%u,", disjunct.getBoundTightenings().size());
402+
s += Stringf( "%u,", disjunct.getBoundTightenings().size() );
404403
for ( const auto &bound : disjunct.getBoundTightenings() )
405404
{
406405
if ( bound._type == Tightening::LB )
407-
s += Stringf("l,%u,%f,", bound._variable, bound._value);
406+
s += Stringf( "l,%u,%f,", bound._variable, bound._value );
408407
else if ( bound._type == Tightening::UB )
409-
s += Stringf("u,%u,%f,", bound._variable, bound._value);
408+
s += Stringf( "u,%u,%f,", bound._variable, bound._value );
410409
}
411-
s += Stringf("%u,", disjunct.getEquations().size());
410+
s += Stringf( "%u,", disjunct.getEquations().size() );
412411
for ( const auto &equation : disjunct.getEquations() )
413412
{
414413
if ( equation._type == Equation::LE )
415-
s += Stringf("l,");
414+
s += Stringf( "l," );
416415
else if ( equation._type == Equation::GE )
417-
s += Stringf("g,");
416+
s += Stringf( "g," );
418417
else
419-
s += Stringf("e,");
420-
s += Stringf("%u,", equation._addends.size());
418+
s += Stringf( "e," );
419+
s += Stringf( "%u,", equation._addends.size() );
421420
for ( const auto &addend : equation._addends )
422421
{
423-
s += Stringf("%f,%u,", addend._coefficient, addend._variable);
422+
s += Stringf( "%f,%u,", addend._coefficient, addend._variable );
424423
}
425-
s += Stringf("%f,", equation._scalar );
424+
s += Stringf( "%f,", equation._scalar );
426425
}
427426
}
428427
return s;
@@ -495,7 +494,7 @@ void DisjunctionConstraint::updateFeasibleDisjuncts()
495494

496495
for ( unsigned ind = 0; ind < _disjuncts.size(); ++ind )
497496
{
498-
if ( caseSplitIsFeasible( _disjuncts.get( ind ) ) )
497+
if ( caseSplitIsFeasible( _disjuncts.get( ind ) ) )
499498
_feasibleDisjuncts.append( ind );
500499
}
501500
}

src/engine/DisjunctionConstraint.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@
3434
#ifndef __DisjunctionConstraint_h__
3535
#define __DisjunctionConstraint_h__
3636

37-
#include "Vector.h"
3837
#include "PiecewiseLinearConstraint.h"
38+
#include "Vector.h"
3939

4040
class DisjunctionConstraint : public PiecewiseLinearConstraint
4141
{
4242
public:
43-
~DisjunctionConstraint() {};
43+
~DisjunctionConstraint(){};
4444
DisjunctionConstraint( const List<PiecewiseLinearCaseSplit> &disjuncts );
4545
DisjunctionConstraint( const Vector<PiecewiseLinearCaseSplit> &disjuncts );
4646
DisjunctionConstraint( const String &serializedDisjunction );
@@ -154,7 +154,7 @@ class DisjunctionConstraint : public PiecewiseLinearConstraint
154154

155155
virtual bool supportVariableElimination() const override
156156
{
157-
return false;
157+
return false;
158158
}
159159

160160
/*
@@ -209,7 +209,7 @@ class DisjunctionConstraint : public PiecewiseLinearConstraint
209209
still feasible, given the current variable bounds
210210
*/
211211
void updateFeasibleDisjuncts();
212-
bool caseSplitIsFeasible( const PiecewiseLinearCaseSplit & caseSplit ) const;
212+
bool caseSplitIsFeasible( const PiecewiseLinearCaseSplit &caseSplit ) const;
213213

214214
inline PhaseStatus indToPhaseStatus( unsigned ind ) const
215215
{
@@ -218,7 +218,7 @@ class DisjunctionConstraint : public PiecewiseLinearConstraint
218218

219219
inline unsigned phaseStatusToInd( PhaseStatus phase ) const
220220
{
221-
//ASSERT( phase != PHASE_NOT_FIXED );
221+
// ASSERT( phase != PHASE_NOT_FIXED );
222222
return static_cast<unsigned>( phase ) - 1;
223223
}
224224
};

src/engine/MaxConstraint.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ void MaxConstraint::updateVariableIndex( unsigned oldIndex, unsigned newIndex )
503503
_auxToElement[auxVar] = newIndex;
504504

505505
if ( _phaseStatus == variableToPhase( oldIndex ) )
506-
_phaseStatus = variableToPhase( newIndex ) ;
506+
_phaseStatus = variableToPhase( newIndex );
507507
}
508508
else
509509
{
@@ -615,7 +615,7 @@ void MaxConstraint::getCostFunctionComponent( LinearExpression &cost,
615615
PhaseStatus phase ) const
616616
{
617617
// If the constraint is not active or is fixed, it contributes nothing
618-
if( !isActive() || phaseFixed() )
618+
if ( !isActive() || phaseFixed() )
619619
return;
620620

621621
if ( phase == MAX_PHASE_ELIMINATED )
@@ -669,7 +669,6 @@ String MaxConstraint::serializeToString() const
669669
// Will be ignored in any case
670670
output += Stringf( ",%u", 0 );
671671

672-
//serializeInfeasibleCases( output );
673672
return output;
674673
}
675674

src/engine/MaxConstraint.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
#ifndef __MaxConstraint_h__
4747
#define __MaxConstraint_h__
4848

49-
#include "PiecewiseLinearConstraint.h"
5049
#include "LinearExpression.h"
5150
#include "Map.h"
51+
#include "PiecewiseLinearConstraint.h"
5252

5353
#define MAX_VARIABLE_TO_PHASE_OFFSET 1
5454

0 commit comments

Comments
 (0)