[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 13/20: grc: super-secret
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 13/20: grc: super-secret |
Date: |
Fri, 28 Aug 2015 19:19:52 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 702b5b86a14ded6262461ac44cd9e8daa2075cd3
Author: Seth Hitefield <address@hidden>
Date: Fri Aug 28 13:55:29 2015 -0400
grc: super-secret
---
grc/base/FlowGraph.py | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++
grc/blocks/options.xml | 6 ++++++
2 files changed, 61 insertions(+)
diff --git a/grc/base/FlowGraph.py b/grc/base/FlowGraph.py
index 52ec741..68b5eaa 100644
--- a/grc/base/FlowGraph.py
+++ b/grc/base/FlowGraph.py
@@ -18,6 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA
"""
import time
+import math
from . import odict
from Element import Element
from .. gui import Messages
@@ -63,6 +64,58 @@ class FlowGraph(Element):
def __str__(self):
return 'FlowGraph - %s(%s)' % (self.get_option('title'),
self.get_option('id'))
+ def get_complexity(self):
+ """
+ Determines the complexity of a flowgraph
+ """
+ dbal = 0
+ block_list = self.get_blocks()
+ for block in block_list:
+ # Skip options block
+ if block.get_key() == 'options':
+ continue
+
+ # Don't worry about optional sinks?
+ sink_list = filter(lambda c: not c.get_optional(),
block.get_sinks())
+ source_list = filter(lambda c: not c.get_optional(),
block.get_sources())
+ sinks = float(len(sink_list))
+ sources = float(len(source_list))
+ base = max(min(sinks, sources), 1)
+
+ # Port ratio multiplier
+ if min(sinks, sources) > 0:
+ multi = sinks / sources
+ multi = (1 / multi) if multi > 1 else multi
+ else:
+ multi = 1
+
+ # Connection ratio multiplier
+ sink_multi = max(float(sum(map(lambda c: len(c.get_connections()),
sink_list)) / max(sinks, 1.0)), 1.0)
+ source_multi = max(float(sum(map(lambda c:
len(c.get_connections()), source_list)) / max(sources, 1.0)), 1.0)
+ dbal = dbal + (base * multi * sink_multi * source_multi)
+
+ elements = float(len(self.get_elements()))
+ connections = float(len(self.get_connections()))
+ disabled_connections = len(filter(lambda c: not c.get_enabled(),
self.get_connections()))
+ blocks = float(len(block_list))
+ variables = elements - blocks - connections
+ enabled = float(len(self.get_enabled_blocks()))
+
+ # Disabled multiplier
+ if enabled > 0:
+ disabled_multi = 1 / (max(1 - ((blocks - enabled) / max(blocks,
1)), 0.05))
+ else:
+ disabled_multi = 1
+
+ # Connection multiplier (How many connections )
+ if (connections - disabled_connections) > 0:
+ conn_multi = 1 / (max(1 - (disabled_connections / max(connections,
1)), 0.05))
+ else:
+ conn_multi = 1
+
+ final = round(max((dbal - 1) * disabled_multi * conn_multi *
connections, 0.0) / 1000000, 6)
+ return final
+
def rewrite(self):
def refactor_bus_structure():
@@ -99,6 +152,8 @@ class FlowGraph(Element):
for child in self.get_children(): child.rewrite()
refactor_bus_structure();
+ # Update the complexity
+
self._options_block.get_param('complexity').set_value(self.get_complexity())
def get_option(self, key):
"""
diff --git a/grc/blocks/options.xml b/grc/blocks/options.xml
index dc02b83..8502fc3 100644
--- a/grc/blocks/options.xml
+++ b/grc/blocks/options.xml
@@ -178,6 +178,12 @@ part#slurp
</option>
<tab>Advanced</tab>
</param>
+ <param>
+ <name>Complexity</name>
+ <key>complexity</key>
+ <value>0</value>
+ <type>float</type>
+ </param>
<check>not $window_size or len($window_size) == 2</check>
<check>not $window_size or 300 <= $(window_size)[0] <=
4096</check>
<check>not $window_size or 300 <= $(window_size)[1] <=
4096</check>
- [Commit-gnuradio] [gnuradio] 06/20: grc: add warning for invalid xterm setting (fixes #828), (continued)
- [Commit-gnuradio] [gnuradio] 06/20: grc: add warning for invalid xterm setting (fixes #828), git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 05/20: grc: rewrite Preferences.py, git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 16/20: Merge remote-tracking branch 'ckuethe/trap_import_errors', git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 17/20: Merge remote-tracking branch 'saikwolf/qt_themeing', git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 11/20: clarify missing module exception., git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 07/20: grc: move gui prefs file to ~/.gnuradio/grc.conf, git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 20/20: Merge branch 'maint', git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 19/20: Merge remote-tracking branch 'gnuradio-wg-grc/master_grcwg', git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 04/20: grc: clean-up ActionHandler.py imports, git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 14/20: Merge remote-tracking branch 'estatz/qtgui_trigger_callbacks', git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 13/20: grc: super-secret,
git <=
- [Commit-gnuradio] [gnuradio] 10/20: grc: show cmdline when xterm is used, git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 12/20: qtgui: Modified the qproperties to scale the colorbar title from the .qss file, git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 18/20: Merge remote-tracking branch 'sdh11/complexity', git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 15/20: Merge remote-tracking branch 'tom/docs/sphinx_update', git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 03/20: grc: have cmake find a xterm executable on UNIX, git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 08/20: whitespace fixes and some minor adjustments for building the Python manual., git, 2015/08/28
- [Commit-gnuradio] [gnuradio] 09/20: docs: Reviving Python manual., git, 2015/08/28