Starting from version 3.5.5 real color sets are supported in CPN Tools. For previous versions, follow the below guidelines.

No, it is not possible to declare a color set of real numbers. The color sets that are supported are described in the Help pages.

CPN Tools does not support real color sets because reals are not an equality type in Standard ML. It is necessary to be able to test equality of token values in CP-nets.

However, it is possible to encode real values as integers or strings.

Real numbers can be converted to and from strings using the following functions:

`Real.toString`

`(Option.valOf o Real.fromString)`

These functions are described in the Standard ML Basis Library.

Real numbers can also be scaled and encoded as infinite integers, (i.e `IntInf.int`

in SML Basis Library), using the `RealToIntInf`

and `IntInfToReal`

functions, which are described in the Help page for Simulator functions.

If you want to use the encoded real values in a color set, then you will also have to convert the infinite integers to regular integers. Here is an example of functions you could use to convert values from reals to integers and back to reals.

(* number of digits to the right of the decimal point*)

val d = 5;fun realToInt r = IntInf.toInt (RealToIntInf d r)

fun intToReal i = (IntInfToReal d (IntInf.fromInt i))val x = 0.35;

val x1 = realToInt x; (* x1 is 35000 *)

val x2 = intToReal x1; (* x2 is 0.35 *)

You must be logged in to post a comment.