# Path: tensorflow_constrained_optimization/python/graph_and_eager_test_case.py
# class _EagerPlaceholder(object):
# class _GraphWrappedSession(object):
# class _EagerWrappedSession(object):
# class GraphAndEagerTestCase(tf.test.TestCase):
#   def __init__(self):
#   def set(self, tensor):
#   def __call__(self):
#   def __init__(self, session):
#   def __enter__(self):
#   def __exit__(self, exc_type, exc_value, traceback):
#   def run(self, tensor, feed_dict=None):
#   def run_ops(self, callback, feed_dict=None):
#   def __init__(self):
#   def __enter__(self):
#   def __exit__(self, exc_type, exc_value, traceback):
#   def run(self, tensor, feed_dict=None):
#   def run_ops(self, callback, feed_dict=None):
#   def wrapped_placeholder(self, dtype, shape=None, name=None):
#   def wrapped_session(self):
# 
# Path: tensorflow_constrained_optimization/python/train/lagrangian_optimizer.py
# def _project_multipliers_wrt_euclidean_norm(multipliers, radius):
#   def while_loop_condition(iteration, multipliers, inactive, old_inactive):
#   def while_loop_body(iteration, multipliers, inactive, old_inactive):
#   def __init__(self,
#                maximum_multiplier_radius=None,
#                dual_scale=1.0,
#                variable_fn=tf.Variable):
#   def state(self):
#   def _project_multipliers(self, multipliers):
#   def create_state(self, num_constraints):
#   def is_state_created(self):
#   def get_loss_fn(self, minimization_problem):
#       def loss_gradient_fn(objective, constraints, proxy_constraints,
#                            multipliers):
#         def gradient_fn(output_gradient):
#       def partial_loss_gradient_fn():
#       def loss_gradient_fn(objective):
# def create_lagrangian_loss(minimization_problem,
#                            maximum_multiplier_radius=None,
#                            dual_scale=1.0,
#                            variable_fn=tf.Variable):
#   def __init__(self,
#                optimizer,
#                num_constraints=None,
#                constraint_optimizer=None,
#                maximum_multiplier_radius=None,
#                name="LagrangianOptimizerV1"):
#   def __init__(self,
#                optimizer,
#                num_constraints=None,
#                constraint_optimizer=None,
#                maximum_multiplier_radius=None,
#                name="LagrangianOptimizerV2"):
# class _LagrangianFormulation(constrained_optimizer.Formulation):
# class LagrangianOptimizerV1(constrained_optimizer.ConstrainedOptimizerV1):
# class LagrangianOptimizerV2(constrained_optimizer.ConstrainedOptimizerV2):
# 
# Path: tensorflow_constrained_optimization/python/train/test_util.py
# class ConstantMinimizationProblem(
#     constrained_minimization_problem.ConstrainedMinimizationProblem):
#   def __init__(self, constraints):
#   def objective(self):
#   def num_constraints(self):
#   def constraints(self):
#   def variables(self):


import numpy as np
import tensorflow as tf
from tensorflow_constrained_optimization.python import graph_and_eager_test_case
from tensorflow_constrained_optimization.python.train import lagrangian_optimizer
from tensorflow_constrained_optimization.python.train import test_util
                   maximum_multiplier_radius=None):
    self._loss_test_helper(
        minimization_problem,
        expected_multipliers,
        maximum_multiplier_radius=maximum_multiplier_radius)
    self._optimizer_v1_test_helper(
        minimization_problem,
        expected_multipliers,
        maximum_multiplier_radius=maximum_multiplier_radius)
    self._optimizer_v2_test_helper(
        minimization_problem,
        expected_multipliers,
        maximum_multiplier_radius=maximum_multiplier_radius)

  def test_project_multipliers_wrt_euclidean_norm(self):
    """Tests Euclidean projection routine on some known values."""
    multipliers1 = tf.constant([-0.1, -0.6, -0.3])
    expected_projected_multipliers1 = np.array([0.0, 0.0, 0.0])

    multipliers2 = tf.constant([-0.1, 0.6, 0.3])
    expected_projected_multipliers2 = np.array([0.0, 0.6, 0.3])

    multipliers3 = tf.constant([0.4, 0.7, -0.2, 0.5, 0.1])
    expected_projected_multipliers3 = np.array([0.2, 0.5, 0.0, 0.3, 0.0])

    with self.wrapped_session() as session:
      projected_multipliers1 = session.run(
          lagrangian_optimizer._project_multipliers_wrt_euclidean_norm(
              multipliers1, 1.0))
      projected_multipliers2 = session.run(

# Path: tensorflow_constrained_optimization/python/graph_and_eager_test_case.py
# class _EagerPlaceholder(object):
# class _GraphWrappedSession(object):
# class _EagerWrappedSession(object):
# class GraphAndEagerTestCase(tf.test.TestCase):
#   def __init__(self):
#   def set(self, tensor):
#   def __call__(self):
#   def __init__(self, session):
#   def __enter__(self):
#   def __exit__(self, exc_type, exc_value, traceback):
#   def run(self, tensor, feed_dict=None):
#   def run_ops(self, callback, feed_dict=None):
#   def __init__(self):
#   def __enter__(self):
#   def __exit__(self, exc_type, exc_value, traceback):
#   def run(self, tensor, feed_dict=None):
#   def run_ops(self, callback, feed_dict=None):
#   def wrapped_placeholder(self, dtype, shape=None, name=None):
#   def wrapped_session(self):
# 
# Path: tensorflow_constrained_optimization/python/train/lagrangian_optimizer.py
# def _project_multipliers_wrt_euclidean_norm(multipliers, radius):
#   def while_loop_condition(iteration, multipliers, inactive, old_inactive):
#   def while_loop_body(iteration, multipliers, inactive, old_inactive):
#   def __init__(self,
#                maximum_multiplier_radius=None,
#                dual_scale=1.0,
#                variable_fn=tf.Variable):
#   def state(self):
#   def _project_multipliers(self, multipliers):
#   def create_state(self, num_constraints):
#   def is_state_created(self):
#   def get_loss_fn(self, minimization_problem):
#       def loss_gradient_fn(objective, constraints, proxy_constraints,
#                            multipliers):
#         def gradient_fn(output_gradient):
#       def partial_loss_gradient_fn():
#       def loss_gradient_fn(objective):
# def create_lagrangian_loss(minimization_problem,
#                            maximum_multiplier_radius=None,
#                            dual_scale=1.0,
#                            variable_fn=tf.Variable):
#   def __init__(self,
#                optimizer,
#                num_constraints=None,
#                constraint_optimizer=None,
#                maximum_multiplier_radius=None,
#                name="LagrangianOptimizerV1"):
#   def __init__(self,
#                optimizer,
#                num_constraints=None,
#                constraint_optimizer=None,
#                maximum_multiplier_radius=None,
#                name="LagrangianOptimizerV2"):
# class _LagrangianFormulation(constrained_optimizer.Formulation):
# class LagrangianOptimizerV1(constrained_optimizer.ConstrainedOptimizerV1):
# class LagrangianOptimizerV2(constrained_optimizer.ConstrainedOptimizerV2):
# 
# Path: tensorflow_constrained_optimization/python/train/test_util.py
# class ConstantMinimizationProblem(
#     constrained_minimization_problem.ConstrainedMinimizationProblem):
#   def __init__(self, constraints):
#   def objective(self):
#   def num_constraints(self):
#   def constraints(self):
#   def variables(self):


# Path: tensorflow_constrained_optimization/python/train/lagrangian_optimizer_test.py
import numpy as np
import tensorflow as tf
from tensorflow_constrained_optimization.python import graph_and_eager_test_case
from tensorflow_constrained_optimization.python.train import lagrangian_optimizer
from tensorflow_constrained_optimization.python.train import test_util

                   maximum_multiplier_radius=None):
    self._loss_test_helper(
        minimization_problem,
        expected_multipliers,
        maximum_multiplier_radius=maximum_multiplier_radius)
    self._optimizer_v1_test_helper(
        minimization_problem,
        expected_multipliers,
        maximum_multiplier_radius=maximum_multiplier_radius)
    self._optimizer_v2_test_helper(
        minimization_problem,
        expected_multipliers,
        maximum_multiplier_radius=maximum_multiplier_radius)

  def test_project_multipliers_wrt_euclidean_norm(self):
    """Tests Euclidean projection routine on some known values."""
    multipliers1 = tf.constant([-0.1, -0.6, -0.3])
    expected_projected_multipliers1 = np.array([0.0, 0.0, 0.0])

    multipliers2 = tf.constant([-0.1, 0.6, 0.3])
    expected_projected_multipliers2 = np.array([0.0, 0.6, 0.3])

    multipliers3 = tf.constant([0.4, 0.7, -0.2, 0.5, 0.1])
    expected_projected_multipliers3 = np.array([0.2, 0.5, 0.0, 0.3, 0.0])

    with self.wrapped_session() as session:
      projected_multipliers1 = session.run(
          lagrangian_optimizer._project_multipliers_wrt_euclidean_norm(
              multipliers1, 1.0))
      projected_multipliers2 = session.run(

          lagrangian_optimizer._project_multipliers_wrt_euclidean_norm(