You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.7 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. Instance Batches
  2. ================
  3. If you have to run experiments on multiple problem instances, *instance batches* are your friend. Simply put an instance batch is a collection of problem instances. In order to manage batches across large instance pools spread out over the file system you can declare them in *batch files*.
  4. Loading Batches
  5. ---------------
  6. All you have to do in order to load a batch is to call the `batch.load("path/batch_file")` function with the path to the corresponding batch file.
  7. ```python
  8. import a2.batch
  9. instance_paths = a2.batch.load("path/to/batch_file")
  10. ```
  11. Batch Files
  12. -----------
  13. Batch files are used do index all instances contained in the batch. The real power of these files comes from two features *nested batches* and the possibility to *include batch files*. A example may look like this:
  14. ```JSON
  15. {
  16. "dir": "./some/path",
  17. "include":
  18. [
  19. "path/to_other/batch_file1",
  20. "path/to_other/batch_file2"
  21. ],
  22. "instances":
  23. [
  24. "instance1.cnf",
  25. "instance2.cnf"
  26. ],
  27. "batches":
  28. [
  29. {
  30. "dir": "./nested/path",
  31. "instances":
  32. [
  33. "instanec11.cnf",
  34. "instance22.cnf"
  35. ]
  36. }
  37. ]
  38. }
  39. ```
  40. A complete grammar is defined further below. The main components of a batch files are *batch objects*. Possible fields of batch objects are:
  41. dir
  42. : The base directory for all contained paths. Consider the example above. The path `instance1.cnf` will be expanded to `./some/path/instance1.cnf`.
  43. : If the base path of a batch is relative (e.g. `./path`) it is always relative to its parent batch (e.g. `./nested/path` will be extended to `./some/path/nested/path`). In case of root batches (highest level in batch file) relative base paths are relative to the file location.
  44. : If no `"dir:"` is specified, the base path of the parent batch is inherited (no `"dir:"` is similar to `"dir": "."`).
  45. include
  46. : Here you can list paths to other batch files, which than will be included to the current batch.
  47. instances
  48. : This is the actual list of instance paths.
  49. batches
  50. : Instance batches can contain other (nested) instance batches. This allows you to structure your batch files much more nicely (see nested base paths).
  51. ---
  52. ### Grammar
  53. The complete grammar of a batch file is defined by:
  54. ```
  55. <file> ::= <batch>
  56. <batch> ::= '{' <fields> '}'
  57. <fields> ::= <field>
  58. | ',' <fields>
  59. <field> ::= <directory>
  60. | <instance list>
  61. | <include list>
  62. | <batch list>
  63. <directory> ::= '"dir":' <Path>
  64. <instance list> ::= '"instances": [' <paths> ']'
  65. <include list> ::= '"include": [' <paths> ']'
  66. <batch list> ::= '"batches": [' <batches> ']'
  67. <paths> ::= <path> | ',' <paths>
  68. <batches> ::= <batch> | ',' <batches>
  69. ```
  70. ---