Repository navigation
feat(score): parse BendableScore from its text form - #278
Merged
blackopsrepl merged 1 commit intoNov 26, 2026
Merged
Conversation
BendableScore now implements ParseableScore, so a planning solution scored with it satisfies the planning_solution bounds and reads score limits such as termination.best_score_limit from solver.toml. The text form is the Display form, `[h1/h2]hard/[s1/s2/s3]soft`; parse rejects a level list whose length is not exactly H (or S).
Collaborator
|
Thanks @slapers — bendable models can now use |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change and Purpose
BendableScore<H, S>is the only built-in score type withoutParseableScore. The solversetup requires
ParseableScoreon the solution's score (for examplerun.rsandruntime/compiler/defaults.rs, which readbest_score_limitfromsolver.toml), so a#[planning_solution]scored with aBendableScoredoes not compile. Today a bendable modelneeds a newtype around the score, and the orphan rule makes that newtype re-implement
Score,the operators and
Displayby hand.BendableScorenow implementsParseableScoreinbendable.rs, next to itsDisplay:parsereads theDisplayform,[h1/h2]hard/[s1/s2/s3]soft, with each level list inbrackets, highest priority first; empty brackets hold zero levels. It trims whitespace like
the other parsers and rejects a level list whose length is not exactly
H(orS).to_string_repris theDisplayform, so parse and render round-trip.The bracket format has no fixed field per suffix, so
impl_score_parse!does not apply; theimpl is hand-written like
SoftScore's andHardSoftDecimalScore's. The core wireframe nowlists
ParseableScoreforBendableScoreinstead of "Does not implementParseableScore".Verification
Commands and results on the branch (macOS, Rust 1.99.1):
make build: ok.cargo test --workspace: ok, every crate green, including 149solverforge-corelib tests.make fmt-check,make clippy,make doc-names,make file-length,make facade-reachability,make public-api: all ok. The public API snapshot is unchanged(it does not list trait impls).
make depswas not run:cargo-macheteis not installed here. The change touches nomanifest.
New tests in
score/tests/bendable_score.rs, following the other score types' tests:test_parse,test_display,display_then_parse_round_trips(includingi64::MIN/MAX),parse_rejects_a_wrong_number_of_levelsandparse_rejects_malformed_text. They do notcompile on
main, whereBendableScorehas noparse.Review Checklist