Get an objective.
12612
def _obj(self):
        
        class Objectives(object):
            def __getitem__(_self, name):
                return self.getObjective(name)

            def __iter__(_self):
                return self.getObjectives()

        return Objectives()
303440
def run_objective(objective, _name, raw_output, output_files, threads)
      # output is a, array: [raw_output, output_files].
      # output_files is a hash containing the absolute paths
      # to file(s) output by the target in the format expected by the
      # objective function(s), with keys as the keys expected by the
      # objective function
      return objective.run(raw_output, output_files, threads)
    end
391064
def get(method, hmc, uri, uri_parms, logon_required):
        """"""
        query_str = uri_parms[0]
        try:
            console = hmc.consoles.lookup_by_oid(None)
        except KeyError:
            raise InvalidResourceError(method, uri)
        result_tasks = []
        filter_args = parse_query_parms(method, uri, query_str)
        for task in console.tasks.list(filter_args):
            result_task = {}
            for prop in task.properties:
                if prop in ('element-uri', 'name'):
                    result_task[prop] = task.properties[prop]
            result_tasks.append(result_task)
        return {'tasks': result_tasks}
131693
def _get_object(data, position, obj_end, opts, dummy):
    """"""
    obj_size, end = _get_object_size(data, position, obj_end)
    if _raw_document_class(opts.document_class):
        return (opts.document_class(data[position:end + 1], opts),
                position + obj_size)

    obj = _elements_to_dict(data, position + 4, end, opts)

    position += obj_size
    if "$ref" in obj:
        return (DBRef(obj.pop("$ref"), obj.pop("$id", None),
                      obj.pop("$db", None), obj), position)
    return obj, position
1217404
def set_objective_sense(self, sense):
        """"""
        if sense == ObjectiveSense.Minimize:
            self._cp.objective.set_sense(self._cp.objective.sense.minimize)
        elif sense == ObjectiveSense.Maximize:
            self._cp.objective.set_sense(self._cp.objective.sense.maximize)
        else:
            raise ValueError('Invalid objective sense')
581244
def get(self):
        """"""
        d = self.getBaseRevision()
        d.addCallback(self.getPatch)
        d.addCallback(self.done)
        return d
703882
def get(self, object_type, object_id):
        """"""
        if object_id == 0:
            return json_success(json.dumps([]))

        query = db.session.query(TaggedObject).filter(and_(
            TaggedObject.object_type == object_type,
            TaggedObject.object_id == object_id))
        tags = [{'id': obj.tag.id, 'name': obj.tag.name} for obj in query]
        return json_success(json.dumps(tags))
826225
def get(self, *args, **kwargs):
        """"""
        location = args[0]
        params = self._get_keywords(location, kwargs)
        url = self._create_path(*args)
        request = requests.get(url, params=params)
        content = request.content
        self._request = request
        return self._output(content)
620882
def set_objective_sense(self, sense):
        """"""
        if sense == ObjectiveSense.Minimize:
            self._p.set_objective_sense(qsoptex.ObjectiveSense.MINIMIZE)
        elif sense == ObjectiveSense.Maximize:
            self._p.set_objective_sense(qsoptex.ObjectiveSense.MAXIMIZE)
        else:
            raise ValueError('Invalid objective sense')
297824
def load_item_for_objective(self):
        """"""
        mgr = self.my_osid_object._get_provider_manager('ASSESSMENT', local=True)
        if self.my_osid_object._my_map['itemBankId']:
            item_query_session = mgr.get_item_query_session_for_bank(Id(self.my_osid_object._my_map['itemBankId']),
                                                                     proxy=self.my_osid_object._proxy)
        else:
            item_query_session = mgr.get_item_query_session(proxy=self.my_osid_object._proxy)
        item_query_session.use_federated_bank_view()
        item_query = item_query_session.get_item_query()
        for objective_id_str in self.my_osid_object._my_map['learningObjectiveIds']:
            item_query.match_learning_objective_id(Id(objective_id_str), True)
        item_list = list(item_query_session.get_items_by_query(item_query))
        # Let's query all takens and their children sections for questions, to
        # remove seen ones
        taking_agent_id = self._assessment_section._assessment_taken.taking_agent_id
        atqs = mgr.get_assessment_taken_query_session(proxy=self.my_osid_object._proxy)
        atqs.use_federated_bank_view()
        querier = atqs.get_assessment_taken_query()
        querier.match_taking_agent_id(taking_agent_id, match=True)
        # let's seed this with the current section's questions
        seen_items = [item_id for item_id in self._assessment_section._item_id_list]
        taken_ids = [str(t.ident)
                     for t in atqs.get_assessments_taken_by_query(querier)]
        # Try to find the questions directly via Mongo query -- don't do
        # for section in taken._get_assessment_sections():
        #     seen_items += [question['itemId'] for question in section._my_map['questions']]
        # because standing up all the sections is wasteful
        collection = JSONClientValidated('assessment',
                                         collection='AssessmentSection',
                                         runtime=self.my_osid_object._runtime)
        results = collection.find({"assessmentTakenId": {"$in": taken_ids}})
        for section in results:
            if 'questions' in section:
                seen_items += [question['itemId'] for question in section['questions']]
        unseen_item_id = None
        # need to randomly shuffle this item_list
        shuffle(item_list)
        for item in item_list:
            if str(item.ident) not in seen_items:
                unseen_item_id = item.get_id()
                break
        if unseen_item_id is not None:
            self.my_osid_object._my_map['itemIds'] = [str(unseen_item_id)]
        elif self.my_osid_object._my_map['allowRepeatItems']:
            if len(item_list) > 0:
                self.my_osid_object._my_map['itemIds'] = [str(item_list[0].ident)]
            else:
                self.my_osid_object._my_map['itemIds'] = []  # don't put '' here, it will break when it tries to find an item with id ''
        else:
            self.my_osid_object._my_map['itemIds'] = []
110010
def do_GET(self):
        """"""
        f = self.send_head()
        if f:
            self.copyfile(f, self.wfile)
            f.close()
267816
def get_payload(self, *args, **kwargs):
        """"""
        if not kwargs:
            kwargs = self.default_params
        else:
            kwargs.update(self.default_params)
        for item in args:
            if isinstance(item, dict):
                kwargs.update(item)
        if hasattr(self, 'type_params'):
            kwargs.update(self.type_params(*args, **kwargs))
        return kwargs
1200841
def take(self, obj):
        """"""
        cached = self._thread_local.cache[self._get_cache_key(obj)]
        build_kwargs = {}

        if 'model' in cached and 'pks' in cached:
            build_kwargs['queryset'] = cached['model'].objects.filter(pk__in=cached['pks'])

        elif 'obj' in cached:
            if cached['obj'].__class__.objects.filter(pk=cached['obj'].pk).exists():
                build_kwargs['obj'] = cached['obj']
            else:
                # Object was deleted in the meantime.
                build_kwargs['queryset'] = cached['obj'].__class__.objects.none()

        self._clean_cache(obj)

        return build_kwargs
404965
def optimize(self, angles0, target):
        """"""
        def new_objective(angles):
            a = angles - angles0
            if isinstance(self.smooth_factor, (np.ndarray, list)):
                if len(a) == len(self.smooth_factor):
                    return (self.f(angles, target) +
                            np.sum(self.smooth_factor * np.power(a, 2)))
                else:
                    raise ValueError('len(smooth_factor) != number of joints')
            else:
                return (self.f(angles, target) +
                        self.smooth_factor * np.sum(np.power(a, 2)))

        return scipy.optimize.minimize(
            new_objective,
            angles0,
            **self.optimizer_opt).x
958028
def objective_bounds(self):
        
        if self.ideal and self.nadir:
            return self.ideal, self.nadir
        raise NotImplementedError(
            "Ideal and nadir value calculation is not yet implemented"
        )
692653
def objective(self, params):
        """"""
        val = self._penalty * np.sum(params**2)
        for winner, losers in self._data:
            idx = np.append(winner, losers)
            val += logsumexp(params.take(idx) - params[winner])
        return val
782111
def get_objective_banks(self):
        """"""
        # Implemented from kitosid template for -
        # osid.resource.BinLookupSession.get_bins_template
        catalogs = self._get_provider_session('objective_bank_lookup_session').get_objective_banks()
        cat_list = []
        for cat in catalogs:
            cat_list.append(ObjectiveBank(self._provider_manager, cat, self._runtime, self._proxy))
        return ObjectiveBankList(cat_list)