pub fn validate_puzzle(
puzzle: &Puzzle,
solution: &Solution,
) -> Result<(), DominoError>
Expand description
Validates a given puzzle solution by computing a model and checking the objective value.
This function takes a reference to a Puzzle
and a Solution
, then performs the following steps:
- Computes a string-based model representation using
compute_model()
. - Executes the computed model using
Model::execute()
. - Extracts the objective value from the solver result.
- Compares the objective value against the expected missing tile count.
- Returns
Ok(())
if the objective value matches the missing tile count, otherwise returns aDominoError
.
§Arguments
puzzle
- A reference to thePuzzle
structure representing the puzzle to be validated.solution
- A reference to theSolution
structure representing the proposed solution.
§Returns
Ok(())
- If the computed objective value matches the expected number of missing tiles.Err(DominoError::ModelError)
- If the model execution fails or the objective value is incorrect.
§Errors
This function returns a DominoError::ModelError
in the following cases:
- If
compute_model()
returns an error. - If
Model::execute()
fails to execute the computed model. - If the extracted objective value does not match the expected missing tile count.