in CPLEX_Studio2212\opl\examples\opl\color there is a graph coloring example
// --------------------------------------------------------------------------
// Licensed Materials - Property of IBM
//
// 5725-A06 5725-A29 5724-Y48 5724-Y49 5724-Y54 5724-Y55
// Copyright IBM Corporation 1998, 2024. All Rights Reserved.
//
// Note to U.S. Government Users Restricted Rights:
// Use, duplication or disclosure restricted by GSA ADP Schedule
// Contract with IBM Corp.
// --------------------------------------------------------------------------
/* ------------------------------------------------------------
Problem Description
-------------------
The problem involves choosing colors for the countries on a map in
such a way that at most four colors (blue, white, yellow, green) are
used and no neighboring countries are the same color. In this exercise,
you will find a solution for a map coloring problem with six countries:
Belgium, Denmark, France, Germany, Luxembourg, and the Netherlands.
------------------------------------------------------------ */
using CP;
range r = 0..3;
string Names[r] = ["blue", "white", "yellow", "green"];
dvar int Belgium in r;
dvar int Denmark in r;
dvar int France in r;
dvar int Germany in r;
dvar int Luxembourg in r;
dvar int Netherlands in r;
subject to {
Belgium != France;
Belgium != Germany;
Belgium != Netherlands;
Belgium != Luxembourg;
Denmark != Germany;
France != Germany;
France != Luxembourg;
Germany != Luxembourg;
Germany != Netherlands;
}
execute {
writeln("Belgium: ", Names[Belgium]);
writeln("Denmark: ", Names[Denmark]);
writeln("France: ", Names[France]);
writeln("Germany: ", Names[Germany]);
writeln("Luxembourg: ", Names[Luxembourg]);
writeln("Netherlands: ", Names[Netherlands]);
}
tuple resultT {
string name;
string value;
};
{resultT} solution = {};
execute{
solution.add("Belgium", Names[Belgium]);
solution.add("Denmark", Names[Denmark]);
solution.add("France", Names[France]);
solution.add("Germany", Names[Germany]);
solution.add("Luxembourg", Names[Luxembourg]);
solution.add("Netherlands", Names[Netherlands]);
writeln(solution);
}
------------------------------
[Alex] [Fleischer]
[Data and AI Technical Sales]
[IBM]
------------------------------
Original Message:
Sent: Wed December 24, 2025 03:09 AM
From: Globe sim
Subject: Re: Graph coloring
Graph coloring is a simple way to assign colors to different points (nodes) in a graph so that no connected points have the same color. It helps make complex connections easier to understand and visually clear.Just like choosing colors for clarity, fun activities such as sanrio hello kitty coloring pages also use colors to create clear and enjoyable designs.
------------------------------
Globe sim
Original Message:
Sent: Wed December 24, 2025 03:09 AM
From: Archive User
Subject: Re: Graph coloring
Originally posted by: SystemAdmin
You need to surround you code snippet with '{code}' tags, otherwise we cannot read it.
As far as I can tell you never initialize the elements in the 'x' array? That would be a problem.
Could you please tell us which statement in your code throws the exception?
#DecisionOptimization
#MathematicalProgramming-General