#### how to balance penalty between multiple entities and a single entity

There is a planning variables A in one planning entity C and A is in scope (A1 … A10). And the scope of A can be devided into two groups: A1 … A5 -> group1. A6 … A10 -> group2.

C has a field d, and one or more entities will have the same d value.

``````class C
{

@PlanningVariable private A a;

@ValueRangeProvider private List<A> aScope; //A1 ... A10

private D d;

}
``````

There is a planning variables A in one planning entity C and A is in scope (A1 … A10). And the scope of A can be devided into two groups: A1 … A5 -> group1. A6 … A10 -> group2.

C has a field d, and one or more entities will have the same d value.

``````class C
{

@PlanningVariable private A a;

@ValueRangeProvider private List<A> aScope; //A1 ... A10

private D d;

}
``````

There is a planning variables A in one planning entity C and A is in scope (A1 … A10). And the scope of A can be devided into two groups: A1 … A5 -> group1. A6 … A10 -> group2.

C has a field d, and one or more entities will have the same d value.

``````class C
{

@PlanningVariable private A a;

@ValueRangeProvider private List<A> aScope; //A1 ... A10

private D d;

}
``````

What we want to do: The A value of an entity with the same D value belongs to the same group, like group1.

We did try:

we try to use hard constraint to realize it, but we found in some situation it will break this hard constraint or other hard constraints which we don’t hope to break.

we try to design a penalty calculation method to use soft constraint. But we found it will perfer to use entities which has the separate d value, and not use the enities with same d value, because it will cause the extra penalty.

we think about if we should extract the D d as an planning entity, and design a calculation method to fix this problem. But it still doesn’t seem to solve the problem.