AngouriMath
CostModel
Description
Summary
What "simpler" means, as a named value rather than as an anonymous function.
Remarks
Func`2, so the cost of an expression was already the caller's
to choose. What it could not do is be named: two callers wanting "the smallest tree"
each wrote the same lambda, neither could say which one they used, and nothing could list
what the alternatives are. #746 v2.0 asks for a cost model that is data for exactly that reason, and names the examples —
smallest tree, fewest radicals — that All now holds.
written:
reading the node as written is not an approximation, it is the question. The others count a
mathematical feature — is there a division here, is there a radical — which is a
property of the value and not of the spelling, so they ask what an exponent
Evaled to rather than what it was typed as.
FewestDivisions used to test the exponent's node, so
cheaper than
divisions. That is
#950. A caller
writing their own model wants to decide which of the two kinds it is, because nothing
here can decide it for them: an expression handed to a cost model has not necessarily been
evaluated, and on an e-graph — where every writing of a value is a member of one class at
once — it certainly has not.
whichever candidate the search happened to generate first — which is an accident rather
than a preference. The node term is small enough not to overturn the feature it is added to
and large enough to decide between candidates the feature cannot separate.
Example
using var _ = MathS.Settings.ComplexityCriteria.Set(CostModel.FewestDivisions.Cost);
Console.WriteLine("a / b + b / c".ToEntity().Simplify()); // (a * c + b ^ 2) / (b * c)Parameter "Name"
A short name, so a report can say which model produced an answer.
Parameter "Description"
What this model prefers, in a sentence.
Parameter "Cost"
Members
#ctor(System.String,System.String,System.Func{AngouriMath.Entity,System.Double})
MethodAll
PropertyCost
PropertyDefault
PropertyDescription
PropertyFeature(AngouriMath.Entity,System.Func{AngouriMath.Entity,System.Boolean})
MethodFewestDivisions
PropertyFewestRadicals
PropertyName
PropertySmallestTree
PropertyToString
Method
Angouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 4378 pages online