File References
Array JSON files are referred to from the problem definition (PD) via the array
, and sometimes, atoms
objects. The array
object refers to just the array while while an atoms
reference also includes atom array configuration (resourceCount, timeCount and stateCount). The design behind having these as external resources (as opposed to embedded in the PD) is so that dynamic parts of a problem definition can be updated (or created) while the core constraints within the PD do not need to change. In other words, this allows the PD file to remain fixed, and only the data (input) files changed.
For example, if an employee schedule is being created, there may be different numbers of employees each week or pay period. However, this wouldn't change the constraints - but it would change the number of resources in the atom array. A traveling salesperson problem may have a different number of locations each run, but again, the constraint definitions wouldn't change.
Array JSON File Format
array
objects within the PD refer to a JSON file that has a JSON array format. As shown in the below example of a two dimensional array:
[
[ 3360.0, 4320.0, 2.0, 5.0, 2.0, 1.0 ],
[ 3360.0, 4320.0, 2.0, 5.0, 2.0, 1.0 ],
[ 3360.0, 4320.0, 2.0, 5.0, 2.0, 1.0 ],
[ 3360.0, 4320.0, 2.0, 5.0, 2.0, 1.0 ],
[ 3360.0, 4320.0, 2.0, 5.0, 2.0, 1.0 ],
[ 3360.0, 4320.0, 2.0, 5.0, 2.0, 1.0 ],
[ 3360.0, 4320.0, 2.0, 5.0, 2.0, 1.0 ],
[ 3360.0, 4320.0, 2.0, 5.0, 2.0, 1.0 ]
]
In Python, the creation of an array as shown above is trivially:
import numpy
import json
na = numpy.zeros((8, 6))
# ...(fill in array a with values)...
a = na.tolist()
with open("filename.json", "w") as f:
json.dump(a, f, indent=4)
Atoms JSON File Format
The atoms JSON file format is simply a separate JSON file that is in the same format as the atoms
object in the PD. For example:
{
"atoms": {
"resourceCount": 4,
"timeCount": 4,
"stateCount": 4
}
}
The atoms
object also contains an array
field which contains an array as defined in the previous section. For example:
{
"atoms": {
"resourceCount": 4,
"timeCount": 4,
"stateCount": 4,
"array": [
[ 0, 0, 1, 0 ],
[ 2, 0, 0, 0 ],
[ 0, 3, 3, 0 ],
[ 2, 0, 0, 1 ]
]
}
}
Note that when the array
is specified within the atoms
object, it must be a two dimensional array with the number of rows equal to resourceCount
and columns equal to timeCount
and the elements (which become atoms) must be less than stateCount
.