Run an experiment.

@param \Scientist\Experiment $experiment

@return mixed
184272
public function runExperiment(Experiment $experiment)
    {
        if ($experiment->shouldRun()) {
            $report = $this->getReport($experiment);
            return $report->getControl()->getValue();
        }

        return call_user_func_array(
            $experiment->getControl(),
            $experiment->getParams()
        );
    }
1005479
public function run()
    {
        // TODO: Implement run() method.
        switch ($_SERVER['REQUEST_METHOD']) {
            case 'GET':
                return $this->get($this->params);
            case 'POST':
                return $this->post($this->params);
            case 'PUT':
                return $this->put($this->params);
            case 'DELETE':
                return $this->delete($this->params);
        }
    }
1141031
def run_experiment(experiment, roleouts, episodes, in_cloud=False,
                   dynProfile=None):
    
    def run():
        if dynProfile is None:
            maxsteps = len(experiment.profile) # episode length
        else:
            maxsteps = dynProfile.shape[1]
        na = len(experiment.agents)
        ni = roleouts * episodes * maxsteps

        all_action = zeros((na, 0))
        all_reward = zeros((na, 0))
        epsilon = zeros((na, ni)) # exploration rate

        # Converts to action vector in percentage markup values.
        vmarkup = vectorize(get_markup)

        for roleout in range(roleouts):
            if dynProfile is not None:
                # Apply new load profile before each roleout (week).
                i = roleout * episodes # index of first profile value
                experiment.profile = dynProfile[i:i + episodes, :]

#            print "PROFILE:", experiment.profile, episodes

            experiment.doEpisodes(episodes) # number of samples per learning step

            nei = episodes * maxsteps # num interactions per role
            epi_action = zeros((0, nei))
            epi_reward = zeros((0, nei))

            for i, (task, agent) in \
            enumerate(zip(experiment.tasks, experiment.agents)):
                action = copy(agent.history["action"])
                reward = copy(agent.history["reward"])

                for j in range(nei):
                    if isinstance(agent.learner, DirectSearchLearner):
                        action[j, :] = task.denormalize(action[j, :])
                        k = nei * roleout
                        epsilon[i, k:k + nei] = agent.learner.explorer.sigma[0]
                    elif isinstance(agent.learner, ValueBasedLearner):
                        action[j, :] = vmarkup(action[j, :], task)
                        k = nei * roleout
                        epsilon[i, k:k + nei] = agent.learner.explorer.epsilon
                    else:
                        action = vmarkup(action, task)

                # FIXME: Only stores action[0] for all interactions.
                epi_action = c_[epi_action.T, action[:, 0].flatten()].T
                epi_reward = c_[epi_reward.T, reward.flatten()].T

                if hasattr(agent, "module"):
                    print "PARAMS:", agent.module.params

                agent.learn()
                agent.reset()

            all_action = c_[all_action, epi_action]
            all_reward = c_[all_reward, epi_reward]

        return all_action, all_reward, epsilon

    if in_cloud:
        import cloud
        job_id = cloud.call(run, _high_cpu=False)
        result = cloud.result(job_id)
        all_action, all_reward, epsilon = result
    else:
        all_action, all_reward, epsilon = run()

    return all_action, all_reward, epsilon
879455
public function run(Request $request)
    {
        $this->container = $this->container ?: Application::getInstance();
        $this->container->set(Request::class, $request);

        // Check and run controller
        if ($this->isControllerAction()) {
            return $this->runController();
        }

        return $this->runCallable();
    }
1213460
public function run($args)
    {
        $args = $this->parseArgs($args);
        foreach ($this->options as $argument => $attribute) {
            $this->{$attribute} = in_array($argument, $args);
            if ($this->{$attribute}) {
                $args = array_values(array_diff($args, [$argument]));
            }
        }

        if (!isset($args[0]) || !$args[0]) {
            return $this->initPath($this->cwd);
        }

        $projectName = $args[0];
        if (!$this->existsProjectName($projectName)) {
            return "> Producer: Project '{$this->projectsDir}/{$projectName}' not found.\n";
        }

        return $this->initPath($this->getProjectDir($projectName));
    }
887934
public function run()
	{
		$objTemplate = new \BackendTemplate('be_rsce_convert');
		$objTemplate->isActive = $this->isActive();
		$objTemplate->action = ampersand(\Environment::get('request'));
		$objTemplate->indexHeadline = $GLOBALS['TL_LANG']['tl_maintenance']['searchIndex'];

		// Rebuild the index
		if (\Input::get('act') === 'rsce_convert') {

			// Check the request token
			if (!isset($_GET['rt']) || !\RequestToken::validate(\Input::get('rt')))
			{
				\System::getContainer()->get('session')->getBag('contao_backend')->set('INVALID_TOKEN_URL', \Environment::get('request'));
				$this->redirect('contao/confirm.php');
			}

			$this->import('Database');

			$failedElements = array();
			$elementsCount = 0;

			$contentElements = \ContentModel::findBy(array(\ContentModel::getTable() . '.type LIKE ?'), 'rsce_%');

			while ($contentElements && $contentElements->next()) {

				$html = $this->getHtmlFromElement($contentElements);

				if (!$html) {
					$failedElements[] = array('content', $contentElements->id, $contentElements->type);
				}
				else {

					$GLOBALS['TL_DCA'][\ContentModel::getTable()]['config']['ptable'] = $contentElements->ptable ?: \ArticleModel::getTable();

					$versions = new \Versions(\ContentModel::getTable(), $contentElements->id);

					$versions->initialize();

					$this->Database
						->prepare('UPDATE ' . \ContentModel::getTable() . ' SET tstamp = ?, type = \'html\', html = ? WHERE id = ?')
						->execute(time(), $html, $contentElements->id);
					$elementsCount++;

					$versions->create();

				}

			}

			$moduleElements = \ModuleModel::findBy(array(\ModuleModel::getTable() . '.type LIKE ?'), 'rsce_%');

			while ($moduleElements && $moduleElements->next()) {

				$html = $this->getHtmlFromElement($moduleElements);

				if (!$html) {
					$failedElements[] = array('module', $moduleElements->id, $moduleElements->type);
				}
				else {

					$versions = new \Versions(\ModuleModel::getTable(), $moduleElements->id);

					$versions->initialize();

					$this->Database
						->prepare('UPDATE ' . \ModuleModel::getTable() . ' SET tstamp = ?, type = \'html\', html = ? WHERE id = ?')
						->executeUncached(time(), $html, $moduleElements->id);
					$elementsCount++;

					$versions->create();

				}

			}

			$formElements = \FormFieldModel::findBy(array(\FormFieldModel::getTable() . '.type LIKE ?'), 'rsce_%');

			while ($formElements && $formElements->next()) {

				$html = $this->getHtmlFromElement($formElements);

				if (!$html) {
					$failedElements[] = array('form', $formElements->id, $formElements->type);
				}
				else {

					$versions = new \Versions(\FormFieldModel::getTable(), $formElements->id);

					$versions->initialize();

					$this->Database
						->prepare('UPDATE ' . \FormFieldModel::getTable() . ' SET tstamp = ?, type = \'html\', html = ? WHERE id = ?')
						->executeUncached(time(), $html, $formElements->id);
					$elementsCount++;

					$versions->create();

				}

			}

			foreach ($failedElements as $element) {
				$this->log('Failed to convert ' . $element[0] . ' element ID ' . $element[1] . ' (' . $element[2] . ') to a standard HTML element', __METHOD__, TL_ERROR);
			}

			$this->log('Converted ' . $elementsCount . ' RockSolid Custom Elements to standard HTML elements', __METHOD__, TL_GENERAL);

			$objTemplate->elementsCount = $elementsCount;
			$objTemplate->failedElements = $failedElements;

		}

		$this->loadLanguageFile('rocksolid_custom_elements');

		return $objTemplate->parse();
	}
351479
def update_experiment():
    ''''''
    experiment_config = Experiments()
    experiment_dict = experiment_config.get_all_experiments()
    if not experiment_dict:
        return None
    for key in experiment_dict.keys():
        if isinstance(experiment_dict[key], dict):
            if experiment_dict[key].get('status') != 'STOPPED':
                nni_config = Config(experiment_dict[key]['fileName'])
                rest_pid = nni_config.get_config('restServerPid')
                if not detect_process(rest_pid):
                    experiment_config.update_experiment(key, 'status', 'STOPPED')
                    continue
                rest_port = nni_config.get_config('restServerPort')
                startTime, endTime = get_experiment_time(rest_port)
                if startTime:
                    experiment_config.update_experiment(key, 'startTime', startTime)
                if endTime:
                    experiment_config.update_experiment(key, 'endTime', endTime)
                status = get_experiment_status(rest_port)
                if status:
                    experiment_config.update_experiment(key, 'status', status)
395262
protected function run($method)
    {
        $endpoint = $this->getEndpoint($method);
        $outputFile = $this->getArgument('accept_file');
        if (is_null($outputFile)) {
            $outputFile = $this->getArgument('accept_any_file');
        }
        if (is_null($outputFile)) {
            $outputFile = $this->getArgument('accept_sound_file');
        }
        $cType = $this->getContentType($method);
        $aCType = $this->getAcceptContentType($method);
        $this->delArgument('accept_file');
        $this->delArgument('accept_any_file');
        $this->delArgument('accept_sound_file');
        $body = $this->getBody($method);
        return $this->client->run(
            $endpoint,
            $method,
            $cType,
            $aCType,
            $body,
            $outputFile
        );
    }
772476
def _maybe_init_run(self, experiment_name, run_name):
    
    experiment_id = self._maybe_init_experiment(experiment_name)
    cursor = self._db.cursor()
    cursor.execute(
        """
        SELECT run_id FROM Runs
        WHERE experiment_id = ? AND run_name = ?
        """,
        (experiment_id, run_name))
    row = cursor.fetchone()
    if row:
      return row[0]
    run_id = self._create_id()
    # TODO: track actual run start times
    started_time = 0
    cursor.execute(
        """
        INSERT INTO Runs (
          experiment_id, run_id, run_name, inserted_time, started_time
        ) VALUES (?, ?, ?, ?, ?)
        """,
        (experiment_id, run_id, run_name, time.time(), started_time))
    return run_id
473083
def set_experiment_winner(experiment):
    """"""
    redis = _get_redis_connection()
    experiment = Experiment.find(redis, experiment)
    if experiment:
        alternative_name = request.form.get('alternative')
        alternative = Alternative(redis, alternative_name, experiment.name)
        if alternative.name in experiment.alternative_names:
            experiment.winner = alternative.name
    return redirect(url_for('.index'))
503662
public function run($request)
    {
        $name = get_class($this);
        $verbose = $request->getVar('verbose');

        // Set new logger
        $logger = $this
            ->getLoggerFactory()
            ->getOutputLogger($name, $verbose);
        $this->setLogger($logger);
    }
542450
def add_experiment(experiment):
    """"""
    redis = oz.redis.create_connection()
    oz.bandit.add_experiment(redis, experiment)
242029
function run()
    {
        $res = $this->resolve();

        $ctrl = isset($res['controller']) && $res['controller'] !== null ? $res['controller'] : $this->defaultController;
        $action = isset($res['action']) && $res['action'] !== null ? $res['action'] : $this->defaultAction;

        //Name format to Controller namespace
        $tmp = explode('\\', str_replace('/', '\\', $ctrl));
        $ctrl = '\\Controller';
        foreach($tmp as $tmp1){
            $ctrl .= '\\'.ucfirst($tmp1);
        }

        //instantiate the controller
        $controller = new $ctrl(['params' => $res['params'], 'request' => $this->request]);

        $this->params = $res['params'];

        if (method_exists($controller, $action))
            return $controller->$action();
        else
            return $controller->{static::$defaultAction}();
    }
355922
public function run() {
		list($name, $id) = $this->resolveNameID();

		if (isset($this->htmlOptions['id'])) {
			$id = $this->htmlOptions['id'];
		} else {
			$this->htmlOptions['id'] = $id;
		}

		if (isset($this->htmlOptions['name'])) {
			$name = $this->htmlOptions['name'];
		}

		if ($this->hasModel()) {
			echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
		} else {
			echo CHtml::textField($name, $this->value, $this->htmlOptions);
		}

		if (isset($this->datasets['source']))
			$this->datasets = array($this->datasets);

		$datasets_js = array();
		foreach ($this->datasets as $i => $dataset) {
			if (!isset($dataset['source'])) {
				throw new CException('The source for a Typeahead dataset was not set');
			}
			if (isset($dataset['source']['name'])) {
				$name = preg_replace('/[^\da-z]/i', '_', $dataset['source']['name']);
				$bloodhound_id = $this->id .'_bloodhound_'. $name;
				$dataset['source'] = 'js:'. $bloodhound_id .'.ttAdapter()';
			} else {
				$dataset['source'] = 'js:substringMatcher(_'. $this->id .'_source_list_'. $i .')';
			}
			$this->datasets[$i] = $dataset;
			$datasets_js[] = CJavaScript::encode($dataset);
		}
		
		$options = CJavaScript::encode($this->options);
		$datasets = implode(', ', $datasets_js);
		
		Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').typeahead({$options}, {$datasets});");
		
	}
1092506
public function run(Request $request = null)
    {
        if (null === $request) {
            $request = Request::createFromGlobals();
        }

        $response = $this->handle($request);
        $response->send();

        return $response;
    }
283471
def add_experiment(redis, name):
    """"""

    if not ALLOWED_NAMES.match(name):
        raise ExperimentException(name, "Illegal name")
    if redis.exists(EXPERIMENT_REDIS_KEY_TEMPLATE % name):
        raise ExperimentException(name, "Already exists")

    json = dict(creation_date=util.unicode_type(datetime.datetime.now()))
    pipe = redis.pipeline(transaction=True)
    pipe.sadd(ACTIVE_EXPERIMENTS_REDIS_KEY, name)
    pipe.hset(EXPERIMENT_REDIS_KEY_TEMPLATE % name, "metadata", escape.json_encode(json))
    pipe.execute()
    return Experiment(redis, name)
1299111
public function run( Request $request )
	{
		try
		{
			if ( !is_string( $this->action['uses'] ) )
				return $this->runCallable( $request );

			return $this->runController( $request );
		}
		catch ( HttpResponseException $e )
		{
			return $e->getResponse();
		}
	}