MathGroup Archive 2007

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

Search the Archive

Re: is there a better way to do constraint logic programming in Mathematica?


Just another idea:

v=Array[x,5];

equ={
Tr[v]==22,
Less@@v,
First[v]>=1,
Last[v]<=10
};

v/.FindInstance[equ,v,Integers,100];

(* or *)

v/. ToRules /@ List @@ Reduce[equ,v,Integers];

-- 
HTH   :>)
Dana DeLouis
6.0, but 5.2 Help files & 4.0 Book


"sdw" <warwick at jps.net> wrote in message
news:fbar15$qft$1 at smc.twtelecom.net...
> 
> simplified constraint programming example in Mathematica:
> 
> find a set of numbers that add to a particular value - numbers cannot be 
> the same
> 
> note  huge timing problem as we go up in variables
> 
> Above 5, it hung...

<snip>



  • Prev by Date: Re: listplot and legend (again)
  • Next by Date: Re: Decompose function into one function for each variable
  • Previous by thread: Re: is there a better way to do constraint logic programming in Mathematica?
  • Next by thread: Re: is there a better way to do constraint logic programming in Mathematica?