# Types of Optimization Constraints

In the Constraints tab when defining an optimization scenario, the Add Constraint dropdown box provides a number of options for constraint types that you can use.  This document provides a brief overview of each from a conceptual level.  See https://support.lityxiq.com/845223-Optimization-Scenario-Constraints for more information on the detailed settings for each.

## Standard Metric-Based Constraint

This type of constraint is by far the most common.  They relate to constraining the value of a single optimization metric (creating optimization metrics is described more here: https://support.lityxiq.com/773516-Define-Optimization-Metrics).  The constraining of the metric can be done within any subset (or multiple subsets) of the dataset.

Some examples are:

• Suppose CPO (cost per order) is a metric that you have defined in the scenario.  You can constrain the optimization results to ensure that the CPO of Social Media and SEO channels do not exceed \$60.
• Suppose Total Targeted Quantity is a metric defined in the scenario.  You can constrain the optimization results to ensure that
• Total Targeted Quantity is greater than 1MM for each of Prospect Segments A, B, and C
• and Total Targeted Quantity is fewer than 250,000 for Prospect Segment E
• and Total Targeted Quantity is fewer than 10MM in total across all segments.
• Suppose Budget is a metric.  You can constrain the optimization to ensure that total budget stays under \$25MM, and that it is at least \$2MM in the print channel due to vendor contract business constraints.

## Levels Count Constraint

The Levels Count constraint is a way of specifying the number of unique different levels of any optimization Attribute that have a positive optimization output.  This is best understood with examples:

• Suppose State is an attribute in your optimization.  You might have a business constraint that say you must spend budget in at least 40 different states.  In this case, the optimization constraint would be specified to ensure that the "Levels Count for State is greater than or equal to 40".
• Suppose in a traditional advertising scenario with newspaper media, you have a business constraint that you cannot place advertising in more than 250 different newspapers (due to production, resource, or other capacity constraints).  In this case, the optimization constraint is to ensure that the "Levels Count for Newspaper".

## Either/Or Constraint

The Either/Or constraint type can be thought of as a "meta-constraint".  It is defined based on other constraints by specifying that not all of them have to hold true in the optimization result; only a subset of them have to hold true.  For example, you may have some constraints defined such that one or the other need to hold, but not necessarily both.

To define an Either/Or constraint, first you define each of the base set of constraints that will become part of the either/or definition.  These base constraints can be any combination of the constraint types described above. Then you create an Either/Or constraint that defines which set of constraints are to be considered, and how many of them must hold.

In the Constraints Involved box, you will see a list of all the other constraints already defined for the scenario.  Check the ones that will be considered as a part of the either/or condition (at least two must be checked).  Then use the How Many Must Hold entry to specify how many of the selected constraints will be required to hold true in the optimization result.  Note that the number chosen here is evaluated as in: "At least x of the selected constraints must hold" where x is the number you entered.

Example: You need to allocate budget optimally across three channels (C1, C2, and C3), among maybe many other channels.  These three channels are related, such that you are contractually required to spend at least \$1000 in one of the channels for this campaign.  You can spend \$1000 or more in two or three of them as well, but definitively you must in at least one of them.  This would lead you to define three Standard constraints as in:

• Budget for C1 >= 1000
• Budget for C2 >= 1000
• Budget for C3 >= 1000

Then, you will define an Either/Or constraint by selecting all three of these as the "Involved Constraints", and then entering "1" for How Many Must Hold.  These three constraints will now be evaluated in the optimization run only with respect to the combined Either/Or condition.