MathGroup Archive 2008

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

Search the Archive

Re: Speeding-up FindInstance

  • To: mathgroup at smc.vnet.net
  • Subject: [mg94943] Re: Speeding-up FindInstance
  • From: Ray Koopman <koopman at sfu.ca>
  • Date: Wed, 31 Dec 2008 06:09:02 -0500 (EST)
  • References: <gjcuml$crl$1@smc.vnet.net>

On Dec 30, 2:55 am, "Colletti, Bruce W." <bcolle... at nvcc.edu> wrote:
> Re Mathematica 7.0.
>
> Let X be an n-by-p array of indexed x-variables,
> e.g., x[1,1], x[1,2], etc.
>
> I seek x-values in {-1, 0, 1} so that all column sums
> are zero and no column is the zero vector.
>
> The code below for a 5x3 problem runs forever.
> What is a faster way to get a solution?  Thankx.
>
> Bruce
>
> {n,p} = {5,3};
>
> X=Array[x,{n,p}];
>
> Z = Flatten[X];
> FindInstance[And@@Join[Map[#==0&,Total@X],
> Map[#>0&,Map[Abs,Total@X,{2}]],
> Map[Abs@#<=1&,Z]],Z,Integers]

{n,p} = {5,3}
Z = Array[z,n]
Timing[Z/.FindInstance[Tr@Z == 0 && Z.Z > 0 && Max@Abs@Z == 1,
                       Z, Integers, p]]

{5,3}
{z[1],z[2],z[3],z[4],z[5]}
{3.36 Second,{{0,-1,0,1,0},{0,0,0,-1,1},{0,0,0,1,-1}}}


  • Prev by Date: Re: Can mathematica save restart file for Simplify?
  • Next by Date: Re: Speeding-up FindInstance
  • Previous by thread: Re: Speeding-up FindInstance
  • Next by thread: Re: BarChart