@@ -15,31 +15,24 @@ class GapEventhdlr(Eventhdlr):
1515
1616 def eventinit (self ): # we want to collect best primal solutions and best dual solutions
1717 self .model .catchEvent (SCIP_EVENTTYPE .BESTSOLFOUND , self )
18- self .model .catchEvent (SCIP_EVENTTYPE .LPSOLVED , self )
19- self .model .catchEvent (SCIP_EVENTTYPE .NODESOLVED , self )
20-
18+ self .model .catchEvent (SCIP_EVENTTYPE .DUALBOUNDIMPROVED , self )
2119
2220 def eventexec (self , event ):
2321 # if a new best primal solution was found, we save when it was found and also its objective
2422 if event .getType () == SCIP_EVENTTYPE .BESTSOLFOUND :
2523 self .model .data ["primal_log" ].append ([self .model .getSolvingTime (), self .model .getPrimalbound ()])
2624
27- if not self .model .data ["dual_log" ]:
28- self .model .data ["dual_log" ].append ([self .model .getSolvingTime (), self .model .getDualbound ()])
29-
30- if self .model .getObjectiveSense () == "minimize" :
31- if self .model .isGT (self .model .getDualbound (), self .model .data ["dual_log" ][- 1 ][1 ]):
32- self .model .data ["dual_log" ].append ([self .model .getSolvingTime (), self .model .getDualbound ()])
33- else :
34- if self .model .isLT (self .model .getDualbound (), self .model .data ["dual_log" ][- 1 ][1 ]):
35- self .model .data ["dual_log" ].append ([self .model .getSolvingTime (), self .model .getDualbound ()])
36-
25+ if event .getType () == SCIP_EVENTTYPE .DUALBOUNDIMPROVED :
26+ self .model .data ["dual_log" ].append ([self .model .getSolvingTime (), self .model .getDualbound ()])
3727
3828 if not hasattr (model , "data" ) or model .data == None :
3929 model .data = {}
4030
41- model .data ["primal_log" ] = []
42- model .data ["dual_log" ] = []
31+ model .data .update ({
32+ 'primal_log' : [],
33+ 'dual_log' : []
34+ })
35+
4336 hdlr = GapEventhdlr ()
4437 model .includeEventhdlr (hdlr , "gapEventHandler" , "Event handler which collects primal and dual solution evolution" )
4538
0 commit comments