Author: varioustoxins Date: Thu Mar 29 21:47:17 2007 New Revision: 3248 URL: http://svn.gna.org/viewcvs/relax?rev=3248&view=rev Log: more modifications to remove accidental dependances on mpi4py in uni_processor creation of command module Added: branches/multi_processor/multi/commands.py Modified: branches/multi_processor/multi/mpi4py_processor.py branches/multi_processor/multi/processor.py branches/multi_processor/specific_fns/model_free.py Added: branches/multi_processor/multi/commands.py URL: http://svn.gna.org/viewcvs/relax/branches/multi_processor/multi/commands.py?rev=3248&view=auto ============================================================================== --- branches/multi_processor/multi/commands.py (added) +++ branches/multi_processor/multi/commands.py Thu Mar 29 21:47:17 2007 @@ -1,0 +1,109 @@ + +from multi.processor import Memo,Slave_command +from multi.processor import Result_command,Result_string,NULL_RESULT + +from maths_fns.mf import Mf +from minimise.generic import generic_minimise + +class Exit_command(Slave_command): + def __init__(self): + super(Exit_command,self).__init__() + + def run(self,processor): + processor.return_object(NULL_RESULT) + processor.do_quit=True + + + +class Get_name_command(Slave_command): + def __init__(self): + super(Exit_command,self).__init__() + + def run(self,processor): + msg = processor.get_name() + result = Result_string(msg,True) + processor.return_object(result) + +#not quit a momento so a memo +class MF_completion_memo(Memo): + def __init__(self,model_free,index,sim_index,run,param_set,scaling): + self.index = index + self.sim_index=sim_index + self.run=run + self.param_set=param_set + self.model_free=model_free + self.scaling=scaling + + +class MF_completion_command(Result_command): + def __init__(self,memo_id,param_vector, func, iter, fc, gc, hc, warning): + super(MF_completion_command,self).__init__(completed=True,memo_id=memo_id) + self.memo_id=memo_id + self.param_vector=param_vector + self.func=func + self.iter=iter + self.fc=fc + self.gc=gc + self.hc=hc + self.warning=warning + + def run(self,relax,processor,memo): + m_f=memo.model_free + m_f.iter_count = 0 + m_f.f_count = 0 + m_f.g_count = 0 + m_f.h_count = 0 + m_f.disassemble_result(param_vector=self.param_vector,func=self.func,iter=self.iter,fc=self.fc, + gc=self.gc,hc=self.hc, warning=self.warning, + run=memo.run, index=memo.index,sim_index=memo.sim_index, + param_set=memo.param_set,scaling=memo.scaling) + + +class MF_minimise_command(Slave_command): + def __init__(self): + super(MF_minimise_command,self).__init__() + + + #!! 'a0':1.0,'mu':0.0001,'eta':0.1, + self.minimise_map={'args':(), 'x0':None, 'min_algor':None, 'min_options':None, 'func_tol':1e-25, 'grad_tol':None, + 'maxiter':1e6, 'A':None, 'b':'None', 'l':None, 'u':None, 'c':None, 'dc':None, 'd2c':None, + 'dc':None, 'd2c':None, 'full_output':0, 'print_flag':0, + 'print_prefix':""} + + + + self.mf_map={'init_params':None, 'param_set':None, 'diff_type':None, 'diff_params':None, + 'scaling_matrix':None, 'num_res':None, 'equations':None, 'param_types':None, + 'param_values':None, 'relax_data':None, 'errors':None, 'bond_length':None, + 'csa':None, 'num_frq':0, 'frq':None, 'num_ri':None, 'remap_table':None, 'noe_r1_table':None, + 'ri_labels':None, 'gx':0, 'gh':0, 'g_ratio':0, 'h_bar':0, 'mu0':0, 'num_params':None, 'vectors':None} + + + #FIXME: bad names + def set_mf(self, **kwargs): + self.mf_map.update(**kwargs) + + + def set_minimise(self,**kwargs): + self.minimise_map.update(**kwargs) + + def build_mf(self): + return Mf(**self.mf_map) + + def do_minimise(self,memo): + self.mf = self.build_mf() + results = generic_minimise(func=self.mf.func, dfunc=self.mf.dfunc, d2func=self.mf.d2func, **self.minimise_map) + + m_f=memo.model_free + param_vector, func, iter, fc, gc, hc, warning = results + m_f.disassemble_result(param_vector=param_vector,func=func,iter=iter,fc=fc, + gc=gc,hc=hc, warning=warning, + run=memo.run, index=memo.index,sim_index=memo.sim_index, + param_set=memo.param_set,scaling=memo.scaling) + def run(self,processor): + self.mf = self.build_mf() + results = generic_minimise(func=self.mf.func, dfunc=self.mf.dfunc, d2func=self.mf.d2func, **self.minimise_map) + param_vector, func, iter, fc, gc, hc, warning = results + + processor.return_object(MF_completion_command(self.memo_id,param_vector, func, iter, fc, gc, hc, warning)) + Modified: branches/multi_processor/multi/mpi4py_processor.py URL: http://svn.gna.org/viewcvs/relax/branches/multi_processor/multi/mpi4py_processor.py?rev=3248&r1=3247&r2=3248&view=diff ============================================================================== --- branches/multi_processor/multi/mpi4py_processor.py (original) +++ branches/multi_processor/multi/mpi4py_processor.py Thu Mar 29 21:47:17 2007 @@ -7,16 +7,17 @@ import time,datetime from multi.processor import Memo,Slave_command -from multi.processor import Result_command,Result_string +from multi.processor import Result,Result_command,Result_string +from multi.commands import Exit_command #FIXME: me move top generic command module -from maths_fns.mf import Mf -from minimise.generic import generic_minimise + # load mpi try: from mpi4py import MPI except ImportError: + raise Exception('test') sys.stderr.write("The dependency 'mpi4py' has not been installed.\n") sys.exit() @@ -58,88 +59,6 @@ -#not quit a momento so a memo -class MF_completion_memo(Memo): - def __init__(self,model_free,index,sim_index,run,param_set,scaling): - self.index = index - self.sim_index=sim_index - self.run=run - self.param_set=param_set - self.model_free=model_free - self.scaling=scaling - - -class MF_completion_command(Result_command): - def __init__(self,memo_id,param_vector, func, iter, fc, gc, hc, warning): - super(MF_completion_command,self).__init__(True,memo_id=memo_id) - self.memo_id=memo_id - self.param_vector=param_vector - self.func=func - self.iter=iter - self.fc=fc - self.gc=gc - self.hc=hc - self.warning=warning - - def run(self,relax,processor,memo): - m_f=memo.model_free - m_f.iter_count = 0 - m_f.f_count = 0 - m_f.g_count = 0 - m_f.h_count = 0 - m_f.disassemble_result(param_vector=self.param_vector,func=self.func,iter=self.iter,fc=self.fc, - gc=self.gc,hc=self.hc, warning=self.warning, - run=memo.run, index=memo.index,sim_index=memo.sim_index, - param_set=memo.param_set,scaling=memo.scaling) - - -class MF_minimise_command(Slave_command): - def __init__(self): - super(MF_minimise_command,self).__init__() - - - #!! 'a0':1.0,'mu':0.0001,'eta':0.1, - self.minimise_map={'args':(), 'x0':None, 'min_algor':None, 'min_options':None, 'func_tol':1e-25, 'grad_tol':None, - 'maxiter':1e6, 'A':None, 'b':'None', 'l':None, 'u':None, 'c':None, 'dc':None, 'd2c':None, - 'dc':None, 'd2c':None, 'full_output':0, 'print_flag':0, - 'print_prefix':""} - - - - self.mf_map={'init_params':None, 'param_set':None, 'diff_type':None, 'diff_params':None, - 'scaling_matrix':None, 'num_res':None, 'equations':None, 'param_types':None, - 'param_values':None, 'relax_data':None, 'errors':None, 'bond_length':None, - 'csa':None, 'num_frq':0, 'frq':None, 'num_ri':None, 'remap_table':None, 'noe_r1_table':None, - 'ri_labels':None, 'gx':0, 'gh':0, 'g_ratio':0, 'h_bar':0, 'mu0':0, 'num_params':None, 'vectors':None} - - - #FIXME: bad names - def set_mf(self, **kwargs): - self.mf_map.update(**kwargs) - - - def set_minimise(self,**kwargs): - self.minimise_map.update(**kwargs) - - def build_mf(self): - return Mf(**self.mf_map) - - def do_minimise(self,memo): - self.mf = self.build_mf() - results = generic_minimise(func=self.mf.func, dfunc=self.mf.dfunc, d2func=self.mf.d2func, **self.minimise_map) - - m_f=memo.model_free - param_vector, func, iter, fc, gc, hc, warning = results - m_f.disassemble_result(param_vector=param_vector,func=func,iter=iter,fc=fc, - gc=gc,hc=hc, warning=warning, - run=memo.run, index=memo.index,sim_index=memo.sim_index, - param_set=memo.param_set,scaling=memo.scaling) - def run(self,processor): - self.mf = self.build_mf() - results = generic_minimise(func=self.mf.func, dfunc=self.mf.dfunc, d2func=self.mf.d2func, **self.minimise_map) - param_vector, func, iter, fc, gc, hc, warning = results - - processor.return_object(MF_completion_command(self.memo_id,param_vector, func, iter, fc, gc, hc, warning)) #FIXME do some inheritance class Mpi4py_processor: Modified: branches/multi_processor/multi/processor.py URL: http://svn.gna.org/viewcvs/relax/branches/multi_processor/multi/processor.py?rev=3248&r1=3247&r2=3248&view=diff ============================================================================== --- branches/multi_processor/multi/processor.py (original) +++ branches/multi_processor/multi/processor.py Thu Mar 29 21:47:17 2007 @@ -1,19 +1,18 @@ class Result(object): - def __init__(self): - pass + def __init__(self,completed): + self.completed=completed class Result_string(Result): #FIXME move result up a level def __init__(self,string,completed): - super(Result_string,self).__init__() + super(Result_string,self).__init__(completed=completed) self.string=string - self.completed=completed + class Result_command(Result): def __init__(self,completed,memo_id=None): - super(Result_command,self).__init__() - self.completed=completed + super(Result_command,self).__init__(completed=completed) self.memo_id=memo_id def run(self,relax,processor,memo): @@ -41,24 +40,6 @@ #FIXME do some inheritance -class Exit_command(Slave_command): - def __init__(self): - super(Exit_command,self).__init__() - - def run(self,processor): - processor.return_object(NULL_RESULT) - processor.do_quit=True - - - -class Get_name_command(Slave_command): - def __init__(self): - super(Exit_command,self).__init__() - - def run(self,processor): - msg = processor.get_name() - result = Result_string(msg,True) - processor.return_object(result) class Memo(object): def memo_id(self): Modified: branches/multi_processor/specific_fns/model_free.py URL: http://svn.gna.org/viewcvs/relax/branches/multi_processor/specific_fns/model_free.py?rev=3248&r1=3247&r2=3248&view=diff ============================================================================== --- branches/multi_processor/specific_fns/model_free.py (original) +++ branches/multi_processor/specific_fns/model_free.py Thu Mar 29 21:47:17 2007 @@ -35,7 +35,7 @@ from maths_fns.mf import Mf from minimise.generic import generic_minimise from float import isNaN,isInf -from multi.mpi4py_processor import MF_minimise_command,MF_completion_memo +from multi.commands import MF_minimise_command,MF_completion_memo class Model_free(Common_functions):