ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 24 May 2016 15:25:53 +0200Evaluation of a LinearFunctionhttps://ask.sagemath.org/question/33536/evaluation-of-a-linearfunction/ I would like to substitute values for the variables in a LinearFunction object. For example:
sage: lp.<x> = MixedIntegerLinearProgram()
sage: f = 2*x[0] + x[1]
sage: f
2*x_0 + x_1
sage: type(f)
<type 'sage.numerical.linear_functions.LinearFunction'>
The object f is not callable, and also the following does nothing (even though the Sage online help suggests that it should do something):
sage: f.subs({x[0]:1.0, x[1]:2.0})
2*x_0 + x_1
I can do what I want to do by writing some code to work with the output of f.dict(), but does Sage have a cleaner way to evaluate a linear function?Tue, 24 May 2016 15:25:53 +0200https://ask.sagemath.org/question/33536/evaluation-of-a-linearfunction/