@@ -134,33 +134,33 @@ public long Value(LinearExpr e)
134134 {
135135 switch ( expr )
136136 {
137- case LinearExprBuilder a :
138- constant += coefficient * a . Offset ;
139- if ( coefficient == 1 )
137+ case LinearExprBuilder a :
138+ constant += coefficient * a . Offset ;
139+ if ( coefficient == 1 )
140+ {
141+ foreach ( var sub in a . Terms )
140142 {
141- foreach ( var sub in a . Terms )
142- {
143- _terms . Enqueue ( sub ) ;
144- }
143+ _terms . Enqueue ( sub ) ;
145144 }
146- else
145+ }
146+ else
147+ {
148+ foreach ( var sub in a . Terms )
147149 {
148- foreach ( var sub in a . Terms )
149- {
150- _terms . Enqueue ( new Term ( sub . expr , sub . coefficient * coefficient ) ) ;
151- }
150+ _terms . Enqueue ( new Term ( sub . expr , sub . coefficient * coefficient ) ) ;
152151 }
152+ }
153153
154- break ;
155- case IntVar intVar :
156- var index = intVar . GetIndex ( ) ;
157- var value = index >= 0 ? Response ! . Solution [ index ] : - Response ! . Solution [ - index - 1 ] ;
158- constant += coefficient * value ;
159- break ;
160- case NotBoolVar :
161- throw new ArgumentException ( "Cannot evaluate a literal in an integer expression." ) ;
162- default :
163- throw new ArgumentException ( "Cannot evaluate '" + expr + "' in an integer expression" ) ;
154+ break ;
155+ case IntVar intVar :
156+ var index = intVar . GetIndex ( ) ;
157+ var value = index >= 0 ? Response ! . Solution [ index ] : - Response ! . Solution [ - index - 1 ] ;
158+ constant += coefficient * value ;
159+ break ;
160+ case NotBoolVar :
161+ throw new ArgumentException ( "Cannot evaluate a literal in an integer expression." ) ;
162+ default :
163+ throw new ArgumentException ( "Cannot evaluate '" + expr + "' in an integer expression" ) ;
164164 }
165165
166166 if ( ! _terms . TryDequeue ( out var term ) )
@@ -170,8 +170,7 @@ public long Value(LinearExpr e)
170170
171171 expr = term . expr ;
172172 coefficient = term . coefficient ;
173- }
174- while ( true ) ;
173+ } while ( true ) ;
175174
176175 return constant ;
177176 }
@@ -250,7 +249,6 @@ class BestBoundCallbackDelegate : BestBoundCallback
250249 public BestBoundCallbackDelegate ( DoubleToVoidDelegate del ) => _delegate = del ;
251250
252251 public override void NewBestBound ( double bound ) => _delegate ( bound ) ;
253-
254252}
255253
256254} // namespace Google.OrTools.Sat
0 commit comments