Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

InequalityPenaltyFunction

Overview

InequalityPenaltyFunction provides the scalar ramp-like mapping used to turn inequality violations into smooth optimization penalties.

Open In Colab

Key Concepts

  • RampFunction implements the exact ramp max(x,0) behavior.

  • SmoothRampPoly2 and SmoothRampPoly3 provide polynomial smooth approximations near the boundary.

  • SoftPlusFunction provides a smooth log-exp approximation.

  • These functions influence solver behavior near active inequality constraints.

Mathematical Formulation

These functions shape how inequality violations are penalized by replacing r=max(g,0)r=\max(g,0) with either the exact ramp or a smooth approximation:

  • RampFunction: exact, non-smooth at 0.

  • SmoothRampPoly2, SmoothRampPoly3: polynomial smoothings near the boundary.

  • SoftPlusFunction: smooth log-exp form.

They are used inside inequality penalty factors to improve optimization behavior near active-set transitions.

Key User API

  • double operator()(double x, OptionalJacobian<1,1> H={})

  • function() to retrieve a callable functor

  • RampFunction::Ramp(x, H)

  • SmoothRampPoly2(epsilon), SmoothRampPoly3(epsilon)

  • SoftPlusFunction(k)

Concise C++ Example

#include <gtsam/constrained/InequalityPenaltyFunction.h>

using namespace gtsam;

SmoothRampPoly2 phi(2.0);
Matrix H;
double r = phi(1.0, H);  // smooth ramp value and derivative

SoftPlusFunction softPlus(0.5);
double rs = softPlus(2.0);