Re: using indexed variables in MultiplierMethod[ ], etc.
- To: mathgroup at smc.vnet.net
- Subject: [mg7724] Re: using indexed variables in MultiplierMethod[ ], etc.
- From: daiyanh at mindspring.com (Daitaro Hagihara)
- Date: Wed, 2 Jul 1997 14:21:47 -0400 (EDT)
- Organization: MindSpring Enterprises
- Sender: owner-wri-mathgroup at wolfram.com
In article <5p75n1$8if at smc.vnet.net>, I wrote: > SymbolicSum. In the def. of SymbolicSum, the arguments are constrained > by the Symbol heads. So all I have to do to circumvent this is to fool > the function as if symbolic arguments are being supplied. If your > function is doing the same thing as SymbolicSum, then this might help. > > SymbolicSum[K,{K,n}] --> (n*(1 + n))/2 > SymbolicSum[K[1],{K[1],n}] --> SymbolicSum[K[1], {K[1], n}] > SymbolicSum[K[1],{K[1],n}]/.K[1]->Symbol[K[1]] --> (n*(1 + n))/2 > > This may come in handy too: > Thread[Array[u,2]->Array[Composition[Symbol,u],2]] > --> {u[1] -> Symbol[u[1]], u[2] -> Symbol[u[2]]} > > Ask the package author before attempting to modify the source code as > there may be a reason why certain argument constraints are imposed. Gee, the top portion of my previous post was gone! It's because of my server, I believe. Anyway, what I wrote was a comment, which is what I said in the blown opening statement of the previous post. The problem with your MultiplierMethod, as it turned out, was the Compile function used in FindMinimum. This Compile function simply doesn't accept non-Symbolic arguments. Period. You can turn off the auto compilation by using Compiled->False option in FindMinimum for using indexed variables, but this may not be desirable for a long and complicated cost function. The following will do the trick for you: m:MultiplierMethod[_,_List,_List,x:{___,_?(Head[#]=!=Symbol&),___},_List,___]:= (Hold[m]/.Thread[x->#])[[1]]/.Thread[#->x]&[If[Head[#]=!=Symbol,Unique[],#]&/@x]; Oh, if you define the above after loading the package, you must reverse the order of DownValues[MultiplierMethod]...a drag, but we must live with it. --daiyan