Budget
Property
Summary
What an algorithm that can run away is allowed to spend before it declines.
Remarks
Unlimited. Unset, each algorithm keeps the budget
it chose for itself. Set, what it does depends on what that budget is for
(#2454):
- A working allowance is replaced. The system solver
(Solve(AngouriMath.Entity.Variable[]): 10,000 steps and 60 seconds
over the whole call) and its Gröbner path (5 seconds) run under this budget
instead of their own, so this is how a caller raises them -- and
Unlimited here means "do not stop", which for a
doubly-exponential algorithm means what it says. - A lid can only be tightened. The proof that a written-out perfect
square is one, which Factorize(System.Int32) runs and
Simplify(System.Int32) offers as a candidate, bounds itself by 2,000
steps and 50 milliseconds against a stall. It runs under the smaller limit on
each axis of that and this, so setting this never makesSimplify or
Factorize run longer. A proof stopped early is "not proved" and falls back
to the symbolic test, so tightening it costs time, not answers. - A budget passed as an argument is capped.EqualitySaturation(AngouriMath.Core.Budgets.WorkBudget,AngouriMath.Core.CostModel),
CanonicalizationOverGraph(AngouriMath.Core.Budgets.WorkBudget) and
AreEqual(AngouriMath.Entity,AngouriMath.Entity,AngouriMath.Core.Budgets.WorkBudget,AngouriMath.Core.Transformations.Soundness,AngouriMath.Core.Domain) spend the budget they were given, under the smaller limit on each axis of it and
this: the outer scope bounds the inner one, and
Unlimited here leaves the argument as passed.
about one of them, so a Time left
steps and also removes its 60 seconds. Against a lid or an argument the missing
clock is simply the looser limit, and theirs applies -- the lid's 50 milliseconds
included, which decide how soon the proof gives up and not the answer. Saying
"no opinion" per axis is a change to WorkBudget itself, left to v3
(#746).
Time is not, so a caller who needs the same answer on
every machine sets the first and leaves the second
BudgetRecording.
(#373)
bounded by it, and nor is anything else in the library, each of which bounds
itself by ceilings of its own that this does not reach; so setting it does not
make an arbitrary call bounded.
Example
using var _ = MathS.Settings.Budget.Set(new WorkBudget { Steps = 100_000 });
using var recording = BudgetRecording.Start();
var solutions = MathS.Equations("x2 + y2 - 4", "x y - 1").Solve("x", "y");Angouri © 2019-2026 · Project's repo · Site's repo · Octicons · Transparency · 6091 pages online