Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# st: Multiple constraint satisfaction problem

 From Sarah Dykstra To statalist@hsphsun2.harvard.edu Subject st: Multiple constraint satisfaction problem Date Wed, 6 Feb 2013 14:53:30 -0500

```Hello Statalist members -

I'm trying to calculate a lower / upper bound for possible number of
troops in each province in Afghanistan for each country which
contributed troops.

The pieces of information I have are listed below. For reference,
there are 5 regions and 34 provinces in Afghanistan, and ~30 countries
contributing troops, depending on the year.

1) The total number of troops per region
2) The total number of troops contributed by each country
3) The provinces to which a country contributed troops  (yes/no). Some
countries (usually those with the lowest troop levels) have no
information and for the purpose of our analysis, we're assuming they
can be placed anywhere.

A simplified example:

USA:     30,000 troops

Region 1: 25,000 troops
-----
Prov B: USA

Region 2: 15,000 troops
-------
Prov D: USA

The strategy I have in mind involves creating a new dataset with an
observation for each block of 100 troops (in the simple example above,
there would be 300 USA obs and 100 Canada obs), merging on a randomly
generated id to a dataset with set up the same way for regions (250
obs for Region 1, etc) and crossing against provinces. This ensures
that the total # troops / country and troops / region constraints are
always satisfied. We'll then drop any scenarios which don't satisfy
the last condition, the province assignments for each country. After X
iterations, we'll take the lowest and highest # of troops per country
and province as our lower and upper bounds.

Any estimates on the time it would take to run a program like this?
Any suggestions for a more efficient strategy in Stata?

Thanks!

Sarah Dykstra
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```