Project#evaluate#
Scores alternative change sets against the solved baseline of a Project. Doesn't modify the project. Use it to compare options, such as which resource should take a task, before committing one with apply. Needs a solved project.
Signature#
public EvaluateResult
public EvaluateResult
Synchronous and CPU-only. Read-only, but not synchronized: serialize calls on one instance. The Collection overload copies the candidates into a Vec, so List.of(...) works.
Parameters#
| Name | Type | Description |
|---|---|---|
candidates |
Vec<Candidate> |
The change sets to score. Must not be null |
options |
EvaluateOptions |
Baseline check, leveling stage, focus tasks and clearFirst. Must not be null |
Behavior#
Each candidate runs on a disposable copy of the reference state (the baseline, or its cleared copy with options.clearFirst):
applythe candidate's changes.solve(null, …)and measure the scheduled stage.- With
options.levelset,levelwith those options and measure the leveled stage.
Every candidate starts from the reference state, never from the previous candidate. A failure inside one candidate goes into that candidate's error and doesn't fail the call. The result has scores, not dates.
Returns#
An EvaluateResult with the baseline metrics and one result per candidate, in input order.
Errors#
All exceptions are unchecked.
| Error | When |
|---|---|
ProjectException with code == ProjectError.NO_BASELINE |
The project is unsolved, including after apply |
ProjectException with code == ProjectError.STALE_BASELINE |
options.baselineId or any candidate's changes.baselineId doesn't name the current baseline |
InputException |
An unknown task in focus (path focus[i]); options.level is invalid for the baseline |
NullPointerException |
candidates or options is null |
evaluateWith#
public EvaluateResult
public EvaluateResult
Same as evaluate, with a choice of Execution. Execution.sequential() is what evaluate uses. Execution.parallel(threads) scores candidates on a private fixed thread pool of min(threads, candidates.size()) workers (null threads means availableProcessors()). With one worker or fewer, candidates run on the calling thread. The pool shuts down before the call returns, and the caller blocks until every candidate is done. Peak memory is one candidate copy per worker.
The results are identical to evaluate and keep input order. A call-level error is the first one in input order, and later candidates may already have run. Errors are the same as for evaluate, plus NullPointerException for a null execution.
Example#
Compare leaving the plan as it is with moving task B to an idle resource.
;
;
Related#
Candidate- one change set to scoreEvaluateOptions- baseline check, leveling stage and focus tasksEvaluateResult- baseline metrics and one result per candidateExecution- sequential or parallel scoring with evaluateWith- Evaluating alternatives - comparing candidates and committing the winner