From b7f2d81041ddd3957ac59fa627f10928c978da4f Mon Sep 17 00:00:00 2001 From: Edoardo Pasca Date: Thu, 9 May 2019 11:03:18 +0100 Subject: added NOTICE.txt --- NOTICE.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 NOTICE.txt diff --git a/NOTICE.txt b/NOTICE.txt new file mode 100644 index 0000000..30a4a3e --- /dev/null +++ b/NOTICE.txt @@ -0,0 +1,15 @@ +CCPi Core Imaging Library. +Copyright 2017 Rutherford Appleton Laboratory STFC +Copyright 2017 University of Manchester + +This software product is developed for the Collaborative Computational +Project in Tomographic Imaging CCPi (http://www.ccpi.ac.uk/) at RAL STFC (http://www.stfc.ac.uk), University of Manchester (http://www.ucl.ac.uk/) +and other contributing institutions. + +Main contributors: +Edoardo Pasca (STFC) +Jakob Jorgensen (UoM) +Evangelos Papoutsellis (UoM) +Evelina Ametova (UoM) +Daniil Kazantsev (Diamond Light Source) +Gemma Fardell (STFC) -- cgit v1.2.3 From a602fcf4b0012576c17db5ddcc6ada1b27daf1ce Mon Sep 17 00:00:00 2001 From: Edoardo Pasca Date: Thu, 9 May 2019 11:09:34 +0100 Subject: updated notice --- NOTICE.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index 30a4a3e..5b03e0d 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -1,9 +1,9 @@ -CCPi Core Imaging Library. +CCPi Core Imaging Library (CIL). Copyright 2017 Rutherford Appleton Laboratory STFC Copyright 2017 University of Manchester This software product is developed for the Collaborative Computational -Project in Tomographic Imaging CCPi (http://www.ccpi.ac.uk/) at RAL STFC (http://www.stfc.ac.uk), University of Manchester (http://www.ucl.ac.uk/) +Project in Tomographic Imaging CCPi (http://www.ccpi.ac.uk/) at RAL STFC (http://www.stfc.ac.uk), University of Manchester and other contributing institutions. Main contributors: -- cgit v1.2.3 From e89324626a5ed650d42914aa5ac98e50ca04a28b Mon Sep 17 00:00:00 2001 From: Edoardo Pasca Date: Fri, 10 May 2019 16:28:14 +0100 Subject: add contributors in alphabetical order --- NOTICE.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index 5b03e0d..c107329 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -6,10 +6,10 @@ This software product is developed for the Collaborative Computational Project in Tomographic Imaging CCPi (http://www.ccpi.ac.uk/) at RAL STFC (http://www.stfc.ac.uk), University of Manchester and other contributing institutions. -Main contributors: -Edoardo Pasca (STFC) -Jakob Jorgensen (UoM) -Evangelos Papoutsellis (UoM) +Main contributors in alphabetical order: Evelina Ametova (UoM) +Jakob Jorgensen (UoM) Daniil Kazantsev (Diamond Light Source) -Gemma Fardell (STFC) +Srikanth Nagella (STFC) +Edoardo Pasca (STFC) +Evangelos Papoutsellis (UoM) -- cgit v1.2.3 From 2f5560fe65b8588685403b9a29caf46b6ee44c14 Mon Sep 17 00:00:00 2001 From: Edoardo Pasca Date: Wed, 22 May 2019 16:54:41 +0100 Subject: verbose to tabulate the output --- .../ccpi/optimisation/algorithms/Algorithm.py | 46 +++++++++++++++++----- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/Wrappers/Python/ccpi/optimisation/algorithms/Algorithm.py b/Wrappers/Python/ccpi/optimisation/algorithms/Algorithm.py index ed95c3f..e119a1c 100755 --- a/Wrappers/Python/ccpi/optimisation/algorithms/Algorithm.py +++ b/Wrappers/Python/ccpi/optimisation/algorithms/Algorithm.py @@ -16,7 +16,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -import time +import time, functools from numbers import Integral class Algorithm(object): @@ -34,7 +34,7 @@ class Algorithm(object): method will stop when the stopping cryterion is met. ''' - def __init__(self): + def __init__(self, **kwargs): '''Constructor Set the minimal number of parameters: @@ -48,11 +48,11 @@ class Algorithm(object): when evaluating the objective is computationally expensive. ''' self.iteration = 0 - self.__max_iteration = 0 + self.__max_iteration = kwargs.get('max_iteration', 0) self.__loss = [] self.memopt = False self.timing = [] - self.update_objective_interval = 1 + self.update_objective_interval = kwargs.get('update_objective_interval', 1) def set_up(self, *args, **kwargs): '''Set up the algorithm''' raise NotImplementedError() @@ -91,9 +91,11 @@ class Algorithm(object): if self.iteration % self.update_objective_interval == 0: self.update_objective() self.iteration += 1 + def get_output(self): '''Returns the solution found''' return self.x + def get_last_loss(self): '''Returns the last stored value of the loss function @@ -145,14 +147,38 @@ class Algorithm(object): if self.should_stop(): print ("Stop cryterion has been reached.") i = 0 + + if verbose: + print ("{:>9} {:>10} {:>11} {:>20}".format('Iter', + 'Max Iter', + 's/Iter', + 'Objective Value')) for _ in self: - if verbose and self.iteration % self.update_objective_interval == 0: - print ("Iteration {}/{}, objective {}".format(self.iteration, - self.max_iteration, self.get_last_objective()) ) - else: + if (self.iteration -1) % self.update_objective_interval == 0: + if verbose: + #print ("Iteration {:>7} max: {:>7}, = {}".format(self.iteration-1, + # self.max_iteration, self.get_last_objective()) ) + print (self.verbose_output()) if callback is not None: - callback(self.iteration, self.get_last_objective()) + callback(self.iteration -1, self.get_last_objective(), self.x) i += 1 if i == iterations: break - + def verbose_output(self): + '''Creates a nice tabulated output''' + timing = self.timing[-self.update_objective_interval-1:-1] + if len (timing) == 0: + t = 0 + else: + t = sum(timing)/len(timing) + el = [ self.iteration-1, + self.max_iteration, + "{:.3f} s/it".format(t), + self.get_last_objective() ] + + if type(el[-1] ) == list: + string = functools.reduce(lambda x,y: x+' {:>15.5e}'.format(y), el[-1],'') + out = "{:>9} {:>10} {:>11} {}".format(*el[:-1] , string) + else: + out = "{:>9} {:>10} {:>11} {:>20.5e}".format(*el) + return out -- cgit v1.2.3