diff --git a/code/python/assets/commands.yaml b/code/python/assets/commands.yaml index 9ff71d2..4d3b087 100644 --- a/code/python/assets/commands.yaml +++ b/code/python/assets/commands.yaml @@ -53,7 +53,7 @@ - name: HIRSCHBERG word1: 'happily ever after' word2: 'apples' - once: true + once: false - name: HIRSCHBERG word1: 'happily' word2: 'applses' @@ -70,3 +70,34 @@ word1: 'ANSTRENGEN' word2: 'ANSPANNEN' once: false + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Beispiele für Seminarwoche 11 (Blatt 10) +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +- &rucksack_1 + name: RUCKSACK + algorithm: GREEDY + allow-fractional: true + capacity: 10 + weights: + [3, 4, 5, 2, 1] + values: + [8, 7, 8, 3, 2] +- <<: *rucksack_1 + algorithm: BRANCH-AND-BOUND +- name: RUCKSACK + algorithm: BRANCH-AND-BOUND + allow-fractional: true + capacity: 90 + items: [ + 'Sonnenblumenkerne', + 'Buchweizen', + 'Rote Beete', + 'Hirse', + 'Sellerie', + ] + weights: + [30, 10, 50, 10, 80] + values: + [17, 14, 17, 5, 25] diff --git a/code/python/assets/config.yaml b/code/python/assets/config.yaml index 62cc33c..aafb719 100644 --- a/code/python/assets/config.yaml +++ b/code/python/assets/config.yaml @@ -28,3 +28,5 @@ options: show: # - ATOMS - TREE + rucksack: + verbose: true diff --git a/code/python/models/commands-schema.yaml b/code/python/models/commands-schema.yaml index de589b5..710c344 100644 --- a/code/python/models/commands-schema.yaml +++ b/code/python/models/commands-schema.yaml @@ -31,7 +31,7 @@ components: $ref: '#/components/schemas/EnumAlgorithmNames' additionalProperties: true # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - # Command - Algorithm: Tarjan + # Algorithm: Tarjan # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CommandTarjan: description: |- @@ -63,7 +63,7 @@ components: - type: number - type: string # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - # Command - Algorithm: TSP + # Algorithm: TSP # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CommandTsp: description: |- @@ -83,9 +83,9 @@ components: items: type: number optimise: - $ref: '#/components/schemas/EnumTSPOptimise' + $ref: '#/components/schemas/EnumOptimiseMode' # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - # Command - Algorithm: Hirschberg + # Algorithm: Hirschberg # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CommandHirschberg: description: |- @@ -107,6 +107,46 @@ components: once: type: boolean default: false + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + # Algorithm: Rucksack Branch & Bound + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CommandRucksack: + description: |- + Instructions for execution of Branch & Bound-Algorithm for the Rucksack-Problem + type: object + required: + - algorithm + - allow-fractional + - capacity + - weights + - values + properties: + algorithm: + $ref: '#/components/schemas/EnumRucksackAlgorithm' + allow-fractional: + type: boolean + default: false + capacity: + description: Maximum weight/volumed allowed in rucksack. + type: number + minimum: 0 + weights: + description: Weights or volumes of each item. + type: array + items: + type: number + exclusiveMinimum: 0 + values: + description: Value extracted from each item (e.g. monetary). + type: array + items: + type: number + items: + description: Optional names of the items (if empty, defaults to 1-based indexes). + type: array + items: + type: string + default: [] # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Enum Algorithm Names # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -118,13 +158,24 @@ components: - TARJAN - TSP - HIRSCHBERG + - RUCKSACK # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - # Enum TSP - Optimise Mode + # Enum Optimise Mode # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - EnumTSPOptimise: + EnumOptimiseMode: description: |- - Enumeration of optimisation options for TSP + Enumeration of optimisation modi. type: string enum: - MIN - MAX + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + # Enum Rucksack mode for algorithm + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + EnumRucksackAlgorithm: + description: |- + Enumeration of mode for Rucksack problem + type: string + enum: + - GREEDY + - BRANCH-AND-BOUND diff --git a/code/python/models/config-schema.yaml b/code/python/models/config-schema.yaml index 1bb0551..dfca22f 100644 --- a/code/python/models/config-schema.yaml +++ b/code/python/models/config-schema.yaml @@ -53,6 +53,7 @@ components: - tsp - tarjan - hirschberg + - rucksack-branch-and-bound properties: log-level: $ref: '#/components/schemas/EnumLogLevel' @@ -114,6 +115,14 @@ components: items: $ref: '#/components/schemas/EnumHirschbergShow' default: [] + rucksack: + type: object + required: + - verbose + properties: + verbose: + type: boolean + default: false # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Enum LogLevel # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~