With the objective function in place, the next step is to formulate the constraints. There are two sets of constraints in this model. The first set guarantees that each vendor receives the number of widgets required. We will refer to this first set of constraints as being the demand constraints. The second set of constraints, called the capacity constraints, ensures no warehouse ships out more widgets than it has on hand.

Starting with the demand constraint for Vendor 1, we need to sum up the shipments from all the warehouses to Vendor 1 and set them equal to Vendor 1's demand of 35 widgets. Thus, if we were using scalar based notation, we would need to construct the following:

VOLUME_1_1 + VOLUME_2_1 + VOLUME_3_1 +

VOLUME_4_1 + VOLUME_5_1 + VOLUME_6_1 = 35;

You would then need to type seven additional demand constraints, in a similar form, to cover all eight vendors. Again, as one can see, this would be a tedious and error prone process. However, as with our objective function, we can use LINGO's set-based modeling language to simplify our task.

Using mathematical notation, all eight demand constraints can be expressed in the single statement:

Σi  VOLUMEij = DEMANDj, for all j in VENDORS

The corresponding LINGO modeling statement appears as follows:

@FOR( VENDORS( J):

@SUM( WAREHOUSES( I): VOLUME( I, J)) =

 DEMAND( J));

This LINGO statement replaces all eight demand constraints. In words, this says for all VENDORS, the sum of the VOLUME shipped from each of the WAREHOUSES to that vendor must equal the corresponding DEMAND of the vendor. Notice how closely this statement resembles the mathematical notation above as shown in the following table.

Math Notation

LINGO Syntax

for all j in VENDORS

@FOR( VENDORS( J):

Σi

@SUM( WAREHOUSES( I):

VOLUME ij

VOLUME( I, J))

=

=

DEMAND j

DEMAND( J));

Now, we will move on to constructing the capacity constraints. In standard mathematical notation, the six capacity constraints would be expressed as:

Σj VOLUME ij <= CAP i , for all i in WAREHOUSES

The equivalent LINGO statement for all capacity constraints would be:

@FOR( WAREHOUSES( I):

@SUM( VENDORS( J): VOLUME( I, J))<=

 CAPACITY( I));

In words, this says, for each member of the set WAREHOUSES, the sum of the VOLUME shipped to each of the VENDORS from that warehouse must be less-than-or-equal-to the CAPACITY of the warehouse.