OpenRules Platform

Decision Optimization

Map Coloring with Violations

Find the best available map coloring when preferences or constraints may be violated, using penalties to compare solutions.

image

This is an advanced version of “Map Coloring” problem that could use 4 colors. Now we have only 3 colors (blue, red, green). It is certainly not enough to color six European countries: Belgium, Denmark, France, Germany, Luxembourg, and the Netherlands with no neighboring countries using the same color. So, some neighboring countries may have the same colors, but there is a relative cost for such violations:

  • France – Luxembourg: $257
  • Luxembourg – Germany: $904
  • Luxembourg – Belgium: $568

We need to find a solution that satisfies as many constraints as possible while minimizing the total violation cost.

As usual, we start with the Glossary:

image

All 6 unknown decision variables could take different colors from 1 to 4.

We will split all constraints into Hard (must be satisfied) and Soft (could be violated). First, we will post hard constraints

image

Then we will post soft constraints with their violation costs:

image

These three constraints were added to the array “Constraint Violations”. Now we can define the objective variable as a sum of all constraint violations:

image

Finally, we can invoke the above tables using the table “Define”. The table “Solve” solves the problem by using the predefined method “SolverMinimize”:

image

Here are the execution results:

Netherlands[1] Belgium[2] Luxembourg[1] Denmark[1] France[1] Germany[3]

Luxembourg != Belgium[0] France != Luxembourg[257] Luxembourg != Germany[0]

Objective[257]

Only the “cheapest” constraint “France != Luxembourg[257]” has been violated.

The proper standard project is available in openrules.solver/PREFERENCES/MapColoringPreferences.

Try Rule Solver

Build decision models that find the best answer.

Start with the free evaluation, then install Rule Solver and explore its optimization examples.