Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
towr::SoftConstraint Class Reference

Converts a constraint to a cost by weighing the quadratic violations. More...

#include <soft_constraint.h>

Inheritance diagram for towr::SoftConstraint:
Inheritance graph
[legend]

Public Types

using ConstraintPtr = Component::Ptr
 

Public Member Functions

 SoftConstraint (const ConstraintPtr &constraint)
 Creates a soft constraint (=cost) from a hard constraint. More...
 
virtual ~SoftConstraint ()=default
 

Private Member Functions

virtual VecBound GetBounds () const overridefinal
 
virtual Jacobian GetJacobian () const override
 The row-vector of derivatives of the cost term. More...
 
virtual VectorXd GetValues () const override
 average value of each upper and lower bound. More...
 
virtual void SetVariables (const VectorXd &x) overridefinal
 

Private Attributes

VectorXd b_
 
ConstraintPtr constraint_
 
VectorXd W_
 weights how each constraint violation contributes to the cost. More...
 

Detailed Description

Converts a constraint to a cost by weighing the quadratic violations.

Let constraint g(x) R^m with upper bound b_u and lower bound b_l. Let g'(x) = g(x) - 0.5(b_u+b_l) = g(x) - b And it's derivative dg'(x)/dx = J(x). Define a cost as c(x) = 0.5 * g'^T * W * g', where W = diag(w1,...,wm). Then the gradient of the cost is defined as: dc(x)/dx = (g'(x)^T * W * J)^T = J^T * W * (g(x)-b).

Definition at line 47 of file soft_constraint.h.

Member Typedef Documentation

using towr::SoftConstraint::ConstraintPtr = Component::Ptr

Definition at line 49 of file soft_constraint.h.

Constructor & Destructor Documentation

towr::SoftConstraint::SoftConstraint ( const ConstraintPtr constraint)

Creates a soft constraint (=cost) from a hard constraint.

Parameters
constraintThe fully initialized constraint.

Weights are set to identity, so each constraint violation contributes equally to the cost.

Definition at line 34 of file soft_constraint.cc.

virtual towr::SoftConstraint::~SoftConstraint ( )
virtualdefault

Member Function Documentation

virtual VecBound towr::SoftConstraint::GetBounds ( ) const
inlinefinaloverrideprivatevirtual

Definition at line 81 of file soft_constraint.h.

SoftConstraint::Jacobian towr::SoftConstraint::GetJacobian ( ) const
overrideprivatevirtual

The row-vector of derivatives of the cost term.

dc(x)/dx = J^T * W * (g-b)

Definition at line 61 of file soft_constraint.cc.

SoftConstraint::VectorXd towr::SoftConstraint::GetValues ( ) const
overrideprivatevirtual

average value of each upper and lower bound.

The quadratic constraint violation transformed to a cost.

c(x) = 0.5 * (g-b)^T * W * (g-b)

Definition at line 53 of file soft_constraint.cc.

virtual void towr::SoftConstraint::SetVariables ( const VectorXd x)
inlinefinaloverrideprivatevirtual

Definition at line 82 of file soft_constraint.h.

Member Data Documentation

VectorXd towr::SoftConstraint::b_
private

Definition at line 64 of file soft_constraint.h.

ConstraintPtr towr::SoftConstraint::constraint_
private

Definition at line 62 of file soft_constraint.h.

VectorXd towr::SoftConstraint::W_
private

weights how each constraint violation contributes to the cost.

Definition at line 63 of file soft_constraint.h.


The documentation for this class was generated from the following files:


towr_core
Author(s): Alexander W. Winkler
autogenerated on Sun Apr 8 2018 02:18:53