pKaTool/CCPS_stab_opt.py
def optimise_system(self):
        """Optimise the system according to the values given by the user"""
        #
        # Did the bozo choose the CCPS?
        #
        self.find_chosen_CCPS()
        if self.get_CCPSs()==[]:
            import tkMessageBox
            tkMessageBox.showwarning('No CCPS selected',
                                     'You have to chose the CCPS from the microscopic states',
                                     parent=self.optwin)
            return
        #
        # Find the properties we will use
        #
        self.active_properties=[]
        props=self.properties.keys()
        for prop in props:
            if self.properties[prop]['include']['var'].get()==1:
                self.active_properties.append(prop)
        #
        print 'I am optimising these properties:',self.active_properties
 
        #
        # Get the variables
        #
        self.intpkas=[]
        self.intenes=[]
        for group in self.groups:
            self.intpkas.append(self.groups[group].intpka)
            for group2 in self.groups[group].intenes.keys():
                self.intenes.append(self.groups[group].intenes[group2])
        #
        # Perform all variations within the limits
        #
        self.intpka_limit=self.properties['individual intpKa shift']['cutoff']['var'].get()
        self.intene_limit=self.properties['individual intene']['cutoff']['var'].get()
        print 'Intpka limit: %5.3f' %self.intpka_limit
        print 'intene limit: %5.3f' %self.intene_limit
        #
        # Make copies of all the variables
        #
        self.vars=[]
        for group in self.groups:
            self.vars.append([self.groups[group].intpka,'intpka',group])
            for group2 in self.groups[group].intenes.keys():
                self.vars.append([self.groups[group].intenes[group2],'intene',group])
        #
        # Set damper
        #
        self.LM_damper = 0.1
        #
        # Update the counter
        #
        self.count=0
        self.keep_running_opt=1
        #
        # Init vars for the scoring function
        #
        self.CCPS_pH_vals=None
        self.CCPSmax_pH_vals=None
        self.Stability_pH_vals=None
        #
        # Start off the iterations
        #
        scores=self.get_system_score().values()
        old_diff=10000.0
        now_diff=0.0
        for val in self.get_system_score().values():
            now_diff=now_diff+val
        min_steps=100
        for x in range(1,10000):
            self.fit_LM_optimise()
            #
            # Update the counter, the scales and the titration curves
            #
            self.status.set("Optimisation running. Step %5d" %self.count)
            self.count=self.count+1
            self.window.update()
            self.optwin.update()

            #self.optwin.update_idletasks()
            self.update_scales_from_fit()
            self.titwin.update() # This statement is essential for propagating changes in variable values
            #
            #
            # recalculate the differences
            #
            now_diff=0.0
            for val in self.get_system_score().values():
                now_diff=now_diff+val
            #
            # Check convergence
            #
            if abs(now_diff-old_diff)<0.000005 and x>min_steps:
                print 'Converged',now_diff
                break
            else:
                old_diff=now_diff
            #
            # Should we stop?
            #
            if self.keep_running_opt==0:
                print 'User abort'
                break
        self.update_pkasystem_curves()
        return
Optimise the system according to the values given by the user
Optimise the system according to the values given by the user
Optimise the system according to the values given by the user
def optimise_system(self):
         Did the bozo choose the CCPS?
        self.find_chosen_CCPS()
        if self.get_CCPSs()==[]:
            import tkMessageBox
            tkMessageBox.showwarning('No CCPS selected',
                                     'You have to chose the CCPS from the microscopic states',
                                     parent=self.optwin)
            return
         Find the properties we will use
        self.active_properties=[]
        props=self.properties.keys()
        for prop in props:
            if self.properties[prop]['include']['var'].get()==1:
                self.active_properties.append(prop)
        print 'I am optimising these properties:',self.active_properties
         Get the variables
        self.intpkas=[]
        self.intenes=[]
        for group in self.groups:
            self.intpkas.append(self.groups[group].intpka)
            for group2 in self.groups[group].intenes.keys():
                self.intenes.append(self.groups[group].intenes[group2])
         Perform all variations within the limits
        self.intpka_limit=self.properties['individual intpKa shift']['cutoff']['var'].get()
        self.intene_limit=self.properties['individual intene']['cutoff']['var'].get()
        print 'Intpka limit: %5.3f' %self.intpka_limit
        print 'intene limit: %5.3f' %self.intene_limit
         Make copies of all the variables
        self.vars=[]
        for group in self.groups:
            self.vars.append([self.groups[group].intpka,'intpka',group])
            for group2 in self.groups[group].intenes.keys():
                self.vars.append([self.groups[group].intenes[group2],'intene',group])
         Set damper
        self.LM_damper = 0.1
         Update the counter
        self.count=0
        self.keep_running_opt=1
         Init vars for the scoring function
        self.CCPS_pH_vals=None
        self.CCPSmax_pH_vals=None
        self.Stability_pH_vals=None
         Start off the iterations
        scores=self.get_system_score().values()
        old_diff=10000.0
        now_diff=0.0
        for val in self.get_system_score().values():
            now_diff=now_diff+val
        min_steps=100
        for x in range(1,10000):
            self.fit_LM_optimise()
             Update the counter, the scales and the titration curves
            self.status.set("Optimisation running. Step %5d" %self.count)
            self.count=self.count+1
            self.window.update()
            self.optwin.update()
            self.optwin.update_idletasks()
            self.update_scales_from_fit()
            self.titwin.update()  This statement is essential for propagating changes in variable values
             recalculate the differences
            now_diff=0.0
            for val in self.get_system_score().values():
                now_diff=now_diff+val
             Check convergence
            if abs(now_diff-old_diff)<0.000005 and x>min_steps:
                print 'Converged',now_diff
                break
            else:
                old_diff=now_diff
             Should we stop?
            if self.keep_running_opt==0:
                print 'User abort'
                break
        self.update_pkasystem_curves()
        return
def optimise_system ( self ) : self . find_chosen_CCPS ( ) if self . get_CCPSs ( ) == [ ] : import tkMessageBox tkMessageBox . showwarning ( 'No CCPS selected' , 'You have to chose the CCPS from the microscopic states' , parent = self . optwin ) return self . active_properties = [ ] props = self . properties . keys ( ) for prop in props : if self . properties [ prop ] [ 'include' ] [ 'var' ] . get ( ) == 1 : self . active_properties . append ( prop ) print 'I am optimising these properties:' , self . active_properties self . intpkas = [ ] self . intenes = [ ] for group in self . groups : self . intpkas . append ( self . groups [ group ] . intpka ) for group2 in self . groups [ group ] . intenes . keys ( ) : self . intenes . append ( self . groups [ group ] . intenes [ group2 ] ) self . intpka_limit = self . properties [ 'individual intpKa shift' ] [ 'cutoff' ] [ 'var' ] . get ( ) self . intene_limit = self . properties [ 'individual intene' ] [ 'cutoff' ] [ 'var' ] . get ( ) print 'Intpka limit: %5.3f' % self . intpka_limit print 'intene limit: %5.3f' % self . intene_limit self . vars = [ ] for group in self . groups : self . vars . append ( [ self . groups [ group ] . intpka , 'intpka' , group ] ) for group2 in self . groups [ group ] . intenes . keys ( ) : self . vars . append ( [ self . groups [ group ] . intenes [ group2 ] , 'intene' , group ] ) self . LM_damper = 0.1 self . count = 0 self . keep_running_opt = 1 self . CCPS_pH_vals = None self . CCPSmax_pH_vals = None self . Stability_pH_vals = None scores = self . get_system_score ( ) . values ( ) old_diff = 10000.0 now_diff = 0.0 for val in self . get_system_score ( ) . values ( ) : now_diff = now_diff + val min_steps = 100 for x in range ( 1 , 10000 ) : self . fit_LM_optimise ( ) self . status . set ( "Optimisation running. Step %5d" % self . count ) self . count = self . count + 1 self . window . update ( ) self . optwin . update ( ) self . update_scales_from_fit ( ) self . titwin . update ( ) now_diff = 0.0 for val in self . get_system_score ( ) . values ( ) : now_diff = now_diff + val if abs ( now_diff - old_diff ) < 0.000005 and x > min_steps : print 'Converged' , now_diff break else : old_diff = now_diff if self . keep_running_opt == 0 : print 'User abort' break self . update_pkasystem_curves ( ) return
Optimise the system according to the values given by the user
Optimise the system according to the values given by the user
"""Optimise the system according to the values given by the user""" # # Did the bozo choose the CCPS? # # # Find the properties we will use # # # # Get the variables # # # Perform all variations within the limits # # # Make copies of all the variables # # # Set damper # # # Update the counter # # # Init vars for the scoring function # # # Start off the iterations # # # Update the counter, the scales and the titration curves # #self.optwin.update_idletasks() # This statement is essential for propagating changes in variable values # # # recalculate the differences # # # Check convergence # # # Should we stop? #
self