Esempio n. 1
0
    def update(self, min_yield):
        '''
        updates the sequences based on if they are higher than the last minimum yield
        :param min_yield: current threshold
        :return: will update original sequence based on if developability parameter found from self.test_seq was
        higher than thershold.

        '''
        # print('updating the sequences based on last minimum yield')
        # print('current minimum yield is  %0.2f' % min_yield)
        # convert the pandas columns to numpy arrays so no for loops  :/
        test_array = sm.convert2numpy(self.test_seq)
        orginal_array =sm.convert2numpy(self.df)
        test_dev = sm.convert2numpy(self.test_seq,self.yield2optimize)
        org_dev = sm.convert2numpy(self.df,self.yield2optimize)
        # accept changes that meet the min yield requirement
        mutatable_seq = min_yield < test_dev

        orginal_array[mutatable_seq, :] = np.copy(test_array[mutatable_seq, :])
        org_dev[mutatable_seq] = np.copy(test_dev[mutatable_seq])

        # update self.test_seq and self.original_seq
        # dangerous code below ; changing self parameters...
        self.df['Ordinal'] = sm.convert2pandas(orginal_array)
        self.df[self.yield2optimize] = org_dev
        self.test_seq = self.df.copy()
        self.test_seq = self.test_seq[['Ordinal']]

        return np.count_nonzero(mutatable_seq) / mutatable_seq.shape[0]
Esempio n. 2
0
    def save_testseq_2_original_seq(self, org_dev, orginal_array):
        print(
            'Saving the updated sequence and developability of last sequence as well.'
        )
        self.original_seq['Ordinal'] = sm.convert2pandas(orginal_array)
        self.original_seq['Developability'] = org_dev

        self.original_seq = self.original_seq[['Ordinal', 'Developability']]
        self.test_seq = self.original_seq.copy()
        self.test_seq = self.test_seq[['Ordinal']]
Esempio n. 3
0
    def change_lowest_yield_sequence_configuration(self):
        '''
        function to mutate the current sequences
        :param idx: index of sequence with lowest yield
        :return: updates self.original_seq['Ordinal']
        '''
        # print('sequence to change %i'%self.idx)
        change_2_seq = self.idx
        while change_2_seq == self.idx:
            change_2_seq = self.g.uniform(shape=[1], minval=0, maxval=self.nb_of_sequences,  # [0,nb_of_sequences)
                                      dtype=tf.int64).numpy()[0]
        # print('new idx  %i '%change_2_seq)
        orginal_array =sm.convert2numpy(df=self.df)
        orginal_array[self.idx, :] = orginal_array[change_2_seq, :].copy()
        # TODO : optimize in pandas to change one sequence without changing everything
        self.df['Ordinal'] = sm.convert2pandas(orginal_array)

        dev=sm.convert2numpy(df=self.df,field=self.yield2optimize)
        # print(dev[self.idx])
        dev[self.idx]=dev[change_2_seq]
        self.df[self.yield2optimize]=sm.convert2pandas(dev)
Esempio n. 4
0
def save_run_stats(c, loops_2_show, nproc):
    # save initial run stats
    stats = pd.DataFrame()
    stats.loc[0, 'nb_loops'] = c.nb_loops
    stats.loc[0, 'nb_steps'] = c.nb_steps
    stats.loc[0, 'start mutation number'] = c.nb_mutations
    stats.loc[0, 'mutation_type'] = c.mutation_type
    stats.loc[0, 'Nb_sequences'] = c.Nb_sequences
    stats.loc[0, 'nproc'] = nproc
    stats.loc[0, 'yield2optimize'] = c.yield2optimize
    stats['Loops to show'] = sm.convert2pandas(np.array([loops_2_show]))
    stats.to_pickle(path=make_file_name(c=c, file_description='run_stats'))
Esempio n. 5
0
    def change_lowest_yield_sequence_configuration(self, idx):
        '''

        :param idx: index of sequence with lowest yield
        :return: updates self.original_seq['Ordinal']
        '''
        print('resampling sequence with lowest min yield, seq idx: %i' % idx)
        change_2_seq = idx
        # idk if any of those syntax is correct ...
        while change_2_seq == idx:
            change_2_seq = self.g_parent.uniform(
                shape=[1],
                minval=0,
                maxval=self.nb_of_sequences,  # [0,nb_of_sequences)
                dtype=tf.int64).numpy()[0]

        # just do the normal method here b/c this is being dumb.
        orginal_array = np.copy(
            np.array(self.original_seq['Ordinal'].to_numpy().tolist()))
        orginal_array[idx, :] = orginal_array[change_2_seq, :].copy()
        # TODO : optimize in pandas to change one sequence without changing everything
        self.original_seq['Ordinal'] = sm.convert2pandas(orginal_array)
        print('updated lowest min yield')
Esempio n. 6
0
import time
import os
import ns_walk as nw
import sys
from ray.util import ActorPool
import ns_data_modules as dm
nproc = np.arange(16, 72, 8)
nproc = [8]
sequence = np.arange(20000, 200000, 20000)

# nproc=np.arange(3,9,2)
# sequence=np.arange(5000,20000,5000)
cpus = 8

times = pd.DataFrame()
times['sequence'] = sm.convert2pandas(sequence)

if ray.is_initialized() is True:
    ray.shutdown()
ray.init(ignore_reinit_error=True)
seed_parent = int.from_bytes(os.urandom(4), sys.byteorder)
g_parent = tf.random.experimental.Generator.from_seed(seed_parent)
# find number of shared memory cores
nb_steps = 15
nb_mutations = 16
yield2optimize = 'Developability'

walkers = [
    nw.walk.remote(nb_steps=nb_steps,
                   yield2optimize=yield2optimize,
                   profile=True) for _ in range(cpus)