Compare commits
9 Commits
3c965eda7b
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 32ef695c87 | |||
| 1ee5e7415b | |||
| b1a467b2e4 | |||
| 9f807d2a21 | |||
| de4bd64e77 | |||
| 0c61a29375 | |||
| bd355098cc | |||
| 278e3713c8 | |||
| de238fede9 |
@@ -115,15 +115,86 @@
|
|||||||
]
|
]
|
||||||
costs: [30, 10, 50, 10, 80]
|
costs: [30, 10, 50, 10, 80]
|
||||||
values: [17, 14, 17, 5, 25]
|
values: [17, 14, 17, 5, 25]
|
||||||
|
- name: RUCKSACK
|
||||||
|
algorithm: BRANCH-AND-BOUND
|
||||||
|
max-cost: 900
|
||||||
|
items: [
|
||||||
|
'Sellerie',
|
||||||
|
'Sonnenblumenkerne',
|
||||||
|
'Rote Beete',
|
||||||
|
'Hirse',
|
||||||
|
'Buchweizen',
|
||||||
|
]
|
||||||
|
costs: [600, 100, 800, 100, 200]
|
||||||
|
values: [10, 15, 20, 5, 15]
|
||||||
|
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
# Beispiele für Seminarwoche 12
|
# Beispiele für Seminarwoche 12
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
- name: RANDOM-WALK
|
||||||
|
algorithm: GRADIENT
|
||||||
|
one-based: true
|
||||||
|
coords-init: [3, 3]
|
||||||
|
landscape: &ref_landscape1
|
||||||
|
neighbourhoods:
|
||||||
|
radius: 1
|
||||||
|
# metric: MANHATTAN
|
||||||
|
metric: MAXIMUM
|
||||||
|
labels:
|
||||||
|
- x
|
||||||
|
- y
|
||||||
|
values:
|
||||||
|
- [5, 2, 1, 3, 4, 7]
|
||||||
|
- [8, 4, 3, 5, 5, 6]
|
||||||
|
- [9, 1, 2, 6, 8, 4]
|
||||||
|
- [7, 4, 4, 3, 7, 3]
|
||||||
|
- [6, 4, 2, 1, 0, 7]
|
||||||
|
- [4, 3, 5, 2, 1, 8]
|
||||||
|
optimise: MAX
|
||||||
|
- name: RANDOM-WALK
|
||||||
|
algorithm: ADAPTIVE
|
||||||
|
one-based: true
|
||||||
|
coords-init: [3, 3]
|
||||||
|
landscape: *ref_landscape1
|
||||||
|
optimise: MAX
|
||||||
|
- name: RANDOM-WALK
|
||||||
|
algorithm: METROPOLIS
|
||||||
|
annealing: false
|
||||||
|
temperature-init: 3.
|
||||||
|
one-based: true
|
||||||
|
coords-init: [5, 3]
|
||||||
|
landscape: *ref_landscape1
|
||||||
|
optimise: MAX
|
||||||
|
- name: RANDOM-WALK
|
||||||
|
algorithm: METROPOLIS
|
||||||
|
annealing: false
|
||||||
|
temperature-init: 3.
|
||||||
|
one-based: false
|
||||||
|
coords-init: [0]
|
||||||
|
landscape:
|
||||||
|
neighbourhoods:
|
||||||
|
radius: 1
|
||||||
|
metric: MANHATTAN
|
||||||
|
labels:
|
||||||
|
- x
|
||||||
|
values: [4, 6.5, 2]
|
||||||
|
optimise: MAX
|
||||||
|
- name: GENETIC
|
||||||
|
population:
|
||||||
|
- [3, 5, 4, 1, 6, 7, 2, 8, 9]
|
||||||
|
- [4, 5, 3, 2, 1, 6, 7, 8, 9]
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
# Beispiele für Seminarwoche 13
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
- name: EUKLID
|
- name: EUKLID
|
||||||
numbers:
|
numbers:
|
||||||
- 2017
|
- 2017
|
||||||
- 58
|
- 58
|
||||||
- name: POLLARD-RHO
|
- name: POLLARD-RHO
|
||||||
|
growth: LINEAR
|
||||||
|
# growth: EXPONENTIAL
|
||||||
number: 534767
|
number: 534767
|
||||||
x-init: 5
|
x-init: 5
|
||||||
|
|||||||
2
code/python/dist/VERSION
vendored
2
code/python/dist/VERSION
vendored
@@ -1 +1 @@
|
|||||||
0.3.0
|
0.3.1
|
||||||
|
|||||||
10
code/python/docs/commands/Models/CommandGenetic.md
Normal file
10
code/python/docs/commands/Models/CommandGenetic.md
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# CommandGenetic
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**name** | [**EnumAlgorithmNames**](EnumAlgorithmNames.md) | | [default to null]
|
||||||
|
**population** | [**List**](array.md) | | [default to null]
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
@@ -5,6 +5,7 @@ Name | Type | Description | Notes
|
|||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
**name** | [**EnumAlgorithmNames**](EnumAlgorithmNames.md) | | [default to null]
|
**name** | [**EnumAlgorithmNames**](EnumAlgorithmNames.md) | | [default to null]
|
||||||
**number** | [**Integer**](integer.md) | | [default to null]
|
**number** | [**Integer**](integer.md) | | [default to null]
|
||||||
|
**growth** | [**EnumPollardGrowthRate**](EnumPollardGrowthRate.md) | | [default to null]
|
||||||
**xMinusinit** | [**Integer**](integer.md) | | [optional] [default to 2]
|
**xMinusinit** | [**Integer**](integer.md) | | [optional] [default to 2]
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|||||||
16
code/python/docs/commands/Models/CommandRandomWalk.md
Normal file
16
code/python/docs/commands/Models/CommandRandomWalk.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# CommandRandomWalk
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**name** | [**EnumAlgorithmNames**](EnumAlgorithmNames.md) | | [default to null]
|
||||||
|
**algorithm** | [**EnumWalkMode**](EnumWalkMode.md) | | [default to null]
|
||||||
|
**landscape** | [**DataTypeLandscapeGeometry**](DataTypeLandscapeGeometry.md) | | [default to null]
|
||||||
|
**optimise** | [**EnumOptimiseMode**](EnumOptimiseMode.md) | | [default to null]
|
||||||
|
**coordsMinusinit** | [**List**](integer.md) | Initial co-ordinates to start the algorithm. | [optional] [default to null]
|
||||||
|
**temperatureMinusinit** | [**Float**](float.md) | | [optional] [default to null]
|
||||||
|
**annealing** | [**Boolean**](boolean.md) | | [optional] [default to false]
|
||||||
|
**oneMinusbased** | [**Boolean**](boolean.md) | | [optional] [default to false]
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# DataTypeLandscapeGeometry
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**neighbourhoods** | [**DataTypeLandscapeNeighbourhoods**](DataTypeLandscapeNeighbourhoods.md) | | [default to null]
|
||||||
|
**labels** | [**List**](string.md) | | [default to null]
|
||||||
|
**values** | [**DataTypeLandscapeValues**](DataTypeLandscapeValues.md) | | [default to null]
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# DataTypeLandscapeNeighbourhoods
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**radius** | [**BigDecimal**](number.md) | | [optional] [default to 1]
|
||||||
|
**metric** | [**EnumLandscapeMetric**](EnumLandscapeMetric.md) | | [default to null]
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# DataTypeLandscapeValues
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
8
code/python/docs/commands/Models/EnumLandscapeMetric.md
Normal file
8
code/python/docs/commands/Models/EnumLandscapeMetric.md
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# EnumLandscapeMetric
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# EnumPollardGrowthRate
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
8
code/python/docs/commands/Models/EnumWalkMode.md
Normal file
8
code/python/docs/commands/Models/EnumWalkMode.md
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# EnumWalkMode
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
@@ -14,14 +14,22 @@ Class | Method | HTTP request | Description
|
|||||||
|
|
||||||
- [Command](.//Models/Command.md)
|
- [Command](.//Models/Command.md)
|
||||||
- [CommandEuklid](.//Models/CommandEuklid.md)
|
- [CommandEuklid](.//Models/CommandEuklid.md)
|
||||||
|
- [CommandGenetic](.//Models/CommandGenetic.md)
|
||||||
- [CommandHirschberg](.//Models/CommandHirschberg.md)
|
- [CommandHirschberg](.//Models/CommandHirschberg.md)
|
||||||
- [CommandPollard](.//Models/CommandPollard.md)
|
- [CommandPollard](.//Models/CommandPollard.md)
|
||||||
|
- [CommandRandomWalk](.//Models/CommandRandomWalk.md)
|
||||||
- [CommandRucksack](.//Models/CommandRucksack.md)
|
- [CommandRucksack](.//Models/CommandRucksack.md)
|
||||||
- [CommandTarjan](.//Models/CommandTarjan.md)
|
- [CommandTarjan](.//Models/CommandTarjan.md)
|
||||||
- [CommandTsp](.//Models/CommandTsp.md)
|
- [CommandTsp](.//Models/CommandTsp.md)
|
||||||
|
- [DataTypeLandscapeGeometry](.//Models/DataTypeLandscapeGeometry.md)
|
||||||
|
- [DataTypeLandscapeNeighbourhoods](.//Models/DataTypeLandscapeNeighbourhoods.md)
|
||||||
|
- [DataTypeLandscapeValues](.//Models/DataTypeLandscapeValues.md)
|
||||||
- [EnumAlgorithmNames](.//Models/EnumAlgorithmNames.md)
|
- [EnumAlgorithmNames](.//Models/EnumAlgorithmNames.md)
|
||||||
|
- [EnumLandscapeMetric](.//Models/EnumLandscapeMetric.md)
|
||||||
- [EnumOptimiseMode](.//Models/EnumOptimiseMode.md)
|
- [EnumOptimiseMode](.//Models/EnumOptimiseMode.md)
|
||||||
|
- [EnumPollardGrowthRate](.//Models/EnumPollardGrowthRate.md)
|
||||||
- [EnumRucksackAlgorithm](.//Models/EnumRucksackAlgorithm.md)
|
- [EnumRucksackAlgorithm](.//Models/EnumRucksackAlgorithm.md)
|
||||||
|
- [EnumWalkMode](.//Models/EnumWalkMode.md)
|
||||||
|
|
||||||
|
|
||||||
<a name="documentation-for-authorization"></a>
|
<a name="documentation-for-authorization"></a>
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ Name | Type | Description | Notes
|
|||||||
**tsp** | [**AppOptions_tarjan**](AppOptions_tarjan.md) | | [default to null]
|
**tsp** | [**AppOptions_tarjan**](AppOptions_tarjan.md) | | [default to null]
|
||||||
**hirschberg** | [**AppOptions_hirschberg**](AppOptions_hirschberg.md) | | [default to null]
|
**hirschberg** | [**AppOptions_hirschberg**](AppOptions_hirschberg.md) | | [default to null]
|
||||||
**rucksack** | [**AppOptions_rucksack**](AppOptions_rucksack.md) | | [default to null]
|
**rucksack** | [**AppOptions_rucksack**](AppOptions_rucksack.md) | | [default to null]
|
||||||
|
**randomMinuswalk** | [**AppOptions_tarjan**](AppOptions_tarjan.md) | | [default to null]
|
||||||
|
**genetic** | [**AppOptions_tarjan**](AppOptions_tarjan.md) | | [default to null]
|
||||||
**euklid** | [**AppOptions_tarjan**](AppOptions_tarjan.md) | | [default to null]
|
**euklid** | [**AppOptions_tarjan**](AppOptions_tarjan.md) | | [default to null]
|
||||||
**pollardMinusrho** | [**AppOptions_tarjan**](AppOptions_tarjan.md) | | [default to null]
|
**pollardMinusrho** | [**AppOptions_tarjan**](AppOptions_tarjan.md) | | [default to null]
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
set shell := [ "bash", "-uc" ]
|
# set shell := [ "bash", "-uc" ]
|
||||||
_default:
|
_default:
|
||||||
@- just --unsorted --choose
|
@- just --unsorted --choose
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|||||||
@@ -44,4 +44,6 @@ def enter(*args: str):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.tracebacklimit = 0;
|
sys.tracebacklimit = 0;
|
||||||
|
# NOTE: necessary for Windows, to ensure that console output is rendered correctly:
|
||||||
|
os.system('');
|
||||||
enter(*sys.argv[1:]);
|
enter(*sys.argv[1:]);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
openapi: 3.0.3
|
openapi: 3.0.3
|
||||||
info:
|
info:
|
||||||
version: 0.3.0
|
version: 0.3.1
|
||||||
title: Schemata for command instructions
|
title: Schemata for command instructions
|
||||||
servers:
|
servers:
|
||||||
- url: "."
|
- url: "."
|
||||||
@@ -235,6 +235,7 @@ components:
|
|||||||
type: object
|
type: object
|
||||||
required:
|
required:
|
||||||
- name
|
- name
|
||||||
|
- growth
|
||||||
- number
|
- number
|
||||||
properties:
|
properties:
|
||||||
name:
|
name:
|
||||||
@@ -242,6 +243,8 @@ components:
|
|||||||
number:
|
number:
|
||||||
type: integer
|
type: integer
|
||||||
exclusiveMinimum: 0
|
exclusiveMinimum: 0
|
||||||
|
growth:
|
||||||
|
$ref: '#/components/schemas/EnumPollardGrowthRate'
|
||||||
x-init:
|
x-init:
|
||||||
type: integer
|
type: integer
|
||||||
default: 2
|
default: 2
|
||||||
@@ -327,6 +330,21 @@ components:
|
|||||||
- GREEDY
|
- GREEDY
|
||||||
- BRANCH-AND-BOUND
|
- BRANCH-AND-BOUND
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
# Enum Type for choice of growth rate in Pollard Algorithm
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
EnumPollardGrowthRate:
|
||||||
|
description: |-
|
||||||
|
Via the 'tail-chasing' period finding method in Pollard's rho algorithm,
|
||||||
|
the difference between the indexes of the pseudo-random sequence
|
||||||
|
can be chosen to growth according to different rates, e.g.
|
||||||
|
|
||||||
|
- `LINEAR` - choose `x[k]` and `x[2k]`
|
||||||
|
- `EXPONENTIAL` - choose `x[k]` and `x[2^{k}]`
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- LINEAR
|
||||||
|
- EXPONENTIAL
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
# Enum Type of walk mode for fitness walk algorithm
|
# Enum Type of walk mode for fitness walk algorithm
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
EnumWalkMode:
|
EnumWalkMode:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
openapi: 3.0.3
|
openapi: 3.0.3
|
||||||
info:
|
info:
|
||||||
version: 0.3.0
|
version: 0.3.1
|
||||||
title: Schemata for config models
|
title: Schemata for config models
|
||||||
servers:
|
servers:
|
||||||
- url: "."
|
- url: "."
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "uni-leipzig-ads-2-2022"
|
name = "uni-leipzig-ads-2-2022"
|
||||||
version = "0.3.0"
|
version = "0.3.1"
|
||||||
description = "Zusatzcode, um Algorithmen und Datenstrukturen im Kurs ADS2 zu demonstrieren."
|
description = "Zusatzcode, um Algorithmen und Datenstrukturen im Kurs ADS2 zu demonstrieren."
|
||||||
authors = [ "Raj Dahya" ]
|
authors = [ "Raj Dahya" ]
|
||||||
maintainers = [ "raj_mathe" ]
|
maintainers = [ "raj_mathe" ]
|
||||||
|
|||||||
@@ -12,5 +12,6 @@ from src.algorithms.pollard_rho.algorithms import *;
|
|||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'pollard_rho_algorithm',
|
'pollard_rho_algorithm_linear',
|
||||||
|
'pollard_rho_algorithm_exponential',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -18,14 +18,71 @@ from src.algorithms.pollard_rho.display import *;
|
|||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'pollard_rho_algorithm',
|
'pollard_rho_algorithm_linear',
|
||||||
|
'pollard_rho_algorithm_exponential',
|
||||||
];
|
];
|
||||||
|
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
# METHOD pollard's rho algorithm
|
# METHOD pollard's rho algorithm - with linear grwoth
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
def pollard_rho_algorithm(
|
def pollard_rho_algorithm_linear(
|
||||||
|
n: int,
|
||||||
|
x_init: int = 2,
|
||||||
|
verbose: bool = False,
|
||||||
|
):
|
||||||
|
steps = [];
|
||||||
|
success = False;
|
||||||
|
f = lambda _: fct(_, n=n);
|
||||||
|
|
||||||
|
d = 1;
|
||||||
|
x = y = x_init;
|
||||||
|
steps.append(Step(x=x));
|
||||||
|
k = 0;
|
||||||
|
k_next = 1;
|
||||||
|
|
||||||
|
while True:
|
||||||
|
# aktualisiere x: x = f(x_prev):
|
||||||
|
x = f(x);
|
||||||
|
# aktualisiere y: y = f(f(y_prev)):
|
||||||
|
y = f(f(y));
|
||||||
|
|
||||||
|
# ggT berechnen:
|
||||||
|
d = math.gcd(abs(x-y), n);
|
||||||
|
steps.append(Step(x=x, y=y, d=d));
|
||||||
|
|
||||||
|
# Abbruchkriterien prüfen:
|
||||||
|
if d == 1: # weitermachen, solange d == 1
|
||||||
|
k += 1;
|
||||||
|
continue;
|
||||||
|
elif d == n: # versagt
|
||||||
|
success = False;
|
||||||
|
break;
|
||||||
|
else:
|
||||||
|
success = True;
|
||||||
|
break;
|
||||||
|
|
||||||
|
if verbose:
|
||||||
|
repr = display_table_linear(steps=steps);
|
||||||
|
print('');
|
||||||
|
print('\x1b[1mEuklidescher Algorithmus\x1b[0m');
|
||||||
|
print('');
|
||||||
|
print(repr);
|
||||||
|
print('');
|
||||||
|
if success:
|
||||||
|
print('\x1b[1mBerechneter Faktor:\x1b[0m');
|
||||||
|
print('');
|
||||||
|
print(f'd = \x1b[1m{d}\x1b[0m.');
|
||||||
|
else:
|
||||||
|
print('\x1b[91mKein (Prim)faktor erkannt!\x1b[0m');
|
||||||
|
print('');
|
||||||
|
return d;
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
# METHOD pollard's rho algorithm - with exponential grwoth
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
def pollard_rho_algorithm_exponential(
|
||||||
n: int,
|
n: int,
|
||||||
x_init: int = 2,
|
x_init: int = 2,
|
||||||
verbose: bool = False,
|
verbose: bool = False,
|
||||||
@@ -64,7 +121,7 @@ def pollard_rho_algorithm(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
repr = display_table(steps=steps);
|
repr = display_table_exponential(steps=steps);
|
||||||
print('');
|
print('');
|
||||||
print('\x1b[1mEuklidescher Algorithmus\x1b[0m');
|
print('\x1b[1mEuklidescher Algorithmus\x1b[0m');
|
||||||
print('');
|
print('');
|
||||||
|
|||||||
@@ -16,14 +16,37 @@ from src.models.pollard_rho import *;
|
|||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'display_table',
|
'display_table_linear',
|
||||||
|
'display_table_exponential',
|
||||||
];
|
];
|
||||||
|
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
# METHOD display table
|
# METHOD display table - linear
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
def display_table(steps: List[Step]) -> str:
|
def display_table_linear(steps: List[Step]) -> str:
|
||||||
|
table = pd.DataFrame({
|
||||||
|
'i': [i for i in range(len(steps))],
|
||||||
|
'x': [step.x for step in steps],
|
||||||
|
'y': [step.y or '-' for step in steps],
|
||||||
|
'd': [step.d or '-' for step in steps],
|
||||||
|
}) \
|
||||||
|
.reset_index(drop=True);
|
||||||
|
# benutze pandas-Dataframe + tabulate, um schöner darzustellen:
|
||||||
|
repr = tabulate(
|
||||||
|
table,
|
||||||
|
headers=['i', 'x(i)', 'y(i) = x(2i)', 'gcd(|x - y|,n)'],
|
||||||
|
showindex=False,
|
||||||
|
colalign=('right', 'right', 'right', 'center'),
|
||||||
|
tablefmt='simple',
|
||||||
|
);
|
||||||
|
return repr;
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
# METHOD display table - exponential
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
def display_table_exponential(steps: List[Step]) -> str:
|
||||||
table = pd.DataFrame({
|
table = pd.DataFrame({
|
||||||
'i': [i for i in range(len(steps))],
|
'i': [i for i in range(len(steps))],
|
||||||
'x': [step.x for step in steps],
|
'x': [step.x for step in steps],
|
||||||
|
|||||||
@@ -26,9 +26,21 @@ __all__ = [
|
|||||||
|
|
||||||
@run_safely()
|
@run_safely()
|
||||||
def endpoint_pollard_rho(command: CommandPollard) -> Result[CallResult, CallError]:
|
def endpoint_pollard_rho(command: CommandPollard) -> Result[CallResult, CallError]:
|
||||||
result = pollard_rho_algorithm(
|
match command.growth:
|
||||||
n = command.number,
|
case EnumPollardGrowthRate.linear:
|
||||||
x_init = command.x_init,
|
result = pollard_rho_algorithm_linear(
|
||||||
verbose = config.OPTIONS.pollard_rho.verbose,
|
n = command.number,
|
||||||
);
|
x_init = command.x_init,
|
||||||
|
verbose = config.OPTIONS.pollard_rho.verbose,
|
||||||
|
);
|
||||||
|
pass;
|
||||||
|
case EnumPollardGrowthRate.exponential:
|
||||||
|
result = pollard_rho_algorithm_exponential(
|
||||||
|
n = command.number,
|
||||||
|
x_init = command.x_init,
|
||||||
|
verbose = config.OPTIONS.pollard_rho.verbose,
|
||||||
|
);
|
||||||
|
pass;
|
||||||
|
case _ as growth:
|
||||||
|
raise Exception(f'No algorithm implemented for \x1b[1m{growth.value}\x1b[0m as growth rate.');
|
||||||
return Ok(CallResult(action_taken=True, message=result));
|
return Ok(CallResult(action_taken=True, message=result));
|
||||||
|
|||||||
1
notes/.gitignore
vendored
1
notes/.gitignore
vendored
@@ -16,6 +16,7 @@
|
|||||||
!/notes.tex
|
!/notes.tex
|
||||||
!/notes.pdf
|
!/notes.pdf
|
||||||
!/woche*.pdf
|
!/woche*.pdf
|
||||||
|
!/*.csv
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# Git Keep
|
# Git Keep
|
||||||
|
|||||||
34
notes/merfachesrucksack.csv
Normal file
34
notes/merfachesrucksack.csv
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
;;;i (Kosten);;;;;;;;;;;;;;;;;
|
||||||
|
j;Objekt[j];;0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17
|
||||||
|
;;value;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0
|
||||||
|
;;cost;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-
|
||||||
|
;;;;;;;;;;;;;;;;;;;;
|
||||||
|
1;A;value[i – cost[j]];;;;0;1;2;3;4;5;6;7;8;9;10;11;12;13;14
|
||||||
|
cost[j];3;… + value[j];;;;4;4;4;8;8;8;12;12;12;16;16;16;20;20;20
|
||||||
|
value[j];4;besser?;;;;WAHR;WAHR;WAHR;WAHR;WAHR;WAHR;WAHR;WAHR;WAHR;WAHR;WAHR;WAHR;WAHR;WAHR;WAHR
|
||||||
|
;;best-value;0;0;0;4;4;4;8;8;8;12;12;12;16;16;16;20;20;20
|
||||||
|
;;best-object;-;-;-;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A
|
||||||
|
;;;;;;;;;;;;;;;;;;;;
|
||||||
|
2;B;value[i – cost[j]];;;;;0;1;2;3;4;5;6;7;8;9;10;11;12;13
|
||||||
|
cost[j];4;… + value[j];;;;;5;5;5;9;10;10;13;14;15;17;18;19;21;22
|
||||||
|
value[j];5;besser?;;;;;WAHR;WAHR;;WAHR;WAHR;;WAHR;WAHR;;WAHR;WAHR;;WAHR;WAHR
|
||||||
|
;;value;0;0;0;4;5;5;8;9;10;12;13;14;16;17;18;20;21;22
|
||||||
|
;;cost;-;-;-;A;B;B;A;B;B;A;B;B;A;B;B;A;B;B
|
||||||
|
;;;;;;;;;;;;;;;;;;;;
|
||||||
|
3;C;value[i – cost[j]];;;;;;;;0;1;2;3;4;5;6;7;8;9;10
|
||||||
|
cost[j];7;… + value[j];;;;;;;;10;10;10;14;15;15;18;20;20;22;24
|
||||||
|
value[j];10;besser?;;;;;;;;WAHR;;;WAHR;WAHR;;WAHR;WAHR;;WAHR;WAHR
|
||||||
|
;;value;0;0;0;4;5;5;8;10;10;12;14;15;16;18;20;20;22;24
|
||||||
|
;;cost;-;-;-;A;B;B;A;C;B;A;C;C;A;C;C;A;C;C
|
||||||
|
;;;;;;;;;;;;;;;;;;;;
|
||||||
|
4;D;value[i – cost[j]];;;;;;;;;0;1;2;3;4;5;6;7;8;9
|
||||||
|
cost[j];8;… + value[j];;;;;;;;;11;11;11;15;16;16;19;21;22;23
|
||||||
|
value[j];11;besser?;;;;;;;;;WAHR;;;;;;;WAHR;;
|
||||||
|
;;value;0;0;0;4;5;5;8;10;11;12;14;15;16;18;20;21;22;24
|
||||||
|
;;cost;-;-;-;A;B;B;A;C;D;A;C;C;A;C;C;D;C;C
|
||||||
|
;;;;;;;;;;;;;;;;;;;;
|
||||||
|
5;E;value[i – cost[j]];;;;;;;;;;0;1;2;3;4;5;6;7;8
|
||||||
|
cost[j];9;… + value[j];;;;;;;;;;13;13;13;17;18;18;21;23;24
|
||||||
|
value[j];13;besser?;;;;;;;;;;WAHR;;;WAHR;;;;WAHR;
|
||||||
|
;;value;0;0;0;4;5;5;8;10;11;13;14;15;17;18;20;21;23;24
|
||||||
|
;;cost;-;-;-;A;B;B;A;C;D;E;C;C;E;C;C;D;E;C
|
||||||
|
@@ -17,6 +17,5 @@ Inhaltsverzeichnis
|
|||||||
- [Vorlesungswoche 11](./woche11.md)
|
- [Vorlesungswoche 11](./woche11.md)
|
||||||
- [Vorlesungswoche 12](./woche12.md)
|
- [Vorlesungswoche 12](./woche12.md)
|
||||||
- [Vorlesungswoche 13](./woche13.md)
|
- [Vorlesungswoche 13](./woche13.md)
|
||||||
<!--
|
|
||||||
- [Vorlesungswoche 14](./woche14.md)
|
- [Vorlesungswoche 14](./woche14.md)
|
||||||
-->
|
- [Vorlesungswoche 15](./woche15.md)
|
||||||
|
|||||||
15
protocol/woche14.md
Normal file
15
protocol/woche14.md
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Vorlesungswoche 14 (4.–10. Juli 2022) #
|
||||||
|
|
||||||
|
## Agenda ##
|
||||||
|
|
||||||
|
- Wiederholung
|
||||||
|
- Netze/Flüsse: Restgraphen, Push, Relabel.
|
||||||
|
- Gomory-Hu
|
||||||
|
- Branch & Bound: Rucksack, TSP.
|
||||||
|
- Matrixmultkiplikation
|
||||||
|
- Matroiden, Greedy
|
||||||
|
- Genetischer Algorithmus
|
||||||
|
|
||||||
|
### Nächste Woche/n ###
|
||||||
|
|
||||||
|
- Wiederholung zur Klausurvorbereitung
|
||||||
83
protocol/woche15.md
Normal file
83
protocol/woche15.md
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
# Vorlesungswoche 15 (11.–17. Juli 2022) #
|
||||||
|
|
||||||
|
## Agenda ##
|
||||||
|
|
||||||
|
- Wiederholung
|
||||||
|
- Alle genetischen Algorithmen im Kurs, inkl. letzter VL, Bsp. aus freiwilligen Übungsblättern.
|
||||||
|
- Branch & Bound: Rucksack, TSP.
|
||||||
|
- Dynamisches Programmieren.
|
||||||
|
- Matroiden: Versprecher letzte Woche
|
||||||
|
</br>
|
||||||
|
```
|
||||||
|
Ich sagte:
|
||||||
|
|A| < |B| ==> es gibt x ∈ E s.d. A u {x} ∈ M
|
||||||
|
|
||||||
|
Das ist zwar nicht falsch, aber nicht die ganze Aussage.
|
||||||
|
Es hätte so lauten sollen:
|
||||||
|
|A| < |B| ==> es gibt x ∈ B\A s.d. A u {x} ∈ M
|
||||||
|
```
|
||||||
|
- Pollard-Rho: Die Rolle der Primzahlen und die Funktion `φ(n)`.
|
||||||
|
|
||||||
|
### Anmerkung ###
|
||||||
|
|
||||||
|
Wir haben mal kurz über Editoren für Notizen geredet. Einerseits gibt es Word (iiiiii) und **LaTeX** (schönes Rendering, nicht so schöne Syntax).
|
||||||
|
Dann gibt es immer plaintext. Aber eine Stufe besser ist **Markdown**. Markdown hat die folgenden Vorteile:
|
||||||
|
|
||||||
|
- Nur plaintext Dateien (d.h. keine riesige XML-Objekte im Hintergrund).
|
||||||
|
- Sehr simple Syntax (bspw. `**fett**`, `_kursiv_`, usw.).
|
||||||
|
- **Keine Kompilation** nötig—nur ein guter Renderer.
|
||||||
|
- Komplexe Textformats mit sehr intuitiver Syntax möglich:
|
||||||
|
- Überschriften
|
||||||
|
- Listen
|
||||||
|
- Tabellen. Z. B. man gibt
|
||||||
|
```
|
||||||
|
| Objekt | Kosten | Wert |
|
||||||
|
| :----: | -----: | ---: |
|
||||||
|
| Apfel | 1,30€ | 301 |
|
||||||
|
| Orange | 2€ | 440 |
|
||||||
|
```
|
||||||
|
ein und bekommt
|
||||||
|
|
||||||
|
| Objekt | Kosten | Wert |
|
||||||
|
| :----: | -----: | ---: |
|
||||||
|
| Apfel | 1,30€ | 301 |
|
||||||
|
| Orange | 2€ | 440 |
|
||||||
|
|
||||||
|
raus.
|
||||||
|
- Code Blocks (in diversen Sprachen). Z. B. man gibt
|
||||||
|
```
|
||||||
|
'''java
|
||||||
|
public class HelloWorld {
|
||||||
|
public static void main (String[] args) {
|
||||||
|
System.out.println("Hello World!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
```
|
||||||
|
(mit Backticks statt `'''`) und bekommt
|
||||||
|
```java
|
||||||
|
public class HelloWorld {
|
||||||
|
public static void main (String[] args) {
|
||||||
|
System.out.println("Hello World!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
raus.
|
||||||
|
|
||||||
|
- URIs
|
||||||
|
- interne Verlinkungen!
|
||||||
|
- sogar Mathe-Formeln mit (simplem) LaTeX-Code
|
||||||
|
|
||||||
|
Man braucht lediglich einen Renderer für Vorschau-Zwecken.
|
||||||
|
Hier ein paar Empfehlungen:
|
||||||
|
|
||||||
|
- VSCode + passende markdown Extensions (alles gratis)
|
||||||
|
- Typora (nicht gratis, aber für mich hat es sich gelohnt). Siehe bspw. <https://support.typora.io/Math>. Der Editor rendert sogar LaTeX-Formeln, und hat einen WYSIWYG-Modus.
|
||||||
|
- online Editoren wie
|
||||||
|
- https://cryptpad.linxx.net -> Markdown-Folien
|
||||||
|
- https://dillinger.io
|
||||||
|
- In Git-Repos (wie dieser hier!) werden **md**-Dateien automatisch gerendert!
|
||||||
|
|
||||||
|
### Nächste Woche/n ###
|
||||||
|
|
||||||
|
- Keine Übung, sondern die Klausur! Viel Erfolg!
|
||||||
Reference in New Issue
Block a user