コード例 #1
0
ファイル: sum.py プロジェクト: Veterun/cryoem-cvpr2015
 def __init__(self,fspace,objs,ws=None):
     Objective.__init__(self,fspace)
     self.objs = objs
     if ws == None:
         self.ws = [None]*len(objs)
     else:
         self.ws = ws
コード例 #2
0
 def __init__(self, fspace, objs, ws=None):
     Objective.__init__(self, fspace)
     self.objs = objs
     if ws == None:
         self.ws = [None] * len(objs)
     else:
         self.ws = ws
コード例 #3
0
    def set_dataset(self, cryodata):
        Objective.set_dataset(self, cryodata)
        self.kernel.set_dataset(cryodata)

        self.error_history = FiniteRunningSum(second_order=False)
        self.correlation_history = FiniteRunningSum(second_order=False)
        self.power_history = FiniteRunningSum(second_order=False)
        self.mask_history = FiniteRunningSum(second_order=False)
コード例 #4
0
ファイル: likelihood.py プロジェクト: Veterun/cryoem-cvpr2015
    def set_dataset(self,cryodata):
        Objective.set_dataset(self,cryodata)
        self.kernel.set_dataset(cryodata)

        self.error_history = FiniteRunningSum(second_order=False)
        self.correlation_history = FiniteRunningSum(second_order=False)
        self.power_history = FiniteRunningSum(second_order=False)
        self.mask_history = FiniteRunningSum(second_order=False)
コード例 #5
0
    def setup(self,params,diagout,statout,ostream):
        Objective.setup(self,params,diagout,statout,ostream)

        if params['kernel'] == 'multicpu':
            from cpu_kernel import UnknownRSThreadedCPUKernel
            self.kernel = UnknownRSThreadedCPUKernel()
        else:
            assert False
        self.kernel.setup(params,diagout,statout,ostream)
コード例 #6
0
ファイル: deepaugment.py プロジェクト: abcp4/DeepAugmentColab
    def __init__(self, images="cifar10", labels=None, config=None):
        """Initializes DeepAugment object

        Does following steps:
            1. load and preprocess data
            2. create child model
            3. create controller
            4. create notebook (for recording trainings)
            5. do initial training
            6. create objective function
            7. evaluate objective function without augmentation

        Args:
            images (numpy.array/str): array with shape (n_images, dim1, dim2 , channel_size), or a string with name of keras-dataset (cifar10, fashion_mnsit)
            labels (numpy.array): labels of images, array with shape (n_images) where each element is an integer from 0 to number of classes
            config (dict): dictionary of configurations, for updating the default config which is:
                {
                    "model": "basiccnn",
                    "method": "bayesian_optimization",
                    "train_set_size": 2000,
                    "val_set_size": 100,
                    "opt_samples": 3,
                    "opt_last_n_epochs": 3,
                    "opt_initial_points": 10,
                    "child_epochs": 50,
                    "child_first_train_epochs": 0,
                    "child_batch_size": 64,
                    "pre_aug_weights_path": "pre_aug_weights.h5",
                    "logging": logging,
                    "notebook_path": f"{EXPERIMENT_FOLDER_PATH}/notebook.csv"
                }
        """
        self.config = DEFAULT_CONFIG
        if config!=None: self.config.update(config)
        self.iterated = 0  # keep tracks how many times optimizer iterated

        self._load_and_preprocess_data(images, labels)

        # define main objects
        self.child_model = ChildCNN(self.input_shape, self.num_classes, self.config)
        self.controller = Controller(self.config)
        self.notebook = Notebook(self.config)
        if self.config["child_first_train_epochs"] > 0:
            self._do_initial_training()
        self.child_model.save_pre_aug_weights()
        self.objective_func = Objective(
            self.data, self.child_model, self.notebook, self.config
        )

        #self._evaluate_objective_func_without_augmentation()
        self.trial_hyperparams = None
        self.trial_no = 0
コード例 #7
0
 def add_objective(self, name, m_points, weight = None, m_points_weights = [], fit_penalty = 0.0):
     obj = Objective(name, points = m_points, weight = weight, points_weights = m_points_weights, fit_penalty = fit_penalty)
     
     #debug_p('adding objective to model ' + str(self.get_model_id()))
     
     self.objectives.append(obj)
     #debug_p('model id (in model) ' + str(self.get_id()))
     #debug_p('num objectives ' + str(len(self.objectives)))
     if weight == None:
         # setting all objectives to equal weight
         eq_weight = 1/(len(self.objectives) + 0.0)
         for obj in self.objectives:
             obj.set_weight(eq_weight)
コード例 #8
0
    def placeObjective(self, objective, x, y):
        if objective != "enemy":
            if not self.contains(objective):

                o = Objective(objective, x, y)
                self.objs.append(o)

            else:
                self.getObjective(objective).setPosition(x, y)

        else:
            o = Objective(objective, x, y)
            self.objs.append(o)
コード例 #9
0
 def test_unfulfilled_agents(self):
     sellers = [Candidate(0, 1), Candidate(0, 0.4)]
     buyers = [Candidate(0, 1.2), Candidate(0, 0.5)]
     edges = [(0, 0), (1, 1)]
     fs = [1, 0.3]
     ans = Objective.unfulfilled_agents(sellers, buyers, edges, fs)
     self.assertEqual(ans[0], [1], str(ans))
     self.assertEqual(ans[1], [0, 1], str(ans))
コード例 #10
0
ファイル: feems_opt.py プロジェクト: jhmarcus/feems-analysis
    def fit_quasi_newton(self,
                         lamb_l2,
                         lamb_smth,
                         lamb_log,
                         w_init,
                         factr=1e7,
                         maxls=50,
                         m=10,
                         lb=-np.Inf,
                         ub=np.Inf,
                         maxiter=15000,
                         verbose=True):
        """
        """
        obj = Objective(self.sumstats, self.graph)
        obj.lamb_l2 = lamb_l2
        obj.lamb_smth = lamb_smth
        obj.lamb_log = lamb_log
        res = fmin_l_bfgs_b(func=loss_wrapper,
                            x0=np.log(w_init),
                            args=[obj],
                            factr=factr,
                            m=m,
                            maxls=maxls,
                            maxiter=maxiter,
                            approx_grad=False,
                            bounds=[(lb, ub)
                                    for _ in range(obj.graph.Delta.shape[1])])
        if maxiter >= 100:
            assert res[2]["warnflag"] == 0, "did not converge"
        self.graph.w = np.exp(res[0])

        # print update
        self.train_loss, _ = loss_wrapper(res[0], obj)
        self.train_nll = neg_log_lik_wrapper(res[0], obj)
        self.pen = self.train_loss - self.train_nll
        if verbose:
            sys.stdout.write(
                ("lambda_l2={:.7f}, "
                 "lambda={:.7f}, "
                 "alpha={:.7f}, "
                 "converged in {} iterations, "
                 "train_loss={:.7f}\n").format(lamb_l2, lamb_smth, lamb_log,
                                               res[2]["nit"], self.train_loss))
コード例 #11
0
ファイル: Lvl_Data.py プロジェクト: fryingpan/Assignment2
 def load(self, lvl, stage):
     if (lvl == 1):
         if stage == 1:
             self.map_file = 'mapfilelvl1.1.txt'
         elif stage == 2:
             self.map_file = 'mapfilelvl1.2.txt'
         self.music_file = "music/gameplay.mod"
         self.cutscene = None
         self.objective = Objective(lvl, stage)
         self.character_pos_x = 100
         self.character_pos_y = 100
     elif (lvl == 2):
         if stage == 1:
             self.map_file = 'mapfilelvl2.1.txt'
         elif stage == 2:
             self.map_file = 'mapfilelvl2.2.txt'
         self.music_file = "music/gameplay2.mod"
         self.cutscene = None
         self.objective = Objective(lvl, stage)
         self.character_pos_x = 100
         self.character_pos_y = 100
     elif (lvl == 3):
         if stage == 1:
             self.map_file = 'mapfilelvl3.1.txt'
         elif stage == 2:
             self.map_file = 'mapfilelvl3.2.txt'
         self.music_file = "music/gameplay2.mod"
         self.cutscene = None
         self.objective = Objective(lvl, stage)
         self.character_pos_x = 100
         self.character_pos_y = 100
     elif (lvl == 4):
         if stage == 1:
             self.map_file = 'mapfile-lvl4-stg1.txt'
         elif stage == 2:
             self.map_file = 'mapfile-lvl4-stg2.txt'
         self.music_file = "music/gameplay3.mod"
         self.cutscene = None
         self.objective = Objective(lvl, stage)
         self.character_pos_x = 100
         self.character_pos_y = 100
     return self.map_file
コード例 #12
0
ファイル: main.py プロジェクト: wararaki718/scrapbox2
def main():
    iris = load_iris()
    X = iris.data
    y = iris.target

    obj = Objective(X, y)

    study = optuna.create_study(direction='maximize')
    study.optimize(obj, n_trials=20)
    print(study.best_trial)
    print('DONE')
コード例 #13
0
def updateObjectives(game_map, opponent_ships):
    objs = []
    for p in planets:
        en_list = sorted(opponent_ships,
                         key=lambda x: p.calculate_distance_between(x))
        for i in range(len(en_list)):
            if p.calculate_distance_between(en_list[i]) > 40 - p.radius:
                break

        if not p.is_owned() and p.remaining_resources > 0:
            objs.append(Objective(p, 'dock_unowned'))
            objs[-1].addEnShip(en_list[:i])
        elif p.owner == me:
            objs.append(Objective(p, 'defend'))
            objs[-1].addEnShip(en_list[:i])
            if not p.is_full() and p.remaining_resources > 0:
                objs.append(Objective(p, 'dock_owned'))
                objs[-1].addEnShip(en_list[:i])
        elif p.owner != me and p.is_owned():
            objs.append(Objective(p, 'attack'))
            objs[-1].addEnShip(en_list[:i])

    return objs
コード例 #14
0
ファイル: feems_opt.py プロジェクト: jhmarcus/feems-analysis
    def fit_w0_s2(self, verbose=True):
        """Fits a constant migration surface (no reg) and residual variance by maximum likelihood
        """
        obj = Objective(self.sumstats, self.graph)
        res = minimize(neg_log_lik_w0_s2, [0.0, 0.0],
                       method="Nelder-Mead",
                       args=(obj))
        assert res.success is True, "did not converge"
        w0_hat = np.exp(res.x[0])
        s2_hat = np.exp(res.x[1])
        self.graph.w0 = w0_hat * np.ones(self.graph.w.shape[0])
        self.sumstats.s2 = s2_hat
        self.sumstats.q = self.graph.n_samples_per_node / s2_hat
        self.sumstats.q_diag = sp.diags(self.sumstats.q).tocsc()
        self.sumstats.q_inv_diag = sp.diags(1. / self.sumstats.q).tocsc()

        # print update
        self.train_loss, _ = loss_wrapper(np.log(self.graph.w0), obj)
        if verbose:
            sys.stdout.write(
                ("constant-w/variance fit, "
                 "converged in {} iterations, "
                 "train_loss={:.7f}\n").format(res.nfev, self.train_loss))
コード例 #15
0
 def __init__(self):
     Objective.__init__(self, False)
     self.kernel = None
コード例 #16
0
    x = np.arange(xDomain[0], xDomain[1], 0.5)
    y = np.arange(yDomain[0], yDomain[1], 0.5)
    x, y = np.meshgrid(x, y)
    z = objectiveFunc(x, y)

    surface = axis.plot_surface(x,
                                y,
                                z,
                                cmap=cm.jet,
                                linewidth=0,
                                antialiased=False)

    figure.colorbar(
        surface,
        shrink=0.5,
        aspect=5,
    )
    plt.savefig(f'{savePath}/objectivePlot.png')
    plt.show(block=False)
    plt.pause(2)
    plt.close()


if __name__ == "__main__":
    params = util.getParams('./project2/params/params.yaml')
    xDomain = [1, 100]
    yDomain = [1, 100]
    objective = Objective(xDomain, yDomain)
    plotActual(xDomain, yDomain, objective.calculate, params['resultsPath'])
コード例 #17
0
ファイル: likelihood.py プロジェクト: Veterun/cryoem-cvpr2015
 def set_data(self,cparams,minibatch):
     Objective.set_data(self,cparams,minibatch)
     self.kernel.set_data(cparams,minibatch)
コード例 #18
0
ファイル: negative.py プロジェクト: qinyao-he/cryoem-cvpr2015
 def __init__(self):
     Objective.__init__(self, False)
コード例 #19
0
def comp_fit_cov(feems,
                 lamb_l2,
                 lamb_smth,
                 lamb_log,
                 projection=True,
                 include_var=False,
                 ind_level=False):
    # create obj
    obj = Objective(feems.sumstats, feems.graph)
    obj.lamb_l2 = lamb_l2
    obj.lamb_smth = lamb_smth
    obj.lamb_log = lamb_log

    # update laplacian
    obj.graph.comp_lap(obj.graph.w)

    # update nll and grad
    obj.inv()
    obj.grad()

    if ind_level is True:
        # number of individuals
        n, p = obj.sumstats.data.shape

        # row index of assn matrix
        row = np.arange(n)

        # col index of assn matrix
        col = obj.graph.obs_ids

        # fill up J
        J = sp.csc_matrix(
            (np.ones(n), (row, col)),
            shape=(n, obj.graph.d))[:, obj.graph.perm_ids][:, :obj.graph.o]

        # diagonal component
        q_full_samples = 1.0 / obj.sumstats.s2 * np.ones(obj.graph.o)

        # fitted covariance
        fit_cov = J @ (obj.Linv_block['oo'] - 1 / obj.graph.d) @ J.T + np.diag(
            J @ (1. / q_full_samples))

        # empirical covariance
        emp_cov = obj.sumstats.data @ obj.sumstats.data.T / p
    else:
        # fitted covariance
        fit_cov = obj.Linv_block[
            'oo'] - 1 / obj.graph.d + obj.sumstats.q_inv_diag.toarray()

        # empirical covariance
        emp_cov = obj.sumstats.S

    # project to the space of contrast
    if projection is True:
        C = comp_contrasts(n) if ind_level is True else comp_contrasts(
            obj.graph.o)
        fit_cov = C @ fit_cov @ C.T
        emp_cov = C @ emp_cov @ C.T

    if include_var is True:
        return (np.triu(fit_cov, k=0), np.triu(emp_cov, k=0))
    else:
        return (np.triu(fit_cov, k=1), np.triu(emp_cov, k=1))
コード例 #20
0
from utils import *
from objective import Objective


def generate_case():
    '''
    This is a function generating the data for a special case. with 3 sellers and 2 buyers
    :return: the list of sellers, the list of buyers, the edges between them.
    '''
    sellers = [Candidate(0.16, 10), Candidate(0.18, 10), Candidate(0.2, 10)]
    buyers = [Candidate(0.19, 13), Candidate(0.21, 13)]
    edges = [(0, 0), (1, 0), (1, 1), (2, 1)]
    return sellers, buyers, edges


sw, vols = solve_opt_assignment(*generate_case())
print "social welfare and volumes on each edge", sw, vols
print "The prices on each edge", Objective(*generate_case()).min_variance()
コード例 #21
0
ファイル: sparsity.py プロジェクト: qinyao-he/cryoem-cvpr2015
 def __init__(self, assumepos=False):
     Objective.__init__(self, False)
     self.assumepos = assumepos
コード例 #22
0
from objective import Objective
from tkinter import Tk
from pywinauto.application import Application
import time
import json
import random
import string
import datetime

# Automated creation of new OSRS accounts using Google Chrome
# the accounts will be stored in a JSON file

account = {}
dob = []
r = Tk()
chrome = Objective("GoogleChrome")
tempMailLink = "https://temp-mail.org/"
dir = "osrs/"

failCount = 0
attemptCount = 0


def get_random_alphanumeric_string(length):
    letters_and_digits = string.ascii_letters + string.digits
    result_str = ''.join(
        (random.choice(letters_and_digits) for i in range(length)))
    return result_str


def fill_random_dateofbirth(objective):
コード例 #23
0
 def __init__(self):
     Objective.__init__(self, False)
     self.kernel = None
コード例 #24
0
 def set_data(self, cparams, minibatch):
     Objective.set_data(self, cparams, minibatch)
     for obj in self.objs:
         obj.set_data(cparams, minibatch)
コード例 #25
0
ファイル: sum.py プロジェクト: Veterun/cryoem-cvpr2015
 def set_data(self,cparams,minibatch):
     Objective.set_data(self,cparams,minibatch)
     for obj in self.objs: obj.set_data(cparams,minibatch)
コード例 #26
0
ファイル: sum.py プロジェクト: Veterun/cryoem-cvpr2015
 def set_dataset(self,cryodata):
     Objective.set_dataset(self,cryodata)
     for obj in self.objs: obj.set_dataset(cryodata)
コード例 #27
0
ファイル: sum.py プロジェクト: Veterun/cryoem-cvpr2015
 def setup(self,params,diagout,statout,ostream):
     Objective.setup(self,params,diagout,statout,ostream)
     for obj in self.objs: obj.setup(params,diagout,statout,ostream)
コード例 #28
0
import shutil
import util
from objective import Objective


def generateARFF(fileName, samples):
    fullDestFilePath = f'./project2/data/{fileName}.arff'
    shutil.copy2('./project2/starter.arff', fullDestFilePath)
    with open(fullDestFilePath, 'a') as arff:
        for sample in samples:
            arff.write(f'{sample[0]},{sample[1]},{sample[2]}\n')


if __name__ == "__main__":
    params = util.getParams('./project2/params/params.yaml')
    xDomain = [1, 100]
    yDomain = [1, 100]
    objective = Objective(xDomain, yDomain)
    trainingSamples = objective.getSamples(params['numSamples'])
    generateARFF('samples', objective.getSamples(params['numSamples']))
コード例 #29
0
 def __init__(self):
     Objective.__init__(self, False)
コード例 #30
0
 def __init__(self, fspace):
     Objective.__init__(self, fspace)
コード例 #31
0
 def set_dataset(self, cryodata):
     Objective.set_dataset(self, cryodata)
     for obj in self.objs:
         obj.set_dataset(cryodata)
コード例 #32
0
class DeepAugment:
    """Initiliazes commponents of DeepAugment (e.g. Controller, Child-model, Notebook) and optimizes image augmentation hyperparameters

    """

    @logger(logfile_dir=EXPERIMENT_FOLDER_PATH)
    def __init__(self, images="cifar10", labels=None, config=None):
        """Initializes DeepAugment object

        Does following steps:
            1. load and preprocess data
            2. create child model
            3. create controller
            4. create notebook (for recording trainings)
            5. do initial training
            6. create objective function
            7. evaluate objective function without augmentation

        Args:
            images (numpy.array/str): array with shape (n_images, dim1, dim2 , channel_size), or a string with name of keras-dataset (cifar10, fashion_mnsit)
            labels (numpy.array): labels of images, array with shape (n_images) where each element is an integer from 0 to number of classes
            config (dict): dictionary of configurations, for updating the default config which is:
                {
                    "model": "basiccnn",
                    "method": "bayesian_optimization",
                    "train_set_size": 2000,
                    "opt_samples": 3,
                    "opt_last_n_epochs": 3,
                    "opt_initial_points": 10,
                    "child_epochs": 50,
                    "child_first_train_epochs": 0,
                    "child_batch_size": 64,
                    "pre_aug_weights_path": "pre_aug_weights.h5",
                    "logging": logging,
                    "notebook_path": f"{EXPERIMENT_FOLDER_PATH}/notebook.csv"
                }
        """
        self.config = DEFAULT_CONFIG
        if config!=None: self.config.update(config)
        self.iterated = 0  # keep tracks how many times optimizer iterated

        self._load_and_preprocess_data(images, labels)

        # define main objects
        self.child_model = ChildCNN(self.input_shape, self.num_classes, self.config)
        self.controller = Controller(self.config)
        self.notebook = Notebook(self.config)
        if self.config["child_first_train_epochs"] > 0:
            self._do_initial_training()
        self.child_model.save_pre_aug_weights()
        self.objective_func = Objective(
            self.data, self.child_model, self.notebook, self.config
        )

        self._evaluate_objective_func_without_augmentation()

    def optimize(self, iterations=300):
        """Optimize objective function hyperparameters using controller and child model

        Args:
            iterations (int): number of optimization iterations, which the child model will be run

        Returns:
            pandas.DataFrame: top policies (with highest expected accuracy increase)
        """
        # iteratate optimizer
        for trial_no in range(self.iterated + 1, self.iterated + iterations + 1):
            trial_hyperparams = self.controller.ask()
            print("trial:", trial_no, "\n", trial_hyperparams)
            f_val = self.objective_func.evaluate(trial_no, trial_hyperparams)
            self.controller.tell(trial_hyperparams, f_val)

        self.iterated += iterations  # update number of previous iterations

        self.top_policies = self.notebook.get_top_policies(20)
        self.notebook.output_top_policies()
        print("\ntop policies are:\n", self.top_policies)

        return self.top_policies

    def image_generator_with_top_policies(self, images, labels, batch_size=None):
        """

        Args:
            images (numpy.array): array with shape (N,dim,dim,channek-size)
            labels (numpy.array): array with shape (N), where each eleemnt is an integer from 0 to num_classes-1
            batch_size (int): batch size of the generator on demand
        Returns:
            generator: generator for augmented images
        """
        if batch_size is None:
            batch_size = self.config["child_batch_size"]

        top_policies_list = self.top_policies[
            ['A_aug1_type', 'A_aug1_magnitude', 'A_aug2_type', 'A_aug2_magnitude',
             'B_aug1_type', 'B_aug1_magnitude', 'B_aug2_type', 'B_aug2_magnitude',
             'C_aug1_type', 'C_aug1_magnitude', 'C_aug2_type', 'C_aug2_magnitude',
             'D_aug1_type', 'D_aug1_magnitude', 'D_aug2_type', 'D_aug2_magnitude',
             'E_aug1_type', 'E_aug1_magnitude', 'E_aug2_type', 'E_aug2_magnitude']
        ].to_dict(orient="records")

        return deepaugment_image_generator(images, labels, top_policies_list, batch_size=batch_size)


    def _load_and_preprocess_data(self, images, labels):
        """Loads and preprocesses data

        Records `input_shape`, `data`, and `num_classes` into `self

        Args:
            images (numpy.array/str): array with shape (n_images, dim1, dim2 , channel_size), or a string with name of keras-dataset (cifar10, fashion_mnsit)
            labels (numpy.array): labels of images, array with shape (n_images) where each element is an integer from 0 to number of classes
        """
        if isinstance(images, str):
            X, y, self.input_shape = DataOp.load(images)
        else:
            X, y = images, labels
        self.input_shape = X.shape[1:]
        self.data = DataOp.preprocess(X, y, self.config["train_set_size"])
        self.num_classes = DataOp.find_num_classes(self.data)

    def _do_initial_training(self):
        """Do the first training without augmentations

        Training weights will be used as based to further child model trainings
        """
        history = self.child_model.fit(
            self.data, epochs=self.config["child_first_train_epochs"]
        )
        #BUG
        #self.notebook.record(
        #    -1, ["first", 0.0, "first", 0.0, "first", 0.0, 0.0], 1, None, history
        #)

    def _evaluate_objective_func_without_augmentation(self):
        """Find out what would be the accuracy if augmentation are not applied
        """
        no_aug_hyperparams = ["rotate", 0.0, "rotate", 0.0,
                              "rotate", 0.0, "rotate", 0.0,
                              "rotate", 0.0, "rotate", 0.0,
                              "rotate", 0.0, "rotate", 0.0,
                              "rotate", 0.0, "rotate", 0.0]
        f_val = self.objective_func.evaluate(0, no_aug_hyperparams)
        self.controller.tell(no_aug_hyperparams, f_val)
コード例 #33
0
 def setup(self, params, diagout, statout, ostream):
     Objective.setup(self, params, diagout, statout, ostream)
     for obj in self.objs:
         obj.setup(params, diagout, statout, ostream)
コード例 #34
0
 def __init__(self):
     Objective.__init__(self, False)
     self.car_type = None
     self.car_N = None
     self.car_C = None
コード例 #35
0
                        help="Prefix to all filenames")

    parser.add_argument(
        '--with_competitor',
        action='store_true',
        help=
        'Also run the standard DNN+Opt competitor to see how well ISMO is doing in comparison'
    )

    args = parser.parse_args()
    prefix = args.prefix

    dimension = 2
    number_of_variables = 1

    objective = Objective()

    ismo.convergence.convergence_study(
        generator_name=args.generator,
        training_parameter_filename=args.simple_configuration_file,
        optimizer_name=args.optimizer,
        retries=args.retries,
        save_result=args.save_result,
        prefix=args.prefix,
        with_competitor=args.with_competitor,
        dimension=dimension,
        number_of_variables=number_of_variables,
        number_of_samples_per_iteration=args.number_of_samples_per_iteration,
        simulator_creator=lambda starting_sample: simulate,
        objective=objective,
        variable_names=['p'],
コード例 #36
0
    def sample_points(self):
        """
        Main function, calls find_new_vector method for the required number of times
        """
        objective = Objective(self.n_dim, self.n_results)
        objective.add_point(np.array(self.example))

        addI = 0
        while addI < self.n_results - 1:
            if addI % 10 == 0:
                print addI
            new_vector, count_fail, best_val = self.find_new_vector(objective)
            if new_vector is not None:
                addI += 1
                objective.add_point(new_vector)

                # adds to total values for final reporting
                # sets min and max objective values for subsequent normalization
                objective.total_obj_distance += best_val
                objective.add_count_fail(count_fail)
                objective.set_max_objective(best_val)
                objective.set_min_objective(parameters.OBJECTIVE_METHOD)
            else:
                print "New vector not found...Consider parameter change if problem exists"

        print
        print "Total Count Fail ", objective.total_count_fail
        print "Total Objective Distance ", objective.total_obj_distance
        return objective.sample_points
コード例 #37
0
ファイル: main.py プロジェクト: noodlegg/Input-Automatisation
from objective import Objective
from tkinter import Tk
import time
import re

# Automated sequence of actions for interaction with Discord bot
# Requires you to have the Discord client in the foreground
# TODO: Instead of time.sleep() it should await for some period of time

r = Tk()
Discord = Objective("Discord")
OCR = Objective("OCR")
countSpawned = 0
countClaimed = 0

# Execution loop
if __name__ == "__main__":
    while True:
        # Type something in Discord chat
        try:
            Discord.clickAtImg("dc_input.PNG")
            Discord.write(".")
            Discord.hotkey("enter")
            time.sleep(0.7)
        except:
            print("Couldn't find Discord input field!")
            continue

        # Check whether card spawned
        try:
            startCoord = Discord.locateImg("dc_spawn.PNG")
コード例 #38
0
ファイル: car.py プロジェクト: Veterun/cryoem-cvpr2015
 def __init__(self):
     Objective.__init__(self,False)
     self.car_type = None
     self.car_N = None
     self.car_C = None
コード例 #39
0
 def set_data(self, cparams, minibatch):
     Objective.set_data(self, cparams, minibatch)
     self.kernel.set_data(cparams, minibatch)
コード例 #40
0
from objective import Objective
from utils import get_data, to_original_order
from connectivity import DistanceConnectivity

if __name__ == '__main__':
    for k_instance in range(100):
        sellers, buyers, edges = get_data('data%d.txt'%k_instance, DistanceConnectivity(10))
        _, _, ori_edges = to_original_order(sellers, buyers, edges)
        alg = Objective(sellers, buyers, edges)

        for obj in ['urr', 'min_var', 'balance']:
            filename = 'output/' + obj + str(k_instance) + '.txt'
            prices = alg.get_prices(obj)
            solution = zip(ori_edges, zip(prices, alg.fs))
            file(filename, 'w').write(str(solution))
コード例 #41
0
ファイル: sparsity.py プロジェクト: Veterun/cryoem-cvpr2015
 def __init__(self,assumepos=False):
     Objective.__init__(self,False)
     self.assumepos = assumepos