diff options
author | Edoardo Pasca <edo.paskino@gmail.com> | 2019-05-23 16:20:08 +0100 |
---|---|---|
committer | Edoardo Pasca <edo.paskino@gmail.com> | 2019-05-23 16:20:08 +0100 |
commit | 31410bc217c7de4659e5df35f3423fdbbd04f59a (patch) | |
tree | 0334cad6c7a566ac3221e928af31fcd9a269eff3 | |
parent | 6794aaaa388f622cc8cd18c56c7345dca016163b (diff) | |
download | framework-31410bc217c7de4659e5df35f3423fdbbd04f59a.tar.gz framework-31410bc217c7de4659e5df35f3423fdbbd04f59a.tar.bz2 framework-31410bc217c7de4659e5df35f3423fdbbd04f59a.tar.xz framework-31410bc217c7de4659e5df35f3423fdbbd04f59a.zip |
updated print
-rwxr-xr-x | Wrappers/Python/ccpi/optimisation/algorithms/Algorithm.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/Wrappers/Python/ccpi/optimisation/algorithms/Algorithm.py b/Wrappers/Python/ccpi/optimisation/algorithms/Algorithm.py index 0778838..78fe196 100755 --- a/Wrappers/Python/ccpi/optimisation/algorithms/Algorithm.py +++ b/Wrappers/Python/ccpi/optimisation/algorithms/Algorithm.py @@ -147,10 +147,9 @@ class Algorithm(object): if self.should_stop(): print ("Stop cryterion has been reached.") i = 0 - - if verbose: - print (self.verbose_header()) for _ in self: + if i == 0 and verbose: + print (self.verbose_header()) if (self.iteration -1) % self.update_objective_interval == 0: if verbose: #print ("Iteration {:>7} max: {:>7}, = {}".format(self.iteration-1, @@ -178,7 +177,7 @@ class Algorithm(object): return out def objective_to_string(self): - el = self.get_last_objective()[0] + el = self.get_last_objective() if type(el) == list: string = functools.reduce(lambda x,y: x+' {:>13.5e}'.format(y), el[:-1],'') string += '{:>15.5e}'.format(el[-1]) @@ -186,7 +185,7 @@ class Algorithm(object): string = "{:>20.5e}".format(el) return string def verbose_header(self): - el = 1 + el = self.get_last_objective() if type(el) == list: out = "{:>9} {:>10} {:>13} {:>13} {:>13} {:>15}\n".format('Iter', 'Max Iter', @@ -197,7 +196,7 @@ class Algorithm(object): '[s]', 'Objective' , 'Objective', 'Gap') else: - out = "{:>9} {:>10} {:>13} {:>20}".format('Iter', + out = "{:>9} {:>10} {:>13} {:>20}\n".format('Iter', 'Max Iter', 'Time/Iter', 'Objective') |