Q:

How to choose 9 values such that

Given 9 variables x1 x2 x3 x4 x5 x6 x7 x8 x9, I want to assign real numbers to them such that:
exactly 1 pair among them sums to 2
exactly 2 pairs among them sum to 3
exactly 3 pairs among them sum to 4
exactly 4 pairs among them sum to 5
exactly 5 pairs among them sum to 6
exactly 6 pairs among them sum to 7
exactly 5 pairs among them sum to 8
exactly 4 pairs among them sum to 9
exactly 3 pairs among them sum to 10
exactly 2 pairs among them sum to 11
and exactly 1 pair among them sums to 12

Could this be modeled as a constraint satisfaction problem somehow?or else how to go about solving this?
Thanks,

A:

Since you ask for 1 pair to have a certain sum, it must be unordered pairs of variables that are counted.  Also since 36 sums are specified, we are excluding (I assume) adding a variable to itself (so that thus 36 not necessarily distinct sums are required).
You are asking an ostensible programming question as to whether it can be solved by constraint programming.  Constraint programming could produce an answer for a finite domain.  Over the domain of real numbers there would be infinitely many possibilities to check without further insight.
In searching some economy can be had by assuming the variables are in increasing order, which would make the rows and columns of the "addition table" of those variables also ascendingly ordered.  Now we at least have a finite problem to explore.  The upper and lower triangles of this table are symmetric, so we only need to find whether one half or the other can be filled out.
Is that enough of a hint?  I'd note that the positions of the 2 and 12 entries in the table are determined (as sums of two smallest and two largest) variables.  We can visualize the upper half of the addition table like this:
  _  2  ?  ?  ?  ?  ?  ?  ?
     _  ?  ?  ?  ?  ?  ?  ?
        _  ?  ?  ?  ?  ?  ?
           _  ?  ?  ?  ?  ?
              _  ?  ?  ?  ?
                 _  ?  ?  ?
                    _  ?  ?
                       _ 12
                          _

We can give a fairly simple Prolog program that selects the entries of one row after another, using the fact that the first open entry in each row must be the smallest one available (since no opportunity to use that entry will arise later, if a large one is used there) together with the fact that the difference between entries in consecutive rows but corresponding columns is a constant across that row (including the diagonal and lower half entries).
To see this, consider row i and column j minus row i' and column j:
(x_i + x_j) - (x_i' + x_j)  =  x_i - x_i'

The difference doesn't depend on the column!  We get the same difference in each column between these rows, e.g. if column j were changed to column j' (say).
Pushing these ideas far enough allows one to solve the problem by hand.

