Skip to content

Commit e332d24

Browse files
EzetowersEzequiel Torres
authored andcommitted
Added Draw as Tree functionality
1 parent 9e17d54 commit e332d24

File tree

12 files changed

+161
-53
lines changed

12 files changed

+161
-53
lines changed

MLC/Common/LispTreeExpr/LispTreeExpr.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
import MLC.Log.log as lg
2323
import networkx as nx
24+
import matplotlib
25+
matplotlib.use("Qt5Agg")
2426
import matplotlib.pyplot as plt
2527
import re
2628

MLC/GUI/Autogenerated/autogenerated.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1686,6 +1686,9 @@ def setupUi(self, ExperimentWindow):
16861686
self.genealogy_button = QtWidgets.QPushButton(self.groupBox_8)
16871687
self.genealogy_button.setObjectName("genealogy_button")
16881688
self.verticalLayout_5.addWidget(self.genealogy_button)
1689+
self.draw_as_tree_button = QtWidgets.QPushButton(self.groupBox_8)
1690+
self.draw_as_tree_button.setObjectName("draw_as_tree_button")
1691+
self.verticalLayout_5.addWidget(self.draw_as_tree_button)
16891692
self.verticalLayout_11.addWidget(self.groupBox_8)
16901693
spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
16911694
self.verticalLayout_11.addItem(spacerItem1)
@@ -1793,7 +1796,7 @@ def setupUi(self, ExperimentWindow):
17931796
ExperimentWindow.setCentralWidget(self.centralWidget)
17941797

17951798
self.retranslateUi(ExperimentWindow)
1796-
self.tabWidget.setCurrentIndex(0)
1799+
self.tabWidget.setCurrentIndex(1)
17971800
self.next_gen_button.clicked.connect(ExperimentWindow.on_next_gen_button_clicked)
17981801
self.save_config_button.clicked.connect(ExperimentWindow.on_save_config_button_clicked)
17991802
self.show_all_check.clicked.connect(ExperimentWindow.on_show_all_check_clicked)
@@ -1830,6 +1833,7 @@ def setupUi(self, ExperimentWindow):
18301833
self.exp_gen_count_combo.activated['QString'].connect(ExperimentWindow.on_gen_count_combo_changed)
18311834
self.exp_prov_gen_button.clicked.connect(ExperimentWindow.on_prev_gen_button_clicked)
18321835
self.exp_next_gen_button.clicked.connect(ExperimentWindow.on_next_gen_button_clicked)
1836+
self.draw_as_tree_button.clicked.connect(ExperimentWindow.on_draw_as_tree_button_clicked)
18331837
# QtCore.QMetaObject.connectSlotsByName(ExperimentWindow)
18341838
ExperimentWindow.setTabOrder(self.textEdit, self.max_cost_combo)
18351839
ExperimentWindow.setTabOrder(self.max_cost_combo, self.min_cost_combo)
@@ -1923,6 +1927,7 @@ def retranslateUi(self, ExperimentWindow):
19231927
self.best_indiv_button.setText(_translate("ExperimentWindow", "Best Individual"))
19241928
self.convergence_button.setText(_translate("ExperimentWindow", "Convergence"))
19251929
self.genealogy_button.setText(_translate("ExperimentWindow", "Genealogy"))
1930+
self.draw_as_tree_button.setText(_translate("ExperimentWindow", "Draw As Tree"))
19261931
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("ExperimentWindow", "Results"))
19271932
self.groupBox.setTitle(_translate("ExperimentWindow", "Experiment properties"))
19281933
self.import_config_button.setText(_translate("ExperimentWindow", "Import"))

MLC/GUI/Autogenerated/mlc_qtcreator/experiment.ui

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<enum>QTabWidget::North</enum>
4343
</property>
4444
<property name="currentIndex">
45-
<number>0</number>
45+
<number>1</number>
4646
</property>
4747
<widget class="QWidget" name="experiment_tab">
4848
<property name="layoutDirection">
@@ -651,6 +651,13 @@
651651
</property>
652652
</widget>
653653
</item>
654+
<item>
655+
<widget class="QPushButton" name="draw_as_tree_button">
656+
<property name="text">
657+
<string>Draw As Tree</string>
658+
</property>
659+
</widget>
660+
</item>
654661
</layout>
655662
</widget>
656663
</item>
@@ -1505,6 +1512,22 @@
15051512
</hint>
15061513
</hints>
15071514
</connection>
1515+
<connection>
1516+
<sender>draw_as_tree_button</sender>
1517+
<signal>clicked()</signal>
1518+
<receiver>ExperimentWindow</receiver>
1519+
<slot>on_draw_as_tree_button_clicked()</slot>
1520+
<hints>
1521+
<hint type="sourcelabel">
1522+
<x>816</x>
1523+
<y>517</y>
1524+
</hint>
1525+
<hint type="destinationlabel">
1526+
<x>482</x>
1527+
<y>406</y>
1528+
</hint>
1529+
</hints>
1530+
</connection>
15081531
</connections>
15091532
<slots>
15101533
<slot>on_closed_dialog()</slot>
@@ -1536,5 +1559,6 @@
15361559
<slot>on_gen_start_over_button_clicked()</slot>
15371560
<slot>on_test_preev_indiv_button_clicked()</slot>
15381561
<slot>on_disable_arduino_toggle()</slot>
1562+
<slot>on_draw_as_tree_button_clicked()</slot>
15391563
</slots>
15401564
</ui>

MLC/GUI/Common/util.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,7 @@ def add_permissions_to_file(filepath, permissions, user_password=None):
148148
os.system('sudo -K')
149149
return cmd_error_code == 0
150150
else:
151-
return os.system(cmd) == 0
151+
return os.system(cmd) == 0
152+
153+
def get_individual_tree(indiv_value):
154+
return LispTreeExpr(indiv_value)

MLC/GUI/Experiment/ExperimentWindow.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from MLC.Log.log import get_gui_logger
3131
from MLC.GUI.Common.util import test_individual_value
3232
from MLC.GUI.Common.util import check_if_indiv_pass_preevaluation
33+
from MLC.GUI.Common.util import get_individual_tree
3334
from MLC.GUI.Autogenerated.autogenerated import Ui_ExperimentWindow
3435
from MLC.GUI.Experiment.ArduinoConfigManager.ArduinoBoardManager import ArduinoBoardManager
3536
from MLC.GUI.Experiment.ChartConfiguration import ChartConfiguration
@@ -462,6 +463,22 @@ def on_genealogy_button_clicked(self):
462463
experiment_name=self._experiment_name)
463464
dialog.show()
464465

466+
def on_draw_as_tree_button_clicked(self):
467+
logger.debug('[EXPERIMENT {0}] [DRAW_AS_TREE_BUTTON] - Executing on_genealogy_button_clicked function')
468+
469+
# Ask the user which Individual he would like to have displayed
470+
indivs_per_gen = Config.get_instance().getint("POPULATION", "size")
471+
individuals_list = [str(x) for x in xrange(1, indivs_per_gen + 1)]
472+
473+
indiv = QInputDialog.getItem(self, "Individual Tree",
474+
"Select the individual you would like to draw",
475+
individuals_list, 0, False)
476+
477+
if indiv[1] == True:
478+
gen_data = self._individuals_per_generation[self._current_gen - 1]
479+
indiv_tree = get_individual_tree(gen_data[int(indiv[0])][5])
480+
indiv_tree.draw()
481+
465482
def on_board_config_button_clicked(self):
466483
logger.debug('[EXPERIMENT {0}] [BOARD_CONFIG_BUTTON] - '
467484
'Executing on_board_config_button_clicked function'

bugs/precision_bug/expr_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def initialize_config():
5252
expr612 = "(root (- -6.3726 (* -7.1746 S0)))"
5353

5454
tree = LispTreeExpr(expr6)
55+
tree.draw()
5556
x = np.linspace(-10.0, 10.0, num=201)
5657
mlc_y = tree.calculate_expression([x])
5758

tools/installer/Dockerfiles/centos7.dockerfile

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ RUN wget -q https://pypi.python.org/packages/source/s/setuptools/setuptools-20.1
9494
RUN wget -q https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb && \
9595
tar xzvf pip-8.0.2.tar.gz && \
9696
cd pip-8.0.2 && /opt/mlc-python-2.7.11/bin/mlc_python setup.py build && /opt/mlc-python-2.7.11/bin/mlc_python setup.py install && \
97-
rm -rf /tmp/pip-8.0.2* && \
98-
/opt/mlc-python-2.7.11/bin/mlc_pip install --upgrade pip
97+
rm -rf /tmp/pip-8.0.2*
98+
99+
RUN /opt/mlc-python-2.7.11/bin/mlc_pip install --upgrade pip
99100

100101
RUN /opt/mlc-python-2.7.11/bin/mlc_pip install --upgrade pip
101102

@@ -133,14 +134,25 @@ RUN wget http://www.graphviz.org/pub/graphviz/stable/SOURCES/graphviz-2.40.1.tar
133134
tar xzvf graphviz-2.40.1.tar.gz && \
134135
cd graphviz-2.40.1 && \
135136
./configure --prefix=/tmp/graphviz-2.40.1 && \
136-
make -j4 && make install && \
137-
mkdir -p /opt/mlc-python-2.7.11/custom_libs /opt/mlc-python-2.7.11/custom_bins && \
138-
cp -r /tmp/graphviz-2.40.1/lib/* /opt/mlc-python-2.7.11/custom_libs && \
137+
make -j4 && make install
138+
139+
# Install mlc dependencies
140+
# Create .sh who will load the desired enviroment to run nosetests within it
141+
RUN export CFLAGS="-I/tmp/graphviz-2.40.1/include" \
142+
export LD_LIBRARY_PATH=/opt/mlc-python-2.7.11/custom_libs:$LD_LIBRARY_PATH && \
143+
export LD_LIBRARY_PATH=/opt/mlc-python-2.7.11/Qt-5.7.1/lib:$LD_LIBRARY_PATH && \
144+
export LD_LIBRARY_PATH=/tmp/graphviz-2.40.1/lib:$LD_LIBRARY_PATH && \
145+
export PKG_CONFIG_PATH=/tmp/graphviz-2.40.1/lib/pkgconfig:$PKG_CONFIG_PATH && \
146+
export PATH=/opt/mlc-python-2.7.11/Qt-5.7.1/bin:$PATH && \
147+
export PATH=/opt/mlc-python-2.7.11/custom_bins:$PATH && \
148+
export PATH=/tmp/graphviz-2.40.1/bin:$PATH && \
149+
/opt/mlc-python-2.7.11/bin/mlc_pip install networkx pydotplus pygraphviz 'ipython<6.0.0' numpy flask requests pyserial nose pyyaml coverage matplotlib scipy pyusb
150+
151+
RUN mkdir -p /opt/mlc-python-2.7.11/custom_libs /opt/mlc-python-2.7.11/custom_bins && \
152+
cp -r /tmp/graphviz-2.40.1/lib/*.so* /tmp/graphviz-2.40.1/lib/graphviz /opt/mlc-python-2.7.11/custom_libs && \
139153
cp -r /tmp/graphviz-2.40.1/bin/* /opt/mlc-python-2.7.11/custom_bins && \
140154
rm -rf /tmp/graphviz-2.40.1*
141155

142-
# Install mlc dependencies
143-
RUN /opt/mlc-python-2.7.11/bin/mlc_pip install networkx pydotplus pygraphviz 'ipython<6.0.0' pyserial numpy nose matplotlib scipy pyyaml flask requests pyusb
144156
RUN gem install fpm
145157

146158
ARG RELEASE

tools/installer/Dockerfiles/debian8.dockerfile

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ RUN wget -q https://pypi.python.org/packages/source/s/setuptools/setuptools-20.1
120120
RUN wget -q https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb && \
121121
tar xzvf pip-8.0.2.tar.gz && \
122122
cd pip-8.0.2 && /opt/mlc-python-2.7.11/bin/mlc_python setup.py build && /opt/mlc-python-2.7.11/bin/mlc_python setup.py install && \
123-
rm -rf /tmp/pip-8.0.2* && \
124-
/opt/mlc-python-2.7.11/bin/mlc_pip install --upgrade pip
123+
rm -rf /tmp/pip-8.0.2*
124+
125+
RUN /opt/mlc-python-2.7.11/bin/mlc_pip install --upgrade pip
125126

126127
RUN /opt/mlc-python-2.7.11/bin/mlc_pip install --upgrade pip
127128

@@ -159,18 +160,25 @@ RUN wget http://www.graphviz.org/pub/graphviz/stable/SOURCES/graphviz-2.40.1.tar
159160
tar xzvf graphviz-2.40.1.tar.gz && \
160161
cd graphviz-2.40.1 && \
161162
./configure --prefix=/tmp/graphviz-2.40.1 && \
162-
make -j4 && make install && \
163-
mkdir -p /opt/mlc-python-2.7.11/custom_libs /opt/mlc-python-2.7.11/custom_bins && \
164-
cp -r /tmp/graphviz-2.40.1/lib/* /opt/mlc-python-2.7.11/custom_libs && \
165-
cp -r /tmp/graphviz-2.40.1/bin/* /opt/mlc-python-2.7.11/custom_bins && \
166-
rm -rf /tmp/graphviz-2.40.1*
163+
make -j4 && make install
167164

168165
# Install mlc dependencies
169166
# Create .sh who will load the desired enviroment to run nosetests within it
170-
RUN export LD_LIBRARY_PATH=/usr/local/Qt-5.7.1/lib:$LD_LIBRARY_PATH && \
171-
export PATH=/usr/local/Qt-5.7.1/bin:$PATH && \
167+
RUN export CFLAGS="-I/tmp/graphviz-2.40.1/include" \
168+
export LD_LIBRARY_PATH=/opt/mlc-python-2.7.11/custom_libs:$LD_LIBRARY_PATH && \
169+
export LD_LIBRARY_PATH=/opt/mlc-python-2.7.11/Qt-5.7.1/lib:$LD_LIBRARY_PATH && \
170+
export LD_LIBRARY_PATH=/tmp/graphviz-2.40.1/lib:$LD_LIBRARY_PATH && \
171+
export PKG_CONFIG_PATH=/tmp/graphviz-2.40.1/lib/pkgconfig:$PKG_CONFIG_PATH && \
172+
export PATH=/opt/mlc-python-2.7.11/Qt-5.7.1/bin:$PATH && \
173+
export PATH=/opt/mlc-python-2.7.11/custom_bins:$PATH && \
174+
export PATH=/tmp/graphviz-2.40.1/bin:$PATH && \
172175
/opt/mlc-python-2.7.11/bin/mlc_pip install networkx pydotplus pygraphviz 'ipython<6.0.0' numpy flask requests pyserial nose pyyaml coverage matplotlib scipy pyusb
173176

177+
RUN mkdir -p /opt/mlc-python-2.7.11/custom_libs /opt/mlc-python-2.7.11/custom_bins && \
178+
cp -r /tmp/graphviz-2.40.1/lib/*.so* /tmp/graphviz-2.40.1/lib/graphviz /opt/mlc-python-2.7.11/custom_libs && \
179+
cp -r /tmp/graphviz-2.40.1/bin/* /opt/mlc-python-2.7.11/custom_bins && \
180+
rm -rf /tmp/graphviz-2.40.1*
181+
174182
RUN gem install fpm
175183

176184
ARG RELEASE

tools/installer/Dockerfiles/fedora20.dockerfile

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ RUN wget -q https://pypi.python.org/packages/source/s/setuptools/setuptools-20.1
101101
RUN wget -q https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb && \
102102
tar xzvf pip-8.0.2.tar.gz && \
103103
cd pip-8.0.2 && /opt/mlc-python-2.7.11/bin/mlc_python setup.py build && /opt/mlc-python-2.7.11/bin/mlc_python setup.py install && \
104-
rm -rf /tmp/pip-8.0.2* && \
105-
/opt/mlc-python-2.7.11/bin/mlc_pip install --upgrade pip
104+
rm -rf /tmp/pip-8.0.2*
105+
106+
RUN /opt/mlc-python-2.7.11/bin/mlc_pip install --upgrade pip
106107

107108
RUN /opt/mlc-python-2.7.11/bin/mlc_pip install --upgrade pip
108109

@@ -140,14 +141,25 @@ RUN wget http://www.graphviz.org/pub/graphviz/stable/SOURCES/graphviz-2.40.1.tar
140141
tar xzvf graphviz-2.40.1.tar.gz && \
141142
cd graphviz-2.40.1 && \
142143
./configure --prefix=/tmp/graphviz-2.40.1 && \
143-
make -j4 && make install && \
144-
mkdir -p /opt/mlc-python-2.7.11/custom_libs /opt/mlc-python-2.7.11/custom_bins && \
145-
cp -r /tmp/graphviz-2.40.1/lib/* /opt/mlc-python-2.7.11/custom_libs && \
144+
make -j4 && make install
145+
146+
# Install mlc dependencies
147+
# Create .sh who will load the desired enviroment to run nosetests within it
148+
RUN export CFLAGS="-I/tmp/graphviz-2.40.1/include" \
149+
export LD_LIBRARY_PATH=/opt/mlc-python-2.7.11/custom_libs:$LD_LIBRARY_PATH && \
150+
export LD_LIBRARY_PATH=/opt/mlc-python-2.7.11/Qt-5.7.1/lib:$LD_LIBRARY_PATH && \
151+
export LD_LIBRARY_PATH=/tmp/graphviz-2.40.1/lib:$LD_LIBRARY_PATH && \
152+
export PKG_CONFIG_PATH=/tmp/graphviz-2.40.1/lib/pkgconfig:$PKG_CONFIG_PATH && \
153+
export PATH=/opt/mlc-python-2.7.11/Qt-5.7.1/bin:$PATH && \
154+
export PATH=/opt/mlc-python-2.7.11/custom_bins:$PATH && \
155+
export PATH=/tmp/graphviz-2.40.1/bin:$PATH && \
156+
/opt/mlc-python-2.7.11/bin/mlc_pip install networkx pydotplus pygraphviz 'ipython<6.0.0' numpy flask requests pyserial nose pyyaml coverage matplotlib scipy pyusb
157+
158+
RUN mkdir -p /opt/mlc-python-2.7.11/custom_libs /opt/mlc-python-2.7.11/custom_bins && \
159+
cp -r /tmp/graphviz-2.40.1/lib/*.so* /tmp/graphviz-2.40.1/lib/graphviz /opt/mlc-python-2.7.11/custom_libs && \
146160
cp -r /tmp/graphviz-2.40.1/bin/* /opt/mlc-python-2.7.11/custom_bins && \
147161
rm -rf /tmp/graphviz-2.40.1*
148162

149-
# Install mlc dependencies
150-
RUN /opt/mlc-python-2.7.11/bin/mlc_pip install networkx pydotplus pygraphviz 'ipython<6.0.0' pyserial numpy nose matplotlib scipy pyyaml flask requests pyusb
151163
RUN gem install fpm
152164

153165
ARG RELEASE

tools/installer/Dockerfiles/ubuntu1404.dockerfile

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ RUN wget -q https://pypi.python.org/packages/source/s/setuptools/setuptools-20.1
121121
RUN wget -q https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb && \
122122
tar xzvf pip-8.0.2.tar.gz && \
123123
cd pip-8.0.2 && /opt/mlc-python-2.7.11/bin/mlc_python setup.py build && /opt/mlc-python-2.7.11/bin/mlc_python setup.py install && \
124-
rm -rf /tmp/pip-8.0.2* && \
125-
/opt/mlc-python-2.7.11/bin/mlc_pip install --upgrade pip
124+
rm -rf /tmp/pip-8.0.2*
125+
126+
RUN /opt/mlc-python-2.7.11/bin/mlc_pip install --upgrade pip
126127

127128
RUN /opt/mlc-python-2.7.11/bin/mlc_pip install --upgrade pip
128129

@@ -160,18 +161,25 @@ RUN wget http://www.graphviz.org/pub/graphviz/stable/SOURCES/graphviz-2.40.1.tar
160161
tar xzvf graphviz-2.40.1.tar.gz && \
161162
cd graphviz-2.40.1 && \
162163
./configure --prefix=/tmp/graphviz-2.40.1 && \
163-
make -j4 && make install && \
164-
mkdir -p /opt/mlc-python-2.7.11/custom_libs /opt/mlc-python-2.7.11/custom_bins && \
165-
cp -r /tmp/graphviz-2.40.1/lib/* /opt/mlc-python-2.7.11/custom_libs && \
166-
cp -r /tmp/graphviz-2.40.1/bin/* /opt/mlc-python-2.7.11/custom_bins && \
167-
rm -rf /tmp/graphviz-2.40.1*
164+
make -j4 && make install
168165

169166
# Install mlc dependencies
170167
# Create .sh who will load the desired enviroment to run nosetests within it
171-
RUN export LD_LIBRARY_PATH=/usr/local/Qt-5.7.1/lib:$LD_LIBRARY_PATH && \
172-
export PATH=/usr/local/Qt-5.7.1/bin:$PATH && \
168+
RUN export CFLAGS="-I/tmp/graphviz-2.40.1/include" \
169+
export LD_LIBRARY_PATH=/opt/mlc-python-2.7.11/custom_libs:$LD_LIBRARY_PATH && \
170+
export LD_LIBRARY_PATH=/opt/mlc-python-2.7.11/Qt-5.7.1/lib:$LD_LIBRARY_PATH && \
171+
export LD_LIBRARY_PATH=/tmp/graphviz-2.40.1/lib:$LD_LIBRARY_PATH && \
172+
export PKG_CONFIG_PATH=/tmp/graphviz-2.40.1/lib/pkgconfig:$PKG_CONFIG_PATH && \
173+
export PATH=/opt/mlc-python-2.7.11/Qt-5.7.1/bin:$PATH && \
174+
export PATH=/opt/mlc-python-2.7.11/custom_bins:$PATH && \
175+
export PATH=/tmp/graphviz-2.40.1/bin:$PATH && \
173176
/opt/mlc-python-2.7.11/bin/mlc_pip install networkx pydotplus pygraphviz 'ipython<6.0.0' numpy flask requests pyserial nose pyyaml coverage matplotlib scipy pyusb
174177

178+
RUN mkdir -p /opt/mlc-python-2.7.11/custom_libs /opt/mlc-python-2.7.11/custom_bins && \
179+
cp -r /tmp/graphviz-2.40.1/lib/*.so* /tmp/graphviz-2.40.1/lib/graphviz /opt/mlc-python-2.7.11/custom_libs && \
180+
cp -r /tmp/graphviz-2.40.1/bin/* /opt/mlc-python-2.7.11/custom_bins && \
181+
rm -rf /tmp/graphviz-2.40.1*
182+
175183
RUN gem install fpm
176184

177185
ARG RELEASE

0 commit comments

Comments
 (0)