diff options
| author | bozokopic <bozo.kopic@gmail.com> | 2018-04-10 15:50:59 +0200 |
|---|---|---|
| committer | bozokopic <bozo.kopic@gmail.com> | 2018-04-10 15:50:59 +0200 |
| commit | 5e3c2fe8a5fec84f6d480da9511441168aea8dad (patch) | |
| tree | 098bd1994e531a219e01c32b9d41c7b082dadea2 /src_py | |
| parent | faeeb9ef7c8253fb4273b6bf5e340ad24883d9e8 (diff) | |
playground - test csp
Diffstat (limited to 'src_py')
| -rw-r--r-- | src_py/opcut/csp.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src_py/opcut/csp.py b/src_py/opcut/csp.py index 04a6d39..209acec 100644 --- a/src_py/opcut/csp.py +++ b/src_py/opcut/csp.py @@ -14,15 +14,15 @@ State = util.namedtuple( Panel = util.namedtuple( 'Panel', + ['id', 'Any'], ['width', 'float'], - ['height', 'float'], - ['label', 'str']) + ['height', 'float']) Item = util.namedtuple( 'Item', + ['id', 'Any'], ['width', 'float'], ['height', 'float'], - ['label', 'str'], ['rotate', 'bool']) Used = util.namedtuple( @@ -33,7 +33,7 @@ Used = util.namedtuple( ['y', 'float'], ['rotate', 'bool']) -Unused = util.namespace( +Unused = util.namedtuple( 'Unused', ['panel', 'Panel'], ['width', 'float'], @@ -189,9 +189,9 @@ def _fitness(state): result = 0 for panel in state.panels: used_areas = [used.item.width * used.item.height - for used in panel.used] + for used in state.used] unused_areas = [unused.width * unused.height - for unused in panel.unused] + for unused in state.unused] result += (panel.width * panel.height - sum(used_areas)) / total_area result -= (_fitness_K * min(used_areas, default=0) * max(unused_areas, default=0) / |
