Your suggestion worked like a charm:
gradL2 = []
for ii in range(len(x)):
gradL2.append((gradL[ii]).function(*x)) # x is list of symbolic vars
def F(s):
tmp=[]
for ii in range(len(gradL2)):
tmp.append((gradL2[ii])(*s))
return tmp
ssoln = scipy.optimize.broyden1(F, [.5,.5,.5], f_tol=1e-14)
Was trying to use Lagrange multipliers to maximize the entropy of probability
schema associated with the rows of a truth table where certain boolean
polynomials are converted to probability expressions and set to a constraint
probability but
gradL = gradH + gradg
critical = solve([gradL[0] == 0, gradL[1] == 0, gradL[2] == 0, ],x,
solution_dict=True)
doesn't solve well enough to get me close to a numerical value. Had to simplify
the system of expressions in critical...trying to automate for any number of
generators of the boolean algebra and multiple constraint equations
Thanks,
Steve
PS Is top posting frowned on here?
On 11/22/2014 12:50 PM, Nils Bruin wrote:
> On Saturday, November 22, 2014 8:06:23 AM UTC-8, Stephen Kauffman wrote:
>>
>> gradL
>> (gradL[0]).arguments()
>> (gradL[1]).arguments()
>> (gradL[2]).arguments()
>> s=[3,.5,.3]
>> (gradL[0])(*s)
>> (gradL[1])(*s)
>> (gradL[2])(*s)
>>
>
>
>> (lam0*(x1 - 1.00000000000000) - log(x0) + log(-x0 + 1), lam0*x0 - log(x1)
>> + log(-x1 + 1), x0*x1 - x0 + 0.500000000000000)
>> (lam0, x0, x1)
>> (lam0, x0, x1)
>> (x0, x1)
>> -2.10000000000000
>> 2.34729786038720
>> ValueError: the number of arguments must be less than or equal to 2
>>
>
> It looks like the elements in gradF are just symbolic expressions, in which
> case evaluation by positional arguments is deprecated and ill-defined
> (there are no guarantees about the order in which the arguments are read):
>
> sage: (x+y)(1,2)
> DeprecationWarning: Substitution using function-call syntax and unnamed
> arguments is deprecated and will be removed from a future release of Sage;
> you can use named arguments instead, like EXPR(x=..., y=...)
> See http://trac.sagemath.org/5930 for details.
>
> In your case, turning the expressions into "symbolic functions" might be
> the way to go:
>
> sage: f=(x+y).function(x,y,z)
> sage: f(2,5,11)
> 7
>
> I need to be able to to be able to define this as a vector valued function
>> of a vector so that I can evaluate it using the entire argument set (lam0,
>> x0, x1) where the missing arguments are ignored for the corresponding
>> component. This is so I may def a function for scipy.optimize like:
>>
>
> Symbolic expressions can be quite slow for that. Look at fast_callable if
> you're running into speed problems.
>
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.