Optaplanner结果中"-4init/0hard/0soft"的含义是什么?
Hey there! Let’s unpack what that score means and why you’re hitting this issue with your high-resource processes.
First, since you already get hard and soft scores, let’s zero in on the init portion of the result:
- Init scores track violations of constraints OptaPlanner checks during the initial solution construction phase—before it even starts optimizing with hard/soft rules. These are baseline, non-negotiable checks the solver runs to build a starting point.
- The
-4here tells you 4 separate initialization constraints were violated when OptaPlanner tried to set up an initial solution for your high-demand processes.
Why this happens with your high-value resource settings
In the default Cloud Balancing demo, sample computers are likely configured with resource limits (memory/CPU/bandwidth) capped around 20. When you set a process’s resource requirement above that threshold, the solver can’t find any computer in your dataset that can accommodate it during initialization. Each unassignable process triggers an init constraint violation, hence the -4init.
The 0hard/0soft part makes sense here: OptaPlanner doesn’t move on to evaluating hard/soft constraints if the initial solution has unresolved init violations—it’s stuck at the first hurdle of assigning processes to feasible computers.
How to fix this
- Adjust computer resource limits: Open the demo’s dataset (usually a CSV/JSON file) and increase the memory/CPU/bandwidth values of your sample computers to match or exceed the high values you’re setting for processes.
- Inspect initialization rules: Check the demo’s DRL rule files for constraints annotated with
@ConstraintWeight(..., Score.ONE_INIT). These are the exact rules being violated—you’ll see the exact requirements for a valid initial assignment. - Tweak initialization logic (if needed): If you want to allow temporary invalid assignments during initialization (and let the solver fix them later), you could reclassify init constraints as hard constraints. That said, this isn’t ideal for Cloud Balancing, where processes need to run on computers with sufficient resources from the start.
内容的提问来源于stack exchange,提问作者Gustavo Chavez

