master > master: code py - schemata für rucksack

This commit is contained in:
RD 2022-06-14 01:34:44 +02:00
parent d79b10e190
commit 7cfaf253b3
4 changed files with 101 additions and 8 deletions

View File

@ -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]

View File

@ -28,3 +28,5 @@ options:
show:
# - ATOMS
- TREE
rucksack:
verbose: true

View File

@ -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

View File

@ -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
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~