# Generate constraints from a Dataset

### Overview

Verteego allows for the dynamic creation of multiple constraints directly from the data contained within a dataset. This functionality is instrumental in building scalable and adaptable optimization models that respond to varying data conditions.

### Implementation

To automatically generate constraints from a dataset, you must specify the dataset to be used as the input and identify the relevant columns that will dictate the constraint parameters. In Verteego, this is achieved by referencing the desired column names, prefixed with the '@' symbol to denote their role in constraint generation.

#### Constraint Creation Process

For every row in the specified input dataset, Verteego examines the column values and generates constraints accordingly. These constraints reflect the conditions and relationships present within the dataset, ensuring the optimization model aligns with real-world scenarios and data-specific requirements.

### Example

Below is a YAML configuration snippet illustrating how to set up the system for generating binary constraints:

```yaml
yamlCopy codebinary_constraint_generator:
  input_dataset: my_dataset
  constraint_type: binary
  left_column: @left_column  # Column in 'my_dataset' defining the left-hand side of the constraint
  operator: @operator        # Column in 'my_dataset' indicating the constraint operator (e.g., 'less', 'greater', 'equal')
  right_column: @right_column  # Column in 'my_dataset' defining the right-hand side of the constraint
  delta: 0                   # The numerical offset for the constraint (optional, defaults to 0)
```

With the provided configuration:

* **`input_dataset`**: Identifies 'my\_dataset' as the source from which constraints will be generated.
* **`constraint_type`**: Specifies that the constraints being generated are of the 'binary' type.
* **`left_column`**, **`operator`**, **`right_column`**: These fields are dynamically filled for each constraint based on the values found in the corresponding columns in 'my\_dataset', signified by the '@' prefix.
* **`delta`**: Establishes an offset value for the constraints, which in this case is set to 0, meaning there is no additional value added to or subtracted from the constraint equation.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.verteego.com/verteego-doc/pipelines/optimization-pipelines/constraints/generate-constraints-from-a-dataset.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
