File tree 1 file changed +12
-4
lines changed
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -280,10 +280,6 @@ def set_objective(self, objective: LPExpressionLike) -> None:
280
280
self .objective = LPExpression .build (objective )
281
281
282
282
def solve (self ) -> None :
283
- if self .has_impossible_constraints :
284
- self .status = LPStatus .INFEASIBLE
285
- return
286
-
287
283
var_dict : dict [int , LPVar ] = {}
288
284
for constraint in self .constraints :
289
285
for term in constraint .lhs .terms :
@@ -292,6 +288,18 @@ def solve(self) -> None:
292
288
for term in self .objective .terms :
293
289
var_dict .setdefault (id (term .variable ), term .variable )
294
290
291
+ # Reset status
292
+ self .objective ._value = None
293
+ self .status = None
294
+ for var in var_dict .values ():
295
+ var ._value = None
296
+
297
+ # Obviously infeasible
298
+ if self .has_impossible_constraints :
299
+ self .status = LPStatus .INFEASIBLE
300
+ return
301
+
302
+ # Obviously optimal
295
303
if not var_dict :
296
304
self .status = LPStatus .OPTIMAL
297
305
self .objective ._value = self .objective .const
You can’t perform that action at this time.
0 commit comments