> ## Documentation Index
> Fetch the complete documentation index at: https://developer.synopsys.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OptConstraint Class

**Namespace:** `Phoenix.Optimization`

## Overview

Class to hold contraint information

## Inheritance

![OptConstraint](https://mintcdn.com/synopsys-00a47cbc/Srh1_f--TdKCLyqD/docs/modelcenter/modelcenter-custom-optimization-algorithm-sdk/2026-r1/api/graphics/class_phoenix_1_1_optimization_1_1_opt_constraint.png?fit=max\&auto=format\&n=Srh1_f--TdKCLyqD\&q=85\&s=6484561d097f7f5b3cebfb3b2e80b910)

## Declaration

```csharp theme={null}
class OptConstraint
```

## Description

Class to hold contraint information

## Public Member Functions

| Type | Name | Description |
| - | - | - |
| int | `Compare (double x, double y)` | Compares to values to see which violates the constraint worse. |
| override bool | `Equals (object obj)` | Determines whether the specified Object is equal to the current Object. |
| bool | `Equals (OptConstraint constraint)` | Determines whether the specified OptConstraint is equal to the current OptConstraint. |
| double | `GetConstraintViolation (double p)` | Given a particular value, returns an amount by which the constraint is violated. |
| override int | `GetHashCode ()` | Serves as a hash function for OptConstraint. |
| | `OptConstraint (OptConstraint constraint)` | Copy constructor to create a new constraint from an existing constraint |
| | `OptConstraint (string name, double lowerBound, double upperBound)` | Create a new constraint with the given name, lower and upper bound. |

## Properties

| Type | Name | Description |
| - | - | - |
| double | `LowerBound [get]` | Lower bound of the constraint or NaN if no lower bound exists. |
| string | `Name [get]` | Name of the constraint |
| double | `UpperBound [get]` | Upper bound of constraint or NaN if no upper bound exists. |

### Properties inherited from [IVariableName]()

| Type | Name | Description |
| - | - | - |
| string | `Name [get]` | The name of the variable |

## Constructor & Destructor Documentation

### OptConstraint()

```csharp theme={null}
OptConstraint ( OptConstraint constraint)
```

Copy constructor to create a new constraint from an existing constraint

**Parameters:**

* `constraint` - Constraint to be copied

### OptConstraint()

```csharp theme={null}
OptConstraint ( string name, double lowerBound, double upperBound )
```

Create a new constraint with the given name, lower and upper bound. At least one bound must be specified. If a bound is not specified, it should be set to NaN.

**Parameters:**

* `name` - Name of the constraint.
* `lowerBound` - Lower bound of the constraint, or NaN if no lower constraint.
* `upperBound` - Upper bound of the constraint, or NaN if no upper constraint.

## Member Function Documentation

### Compare

```csharp theme={null}
int Compare ( double x, double y )
```

Compares to values to see which violates the constraint worse.

**Parameters:**

* `x` - Test value 1
* `y` - Test value 2

**Returns:** -1 if x violates less, 0 if they violate the same, 1 if x violates it more

### Equals

```csharp theme={null}
override bool Equals ( object obj)
```

Determines whether the specified Object is equal to the current Object.

**Parameters:**

* `obj` - The object to compare with the current object.

**Returns:**

* true if the specified Object is equal to the current Object; otherwise, false.

### Equals

```csharp theme={null}
bool Equals ( OptConstraint constraint)
```

Determines whether the specified OptConstraint is equal to the current OptConstraint.

**Parameters:**

* `constraint` - The OptConstraint object to compare with the current OptConstraint.

**Returns:**

* true if the specified OptConstraint is equal to the current OptConstraint; otherwise, false.

### GetConstraintViolation

```csharp theme={null}
double GetConstraintViolation ( double p)
```

Given a particular value, returns an amount by which the constraint is violated. If the constraint is not violated, returns 0. If it is violated, always returns a positive value.

**Parameters:**

* `p` - The value to test

**Returns:**

* The value of the constraint violation

### GetHashCode

```csharp theme={null}
override int GetHashCode ( )
```

Serves as a hash function for OptConstraint.

**Returns:**

* A hash code for the current OptConstraint.

### operator!=

```csharp theme={null}
static bool operator!= ( OptConstraint a, OptConstraint b )
```

Determines whether the specified OptConstraint instances are considered not equal.

**Parameters:**

* `a` - The first OptConstraint to compare.
* `b` - The second OptConstraint to compare.

**Returns:**

* true if the OptConstraints are not considered equal; otherwise, false.

### operator==

```csharp theme={null}
static bool operator== ( OptConstraint a, OptConstraint b )
```

Determines whether the specified OptConstraint instances are considered equal.

**Parameters:**

* `a` - The first OptConstraint to compare.
* `b` - The second OptConstraint to compare.

**Returns:**

* true if the OptConstraints are considered equal; otherwise, false.

### LowerBound

```csharp theme={null}
double LowerBound
```

Lower bound of the constraint or NaN if no lower bound exists.

### Name

```csharp theme={null}
string Name
```

Name of the constraint

Implements IVariableName.

### UpperBound

```csharp theme={null}
double UpperBound
```

Upper bound of constraint or NaN if no upper bound exists.

## Property Documentation

### LowerBound

```csharp theme={null}
double LowerBound
```

Lower bound of the constraint or NaN if no lower bound exists.

### Name

```csharp theme={null}
string Name
```

Name of the constraint

Implements IVariableName.

### UpperBound

```csharp theme={null}
double UpperBound
```

Upper bound of constraint or NaN if no upper bound exists.
