How to: Create a Constraint

Solver Foundation 3.0

You can add a constraint to a model to restrict it for business or logical reasons. For example, you can add a constraint to ensure that the sum of demand over a set of airline routes is equal to the total demand or to cap server load at 90%.

To create a constraint

  1. In the Modeling Pane, click the Constraints tab.

  2. Click New.

  3. In the Name field, type a unique name.

  4. In the Expression field, type the OML code to express the constraint. The following code examples demonstrate two constraints. The first constraint uses the ForEach expression to ensure that the demand for each route is the product of the passenger capacities and aircraft allocation, minus the number of bumped passengers.

          {iter1, Routes},
            {iter2, Aircraft},
            Capacity[iter2, iter1] * Allocation[iter2, iter1]
          ], Bumped[iter1]] >= Demand[iter1]

    The second constraint stipulates that the sum of the allocations for a plane type over all routes must not exceed inventory.

          {iter3, Aircraft},
          Available[iter3] != 0,
            {iter4, Routes},
            Allocation[iter3, iter4]
          ] == Available[iter3]
  5. (Optional) In the Description field, type a comment that describes the goal.

Note Note

This example is based on the stochastic model in the Excel Samples for Solver Foundation that demonstrates how to allocate aircraft to different routes.