Solver Configuration
Configure solver behavior with SolverConfig and TerminationConfig
This section covers solver configuration and execution.
SolverConfig and TerminationConfigSolverFactory and SolverSimpleScore, HardSoftScore, HardMediumSoftScore, and BendableScoreRunning a solver involves:
use solverforge_core::{SolveRequest, SolveResponse, TerminationConfig};
// Build request with termination
let request = SolveRequest::new(
domain, constraints, wasm_base64,
"alloc", "dealloc", list_accessor, problem_json
)
.with_termination(TerminationConfig::new()
.with_spent_limit("PT5M")
.with_best_score_feasible(true)
);
// Send to solver
let response: SolveResponse = client
.post(&format!("{}/solve", service.url()))
.json(&request)
.send()?
.json()?;
// Check result
println!("Score: {}", response.score);
if response.score.starts_with("0hard") {
println!("Solution is feasible!");
}
The solver continues until a termination condition is met:
| Condition | Description |
|---|---|
spent_limit | Maximum solving time (e.g., "PT5M") |
best_score_feasible | Stop when feasible |
best_score_limit | Stop at target score |
move_count_limit | Maximum moves |
step_count_limit | Maximum steps |
Multiple conditions can be combined - the solver stops when any is satisfied.
Configure solver behavior with SolverConfig and TerminationConfig
Create and run solvers with SolverFactory and Solver
Understand SimpleScore, HardSoftScore, HardMediumSoftScore, and BendableScore
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.