def _line_opt(self):
direction = self.search_direction.direction<EOL>if self.constraints is not None:<EOL><INDENT>try:<EOL><INDENT>direction = self.constraints.project(self.x, direction)<EOL><DEDENT>except ConstraintError:<EOL><INDENT>self._screen("<STR_LIT>", newline=True)<EOL>return False<EOL><DEDENT><DEDENT>direction_norm = np.linalg.norm(direction)<EOL>if direction_norm == <NUM_LIT:0>:<EOL><INDENT>return False<EOL><DEDENT>self.line.configure(self.x, direction/direction_norm)<EOL>success, wolfe, qopt, fopt =self.line_search(self.line, self.initial_step_size, self.epsilon)<EOL>if success:<EOL><INDENT>self.step = qopt*self.line.axis<EOL>self.initial_step_size = np.linalg.norm(self.step)<EOL>self.x = self.x + self.step<EOL>self.f = fopt<EOL>if wolfe:<EOL><INDENT>self._screen("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>self._screen("<STR_LIT:U+0020>")<EOL>self.search_direction.reset()<EOL><DEDENT>return True<EOL><DEDENT>else:<EOL><INDENT>if self.debug_line:<EOL><INDENT>import matplotlib.pyplot as pt<EOL>import datetime<EOL>pt.clf()<EOL>qs = np.arange(<NUM_LIT:0.0>, <NUM_LIT>)*(<NUM_LIT:5>*self.initial_step_size/<NUM_LIT>)<EOL>fs = np.array([self.line(q) for q in qs])<EOL>pt.plot(qs, fs)<EOL>pt.xlim(qs[<NUM_LIT:0>], qs[-<NUM_LIT:1>])<EOL>fdelta = fs.max() - fs.min()<EOL>if fdelta == <NUM_LIT:0.0>:<EOL><INDENT>fdelta = fs.mean()<EOL><DEDENT>fmargin = fdelta*<NUM_LIT:0.1><EOL>pt.ylim(fs.min() - fmargin, fs.max() + fmargin)<EOL>pt.title('<STR_LIT>' % (fdelta, fs.mean()))<EOL>pt.xlabel('<STR_LIT>')<EOL>pt.ylabel('<STR_LIT>')<EOL>pt.savefig('<STR_LIT>' % (datetime.datetime.now().isoformat()))<EOL><DEDENT>self._reset_state()<EOL>return False<EOL><DEDENT>
Perform a line search along the current direction