11from PEPit .point import Point
22
33
4- def exact_linesearch_step (x0 , f , directions ):
4+ def exact_linesearch_step (x0 , f , directions , name = 'new_x' ):
55 """
66 This routine outputs some :math:`x` by *mimicking* an exact line/span search in specified directions.
77 It is used for instance in ``PEPit.examples.unconstrained_convex_minimization.wc_gradient_exact_line_search``
@@ -63,6 +63,7 @@ def exact_linesearch_step(x0, f, directions):
6363 x0 (Point): the starting point.
6464 f (Function): the function on which the (sub)gradient will be evaluated.
6565 directions (List of Points): the list of all directions required to be orthogonal to the (sub)gradient of x.
66+ name (Str): the name of the point we arrive to.
6667
6768 Returns:
6869 x (Point): such that all vectors in directions are orthogonal to the (sub)gradient of f at x.
@@ -72,18 +73,18 @@ def exact_linesearch_step(x0, f, directions):
7273 """
7374
7475 # Instantiate a Point
75- x = Point ()
76+ x = Point (name = name )
7677
7778 # Define gradient and function value of f on x
7879 gx , fx = f .oracle (x )
7980
8081 # Add constraints
8182 constraint = ((x - x0 ) * gx == 0 )
82- constraint .set_name ("exact_linesearch({})_on_{} " .format (f .get_name (), x0 .get_name ()))
83+ constraint .set_name ("exact_linesearch({})_to_{}_from_{} " .format (f . get_name (), x .get_name (), x0 .get_name ()))
8384 f .add_constraint (constraint )
8485 for d in directions :
8586 constraint = (d * gx == 0 )
86- constraint .set_name ("exact_linesearch({})_on_{} _in_direction_{}" .format (f .get_name (), x0 .get_name (), d .get_name ()))
87+ constraint .set_name ("exact_linesearch({})_to_{}_from_{} _in_direction_{}" .format (f . get_name (), x .get_name (), x0 .get_name (), d .get_name ()))
8788 f .add_constraint (constraint )
8889
8990 # Return triplet of points
0 commit comments