Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Generating systems of constraints

  • To: mathgroup at
  • Subject: [mg72371] Re: Generating systems of constraints
  • From: Jens-Peer Kuska <kuska at>
  • Date: Tue, 26 Dec 2006 08:59:27 -0500 (EST)
  • Organization: Uni Leipzig
  • References: <emdp92$k3f$>
  • Reply-to: kuska at


assuming your variables named a[1],a[2], a[3] ..
than define

SetAttributes[b, Orderless]
MakeConstrains[n_Integer] := With[{vNo = n},
     Block[{var, constrain},
       var = Table[a[i], {i, 1, vNo}];
       constrain = Union[Flatten[Outer[b[#1, #2] &, var, var]] /. b[v1_,
       v1_] :> Sequence[]] /. b -> NotEqual;
       constrain = Join[constrain, 0 <= # <= vNo & /@ var];
       And @@ constrain



will construct the conditions for 120000


Alec Resnick wrote:
> Good day!  I was hoping someone might be able to point me in the  
> right direction with a problem I ran into.  I'm trying to solve an  
> arbitrarily large system of linear, Diophantine equations whose  
> solutions are subject to two constraints
> 1) All the variables are distinct; i.e., none of the variables are  
> equal to one another.
> 2) All of the variables are bounded by 1 <= x <= # of variables.
> So in essence, I have a system of equations with N variables that I  
> would like to generate solutions for by assigning {1,2...,N} to each  
> variable.
> Now, I know that I can use Reduce to solve this system; however, I  
> don't know how to generate constraints like this for a given N, and  
> I'd rather not type them all out.  Does anyone have any suggestions?   
> I don't need to do this for very many systems, but more than four, so  
> I don't want to have to do too much of it manually.
> Thanks!
> Gratefully,
> a.

  • Prev by Date: integrate
  • Next by Date: Re: nestled plotting
  • Previous by thread: Generating systems of constraints
  • Next by thread: Merry Christmas! Can somebody help me with this equation? Thank you!