Source-linked AI summary

OptLayer - Practical Constrained Optimization for Deep Reinforcement Learning in the Real World

Tu-Hoa Pham, Giovanni De Magistris, Ryuki Tachibana

arXiv:1709.07643v2cs.ROcs.AI

TL;DR

Real-world reinforcement learning is difficult because unconstrained trial-and-error can produce unsafe robot behavior, and safe policies are sensitive to reward design. The paper introduces OptLayer to project neural-network actions onto constraint-satisfying actions while penalizing unsafe predictions, demonstrating the approach in simulated and real-world reaching. The authors conclude that constrained optimization can couple efficiently with stochastic control policies, although training from scratch and formalizing constraints remain difficult.

  • Problem

    Safe reinforcement learning for robotics must address unsafe exploration and the sensitivity of learned safety to reward and cost design.

  • Method

    OptLayer adds a fully differentiable constrained optimization layer that enforces arbitrary constraints on predicted robot actions and supports a compatible reward strategy.

  • Results

    The approach demonstrated 3D reaching with collision avoidance on an industrial manipulator in simulation and the real world, while real-world experiments accommodated reasonable environmental and task changes without dedicated training.

  • Takeaways & Limitations

    Constrained optimization can be coupled with stochastic control policies for real-world reinforcement learning where safety is crucial.

  • Takeaways & Limitations

    Learning control policies from scratch may remain too time-consuming, and formalizing safety constraints can be difficult under dynamic model uncertainties or dependence on perception accuracy.

Abstract

from arXiv · show

While deep reinforcement learning techniques have recently produced considerable achievements on many decision-making problems, their use in robotics has largely been limited to simulated worlds or restricted motions, since unconstrained trial-and-error interactions in the real world can have undesirable consequences for the robot or its environment. To overcome such limitations, we propose a novel reinforcement learning architecture, OptLayer, that takes as inputs possibly unsafe actions predicted by a neural network and outputs the closest actions that satisfy chosen constraints. While learning control policies often requires carefully crafted rewards and penalties while exploring the range of possible actions, OptLayer ensures that only safe actions are actually executed and unsafe predictions are penalized during training. We demonstrate the effectiveness of our approach on robot reaching tasks, both simulated and in the real world.

I. INTRODUCTION

The paper targets safe real-world reinforcement learning by constraining robot actions during exploration and execution. It introduces OptLayer, a differentiable optimization layer paired with a reward strategy, and evaluates the approach on simulated and real-world reaching with collision avoidance.

  • OptLayer enforces arbitrary safety constraints on neural-network-predicted robot actions through a fully differentiable optimization layer.
  • The method adds a simple reward strategy compatible with existing policy-optimization techniques.
  • The approach is demonstrated on 3D reaching with collision avoidance for an industrial manipulator in simulation and the real world.
  • Robot-control optimization can produce unsatisfactory policies when models are uncertain, constraints are overly conservative, or task dynamics are difficult to model.
  • Real-world reinforcement learning requires safe exploration during training and safe execution at inference time.
  • Unconstrained reinforcement learning can involve unsafe actions and is highly sensitive to the reward and cost structure.

A. Reinforcement Learning Nomenclature

The paper formulates reinforcement learning through trajectories, value functions, and parameterized policies, then situates its method within TRPO-based policy optimization. The illustrated reacher setting uses target distance and collision-penalty terms in its reward description.

  • An infinite-horizon discounted Markov Decision Process is defined by states, actions, transitions, rewards, initial-state probabilities, and a discount factor.
  • A trajectory consists of alternating states and actions, with actions sampled from the policy and subsequent states sampled from the transition distribution.
  • Qπ, Vπ, and Aπ denote the state-action value, value, and advantage functions, respectively.
  • TRPO iteratively refines a parameterized policy by solving a constrained optimization problem using sampled state-action trajectories.
  • The 2D reacher reward description includes target distance and a collision-penalty coefficient βcoll ∈{1, 5, 10, 50}.

B. Motivating Example

The 2-DoF reaching task tests how collision penalties affect reinforcement-learning behavior in an obstacle-avoidance setting. Results show that reward design creates a trade-off between collision avoidance and exploration, motivating explicit safety constraints.

  • Environment: The 2-DoF robot must reach randomly sampled targets while avoiding a spherical obstacle in a planar environment.Episodes run for up to 200 steps with 0.01-second intervals, and actions specify joint-position increments.
  • Reward structure: The environment rewards target proximity and penalizes collisions, with collision penalties parameterized by βcoll ∈ {1, 5, 10, 50}.The implementation monitors both external and self-collisions while neural-network policies interact with the environment.
  • Results: Reward evolution depends strongly on the collision-penalty weight.The comparison averages behavior across the tested penalty settings during training.
  • Results: With βcoll = 1, collision avoidance is never learned because the penalty rcoll = −20 is outweighed by reaching and proximity incentives.The resulting strategy may hit the obstacle to restart the episode and obtain proximity reward.
  • Results: With βcoll = 50, the penalty rcoll = −1000 reduces collisions but discourages exploration, leading the policy to remain near the start pose.The policy ignores further targets under this large penalty.
  • Results: βcoll = 5 and 10 yield comparable rewards, but βcoll = 10 produces half the number of collisions.These results underscore the sensitivity of learned behavior to reward construction and the difficulty of learning safety without violations.

IV. CONSTRAINED OPTIMIZATION LAYER

OptLayer formulates action correction as a constrained quadratic program that projects neural-network predictions onto the set of safe actions. Its objective and constraints are made differentiable so the layer can participate in end-to-end training.

  • Optimization formulation: The quadratic program minimizes 1/2 x^T P x + q^T x subject to linear constraints.P and q define the objective, while G, h, A, and b define inequality and equality constraints.
  • Pipeline: The architecture is presented as a constrained optimization pipeline for enforcing safety constraints on predicted robot actions.The paper also describes the layer as fully differentiable and applicable to arbitrary action constraints.
  • Optimization formulation: OptLayer seeks an action closest to the neural network’s prediction while satisfying linear equality and inequality constraints.The optimization uses a quadratic objective over action variables and constraints represented by matrix-vector systems.
  • Differentiability: The objective and constraint matrices are differentiable expressions of the current state s_i and predicted action eai.This construction supports backward-pass gradients required for end-to-end neural-network training.
  • Constraint representation: OptLayer accommodates robotic constraints that are constant, affine in state, auxiliary-variable dependent, or conditionally active.The exposition focuses on inequalities, while equality constraints are treated analogously.

1) Objective matrices:

The objective matrix is constructed by expressing the distance between the optimized action and the neural-network prediction as a quadratic program. This yields an identity quadratic matrix and a linear term determined by the prediction.

  • Objective matrices: The optimization objective measures squared L2 distance between variables x and the predicted action eai.The objective keeps the corrected action close to the neural network’s output.
  • Objective matrices: Because eai does not depend on x, its constant quadratic term does not affect the optimum.The objective can therefore be written in the standard quadratic-program form with P = I_nx and q = −eai.
  • Constraint construction: Joint-velocity limits become linear inequalities on the action hypothesis x = Δθi after approximating velocity by Δθi/ΔT.The resulting constraints use manufacturer-specified lower and upper velocity limits.
  • Constraint construction: For joint-velocity limits, the constant constraint matrices are Gcst = [I_nx, −I_nx]^T and hcst = [ΔT θ̇max, −ΔT θ̇min]^T.These matrices remain constant throughout the robot’s motion.

3) Constraint matrices affine in the state vector:

The paper constructs state-dependent constraint matrices for joint positions and torques by expressing action limits through current states and auxiliary dynamics quantities.

  • Joint-position limits depend on the current joint positions because the next position is θ_i+1 = θ_i + x.
  • A selection matrix Hθ extracts joint-position terms from state s_i, making the corresponding bounds affine in the state.
  • Torque constraints use robot dynamics, with H(q) as the mass matrix and C(q, ˙q) as the bias vector of Coriolis, centrifugal, and gravitational forces.
  • The first six rows of the dynamics equation compute base forces, while rows indexed 7 and onward provide Hτ(q) and Cτ(q, ˙q) for joint torques.
  • Forward differences express velocity and acceleration through action x, making τ_i affine in x after combining the dynamics equations.
  • Because Hτ and Cτ are not simple functions of s_i, the environment computes them and appends their elements to the state for constraint construction.

5) Conditional constraint matrices:

Conditional constraints are activated only when state-dependent conditions hold, allowing collision avoidance requirements to enter the optimization selectively.

  • Collision-avoidance constraints activate when a robot link’s distance d_l from the environment falls below the influence distance d_M.
  • The safety constraint limits how quickly d_l may decrease and requires d_l to increase strictly below the security distance d_m.
  • The state is extended with J(q,p_l)^T n_l and d_l so conditional constraint matrices and their activation test can be formed from s_i.
  • The activation condition depends only on state s_i, before the action x is optimized.

C. Quadratic Program Solving

OptLayer assembles always-active and conditional constraints into quadratic programs, solves them with a differentiable interior-point procedure, and outputs the feasible action closest to the network prediction.

  • Assembling constraint matrices for batch solving: Always-active matrices are concatenated into G_base and h_base, while conditional matrices are appended only when their activation condition holds.
  • Assembling constraint matrices for batch solving: Fixed-size G and h matrices enable batch solving by substituting base submatrices when conditional constraints are inactive.
  • Quadratic Program Solving: The implementation solves quadratic programs with an interior-point method using objective and constraint matrices P, q, G, h, A, and b.
  • Iterative resolution: BUILDTRAJ records states, predictions, rewards, values, corrected actions, and violation costs while OptLayer constrains each predicted action.
  • Quadratic Program Solving: The solver iteratively updates primal, slack, and dual variables, using a constant k_max = 10 for batch solving because typical problems converge in about 5 iterations.
  • Quadratic Program Solving: The final output is the action a* closest to the initial prediction ea that satisfies all safety constraints.

V. CONSTRAINED REINFORCEMENT LEARNING

The constrained reinforcement-learning procedure executes OptLayer-corrected actions, quantifies violations of raw predictions, and uses those costs during training without executing unsafe actions.

  • Trajectory Sampling: OptLayer produces corrected actions a* for execution while retaining raw predictions ea to measure constraint violations.
  • Trajectory Sampling: Equality and inequality violation costs quantify how much each unconstrained prediction violates the corresponding constraints.
  • Trajectory Sampling: The total violation cost c = c_eq + c_in combines normalized equality and inequality contributions computed within OptLayer.
  • Trajectory Sampling: BUILDTRAJ outputs states, raw predictions, rewards, values, corrected actions, and constraint violation costs for constrained or unconstrained execution modes.

B. Policy Update Strategies

The paper evaluates four policy-update strategies that differ in whether they train on unconstrained predictions, corrected actions, or both. These strategies are applied to OptLayer-based 3D reaching with a 6-DoF manipulator in simulation and real-world settings.

  • Policy update strategies: The four strategies are Unconstrained Predictions (UP), Constrained-learn Predictions (CP), Constrained-learn Corrections (CC), and Constrained-learn Predictions and Corrections (CPC).CP trains on raw predictions after constrained execution; CC trains on corrected actions; CPC trains on both raw predictions with discounted rewards and corrected actions with original rewards.
  • Policy update strategies: CPC first associates raw predictions with discounted rewards and then associates corrected actions with better rewards.This combines learning from the network’s original predictions with learning from the safe actions produced by OptLayer.
  • Policy update strategies: CP treats OptLayer as part of the environment from the network’s perspective by updating the policy with raw predicted actions.The network is trained using raw predictions rather than corrected actions.
  • Policy update strategies: CC trains directly on corrected actions, which can differ substantially from the neural network’s initial predictions.The paper attributes this distinction to the relationship between corrected actions and the stochastic policy being optimized.
  • Experimental setting: The experiments apply these strategies to 3D reaching with a 6-DoF industrial manipulator in both simulation and the real world.The setup uses an industrial manipulator equipped with a force-torque sensor and gripper; the task includes a target and obstacle.

B. Evaluating Policy Update Strategies

The evaluation compares unconstrained and constrained policy updates on simulated and real-world 3D reaching. OptLayer prevents collisions, while CPC reaches high reward in fewer simulated episodes and transfers to changing real-world conditions without dedicated training.

  • Simulation: 700 average reward is reached in 5350 episodes by UP, 4950 by CP, and 3250 by CPC.The comparison comes from training over 7000 episodes on the simulated 3D reaching task.
  • Simulation: OptLayer ensures that collisions never happen for UP, CP, CC, and CPC during constrained training, whereas unconstrained training does not effectively learn collision avoidance.UP can learn to reach but still collides; CP achieves rewards comparable to UP while maintaining safety.
  • Simulation: CPC reaches performance comparable to UP and CP with fewer episodes than either strategy.The paper attributes CPC’s faster learning to first training on raw predictions with discounted rewards before training on corrected actions.
  • Real-world experiments: On the real robot, CPC reaches a target while avoiding a balloon, unlike the unconstrained UP policy, which reaches the target but knocks the balloon down.The real-world setup also tests moving targets and moving obstacles.
  • Real-world experiments: A CPC policy trained for a specific task follows a moving target without hitting the obstacle and moves away when a moving obstacle approaches.These tests illustrate behavior under changing target and obstacle conditions without dedicated training for the moving-target task.
  • Real-world experiments: The authors report that the system accommodates reasonable changes in environment and task conditions without dedicated training.The paper presents this as a result of the real-world robot experiments.
  • Limitations: Learning control policies from scratch may remain too time-consuming even for simple tasks.The authors identify this as a current implementation limitation and propose investigating robotics-specific action-space exploration.
Loading 1709.07643v2…