8888 ):
8989 libfile = os .path .join (_lib_dir , "libCbc.dylib" )
9090 else :
91- raise NotImplementedError (
92- "Your operating system/platform is not supported"
93- )
91+ raise NotImplementedError ("Your operating system/platform is not supported" )
9492 cbclib = ffi .dlopen (libfile )
9593 has_cbc = True
9694except Exception as e :
9795 logger .error ("An error occurred while loading the CBC library:\t " "{}\n " .format (e ))
9896 has_cbc = False
9997
10098if has_cbc :
101- ffi .cdef (
102- """
99+ ffi .cdef ("""
103100 typedef int(*cbc_progress_callback)(void *model,
104101 int phase,
105102 int step,
546543 const char *Cbc_featureName(int i);
547544
548545 void Cbc_reset(Cbc_Model *model);
549- """
550- )
546+ """ )
551547
552548CHAR_ONE = "{}" .format (chr (1 )).encode ("utf-8" )
553549CHAR_ZERO = "\0 " .encode ("utf-8" )
@@ -1008,12 +1004,10 @@ def cbc_get_osi_name_indexes(osi_solver) -> Dict[str, int]:
10081004 return nameIdx
10091005
10101006 # progress callback
1011- @ffi .callback (
1012- """
1007+ @ffi .callback ("""
10131008 int (void *, int, int, const char *, double, double, double,
10141009 int, int *, void *)
1015- """
1016- )
1010+ """ )
10171011 def cbc_progress_callback (
10181012 model ,
10191013 phase : int ,
@@ -1036,11 +1030,9 @@ def cbc_inc_callback(
10361030 return
10371031
10381032 # cut callback
1039- @ffi .callback (
1040- """
1033+ @ffi .callback ("""
10411034 void (void *osi_solver, void *osi_cuts, void *app_data, int level, int npass)
1042- """
1043- )
1035+ """ )
10441036 def cbc_cut_callback (osi_solver , osi_cuts , app_data , depth , npass ):
10451037 if (
10461038 osi_solver == ffi .NULL
@@ -1452,10 +1444,8 @@ def write(self, file_path: str):
14521444 elif ".bas" in file_path .lower ():
14531445 cbclib .Cbc_writeBasis (self ._model , fpstr , CHAR_ONE , 2 )
14541446 else :
1455- raise ValueError (
1456- "Enter a valid extension (.lp, .mps or .bas) \
1457- to indicate the file format"
1458- )
1447+ raise ValueError ("Enter a valid extension (.lp, .mps or .bas) \
1448+ to indicate the file format" )
14591449
14601450 def read (self , file_path : str ) -> None :
14611451 if not isfile (file_path ):
@@ -1484,10 +1474,8 @@ def read(self, file_path: str) -> None:
14841474 logger .info ("Optimal LP basis successfully loaded." )
14851475
14861476 else :
1487- raise ValueError (
1488- "Enter a valid extension (.lp, .mps or .bas) \
1489- to indicate the file format"
1490- )
1477+ raise ValueError ("Enter a valid extension (.lp, .mps or .bas) \
1478+ to indicate the file format" )
14911479
14921480 def set_start (self , start : List [Tuple [Var , numbers .Real ]]) -> None :
14931481 # Augment start list with default zero values for absent non-continuous variables
@@ -1778,7 +1766,9 @@ def add_var(
17781766 numnz = len (column .constrs )
17791767
17801768 isInt = (
1781- CHAR_ONE if var_type .upper () == "B" or var_type .upper () == "I" else CHAR_ZERO
1769+ CHAR_ONE
1770+ if var_type .upper () == "B" or var_type .upper () == "I"
1771+ else CHAR_ZERO
17821772 )
17831773 cbclib .Osi_addCol (
17841774 self .osi ,
0 commit comments