FunctionalConstraint

class FunctionalConstraint(validNames: List<String>, val lhsFunc: ConstraintFunctionIfc, val rhsValue: Double = 0.0, val inequalityType: InequalityType = InequalityType.LESS_THAN) : ConstraintIfc

Represents a functional constraint in an optimization problem.

This class models a constraint where the left-hand side is computed using a user-defined function and is compared to a predefined right-hand side value using an inequality (less than or greater than).

The valid variable names are defined at the time of initialization, and the left-hand side function is applied to input values to compute the constraint's value.

Parameters

validNames

the input variable names that are valid for the function. The list must not be empty and must contain non-blank strings.

Constructors

Link copied to clipboard
constructor(validNames: List<String>, lhsFunc: ConstraintFunctionIfc, rhsValue: Double = 0.0, inequalityType: InequalityType = InequalityType.LESS_THAN)

Properties

Link copied to clipboard

Used to turn greater than inequalities to less than inequalities

Link copied to clipboard
open override val inequalityType: InequalityType

The type of inequality (LESS_THAN or GREATER_THAN). Defaults to LESS_THAN.

Link copied to clipboard

The function used to compute the left-hand side of the equation.

Link copied to clipboard
open val ltRHSValue: Double

The right-hand side of the constraint adjusted for the direction of the inequality to ensure a less-than constraint

Link copied to clipboard
open override val rhsValue: Double = 0.0

The right-hand side value of the constraint. Defaults to 0.0.

Link copied to clipboard

Functions

Link copied to clipboard
open override fun computeLHS(values: Map<String, Double>): Double

Computes the value of the left-hand side of the constraint based on the supplied values for each input variable in the equation.

Link copied to clipboard
open override fun isSatisfied(values: Map<String, Double>): Boolean

Computes the value of the left-hand side of the constraint based on the supplied values for each input variable in the equation and checks if the constraint is satisfied.

Link copied to clipboard
open fun slack(inputs: Map<String, Double>): Double

The slack associated with the constraint based on the provided inputs. This is the difference between the right-hand side value and the left-hand side value.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open fun violation(inputs: Map<String, Double>): Double