def set_objective(self, objective, extraobjexpr=None):
if objective is not None:<EOL><INDENT>facvar =self._get_facvar(simplify_polynomial(objective,<EOL>self.substitutions))<EOL>self.obj_facvar = facvar[<NUM_LIT:1>:]<EOL>self.constant_term = facvar[<NUM_LIT:0>]<EOL>if self.verbose > <NUM_LIT:0> and facvar[<NUM_LIT:0>] != <NUM_LIT:0>:<EOL><INDENT>print("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>% facvar[<NUM_LIT:0>], file=sys.stderr)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.obj_facvar = self._get_facvar(<NUM_LIT:0>)[<NUM_LIT:1>:]<EOL><DEDENT>if extraobjexpr is not None:<EOL><INDENT>for sub_expr in extraobjexpr.split('<STR_LIT:]>'):<EOL><INDENT>startindex = <NUM_LIT:0><EOL>if sub_expr.startswith('<STR_LIT:->') or sub_expr.startswith('<STR_LIT:+>'):<EOL><INDENT>startindex = <NUM_LIT:1><EOL><DEDENT>ind = sub_expr.find('<STR_LIT:[>')<EOL>if ind > -<NUM_LIT:1>:<EOL><INDENT>idx = sub_expr[ind+<NUM_LIT:1>:].split("<STR_LIT:U+002C>")<EOL>i, j = int(idx[<NUM_LIT:0>]), int(idx[<NUM_LIT:1>])<EOL>mm_ind = int(sub_expr[startindex:ind])<EOL>if sub_expr.find('<STR_LIT:*>') > -<NUM_LIT:1>:<EOL><INDENT>value = float(sub_expr[:sub_expr.find('<STR_LIT:*>')])<EOL><DEDENT>elif sub_expr.startswith('<STR_LIT:->'):<EOL><INDENT>value = -<NUM_LIT:1.0><EOL><DEDENT>else:<EOL><INDENT>value = <NUM_LIT:1.0><EOL><DEDENT>base_row_offset = sum([bs**<NUM_LIT:2> for bs in<EOL>self.block_struct[:mm_ind]])<EOL>width = self.block_struct[mm_ind]<EOL>for column in self.F[base_row_offset + i*width + j].rows[<NUM_LIT:0>]:<EOL><INDENT>self.obj_facvar[column-<NUM_LIT:1>] =value*self.F[base_row_offset + i*width + j, column]<EOL><DEDENT><DEDENT><DEDENT><DEDENT>
Set or change the objective function of the polynomial optimization
        problem.

        :param objective: Describes the objective function.
        :type objective: :class:`sympy.core.expr.Expr`
        :param extraobjexpr: Optional parameter of a string expression of a
                             linear combination of moment matrix elements to be
                             included in the objective function
        :type extraobjexpr: str.