Commit 9ab6a80d authored by Mayank Yadav's avatar Mayank Yadav

Added support for completely custom tree building

parent 8e5165f9
No preview for this file type
......@@ -11,4 +11,16 @@ JS:
heavylifting.js -> Does all the main js work
NOTE:
Ctrl(Cmd)+Click for selecting multiple entries in Numeric-predicates and Categorical-predicates selection
\ No newline at end of file
Ctrl(Cmd)+Click for selecting multiple entries in Numeric-predicates and Categorical-predicates selection
The dynamics.txt file must be present in ./examples folder to use the simulation functionality.
The format of dynamics .txt file must be as follows:
"Parameters:
...
Dynamics:
dx_0=...
...
"
There should be no [] and change in state variable 0 is to be denoted as dx_0 not dx[0]
\ No newline at end of file
......@@ -34,6 +34,9 @@ numResults = 0
# time discretisation parameter
tau = 0
# Saved domain knowledge predicates
pred = []
def runge_kutta(x, u, nint=10):
# nint is number of times to run Runga-Kutta loop
......@@ -76,7 +79,14 @@ def computation(index, x, u, ll):
def discretize(x):
diff = []
for i in range(numVars):
diff.append(minBounds[i] + stepSize[i] * (1 + int((x[i] - minBounds[i]) / stepSize[i])))
lower = minBounds[i] + stepSize[i] * (int((x[i] - minBounds[i]) / stepSize[i]))
upper = minBounds[i] + stepSize[i] * (1 + int((x[i] - minBounds[i]) / stepSize[i]))
mid = (lower + upper) / 2
if x[i] >= mid:
diff.append(upper)
else:
diff.append(lower)
# diff.append(minBounds[i] + stepSize[i] * (1 + int((x[i] - minBounds[i]) / stepSize[i])))
return diff
......@@ -223,6 +233,60 @@ def rc2():
return []
# Called when evaluating impurity of initially entered domain knowledge
@app.route("/evaluatePredicateImpurity", methods=['POST'])
def evalImpurityRoute():
data = request.get_json()
pred = data['predicate']
returnDict = {"impurity": 0.5}
return jsonify(returnDict)
# Called when trying to get feature and label specifications
@app.route("/featureLabelSpecifications", methods=['POST'])
def returnFeaturesLabels():
data = request.get_json()
global pred
# Contains finally selected domain knowledge, preferably store in some global variable
pred = data['domainKnowledge']
dummy_feature_specifications = [['x_0', 'Ego.Choose', '1', '1', '1', '1', '1'],
['x_1', 'Front.Choose', '0', '0', '0', '0', '1']]
dummy_label_specifications = [['accelerationEgo', '-2', '2', '2']]
returnDict = {"feature_specifications": dummy_feature_specifications,
"label_specifications": dummy_label_specifications}
return jsonify(returnDict)
# Called when trying to refresh impurities for different nodes
@app.route("/refreshImpurities", methods=['POST'])
def refreshImpurities():
data = request.get_json()
# Contains address of node trying to build
address = data['address']
dummy_domain_knowledge_updated_impurities = ['0.23'] * (len(pred))
dummy_computed_predicates = [['12', '0.57', 'x_1 + x_2 <= 0'], ['13', '0.651', 'x_3 + 5.0 <= 0']]
returnDict = {"updated_impurities": dummy_domain_knowledge_updated_impurities,
"computed_predicates": dummy_computed_predicates}
return jsonify(returnDict)
# Returns number of splits for a node on selecting appropriate predicate
@app.route("/splitNode", methods=['POST'])
def splitNode():
data = request.get_json()
# Contains address of node trying to split and predicate
address = data['address']
pred = data['predicate']
# Do processing here
returnDict = {"number_splits": 3}
return jsonify(returnDict)
# Used to get the list of unzipped examples
@app.route("/examples")
def showscs():
......
......@@ -167,6 +167,40 @@
</div>
</div>
<!-- Modal that comes on clicking 'Custom Tree' -->
<div class="modal fade" id="initialCustomTreeModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Input domain knowledge:</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<!-- evaluatePredicateImpurityForm: Selects domain knowledge -->
<form id="evaluatePredicateImpurityForm">
<div class="modal-body" id="formSecondBody">
<div>
<label for="init_domain_knowledge">Input predicate:</label>
<div class="search_categories">
<input type="text" id="init_domain_knowledge" name="init_domain_knowledge"><br><br>
</div>
<div>Computed Impurity: <span id="computedImpurity"></span></div>
</div>
</div>
<div class="modal-footer">
<button id="addToDomainKnowledgeTableButton" style="visibility: hidden;" type="button" onclick="addToDomainKnowledgeTable()" class="btn btn-primary">Add</button>
<button id="evaluatePredicateImpurityFormButton" type="submit" value="Send" class="btn btn-primary"> Evaluate </button>
<button type="button" onclick="closeInitialCustomTreeModal()" class="btn btn-primary">Done</button>
</div>
</form>
</div>
</div>
</div>
<!-- Sidenav that is used for selecting controller, config and other fine tuning properties -->
<div id="mySidenav" class="sidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a>
......@@ -273,7 +307,7 @@
<!-- Navbar at top -->
<nav class="navbar navbar-expand-xl navbar-light" style="margin: 1.25rem;">
<button class="btn" onclick="openNav()"><i class="fa fa-cog"></i></button>
<button id="sideNavOpener" class="btn" onclick="openNav()"><i class="fa fa-cog"></i></button>
<a class="navbar-brand" href="https://gitlab.lrz.de/i7/dtcontrol">dtControl</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
......@@ -318,6 +352,13 @@
<input id = "editTree" type="checkbox" autocomplete="off"> Edit Tree
</label>
</div>
<!-- Custom tree -->
<button id="customTreeButton" type="button" onclick="customTree()" class="btn btn-dark">Custom Tree</button>
<!-- Split Node -->
<button id="splitNodeButton" type="button" onclick="splitNode()" class="btn btn-dark" style="visibility: hidden; margin-left: 7px;">Split Node</button>
</div>
</nav>
......@@ -341,7 +382,7 @@
</div>
<!-- Column for model visualisation -->
<div class="col-lg-6" id="hideThisDiv" style="visibility:hidden">
<div class="col-lg-6" id="hideThisDiv" style="display:none">
<div class="card shadow mb-4">
<div class="card-body">
<div style="text-align:center;">
......@@ -352,6 +393,110 @@
</div>
</div>
<!-- Row for domain knowledge and computed predicates tables -->
<div id="mainRow1.1" class="row" style="display: none;">
<div class="col-lg-6">
<div class="card shadow mb-4">
<div class="card-body">
<h3>Domain Knowledge</h3>
<div class="table-responsive">
<!-- Doman knowledge table in this div -->
<div id="domainKnowledgeTableHere">
<table id="domainKnowledgeTable" class="table table-fixed">
<tr>
<th></th>
<th>Index</th>
<th>Impurity</th>
<th>Expression</th>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="card shadow mb-4">
<div class="card-body">
<h3>Computed Predicates</h3>
<div class="table-responsive">
<!-- Computed predicates table in this div -->
<div id="computedPredicatesTableHere">
<table id="computedPredicatesTableFull" class="table table-fixed">
<thead>
<tr>
<th></th>
<th>Index</th>
<th>Impurity</th>
<th>Expression</th>
</tr>
</thead>
<tbody id="computedPredicatesTable">
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Row for feature specification and label specification tables -->
<div id="mainRow1.2" class="row" style="display: none;">
<div class="col-lg-6">
<div class="card shadow mb-4">
<div class="card-body">
<h3>Feature Specifications</h3>
<div class="table-responsive">
<!-- Feature specifications table in this div -->
<div id="featureSpecificationTableHere">
<table id="featureSpecificationTable" class="table table-fixed">
<tr>
<th>Column</th>
<th>Name</th>
<th>Min</th>
<th>Max</th>
<th>Avg</th>
<th>Median</th>
<th>Step Size</th>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="card shadow mb-4">
<div class="card-body">
<h3>Label Specifications</h3>
<div class="table-responsive">
<!-- Label specifications table in this div -->
<div id="labelSpecificationTableHere">
<table id="labelSpecificationTable" class="table table-fixed">
<tr>
<th>Name</th>
<th>Min</th>
<th>Max</th>
<th>Step Size</th>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Row for simulation table -->
<div id="mainRow2" class="row" style="visibility: hidden;">
<div class="col-lg-12">
......@@ -386,7 +531,6 @@
<script src="{{ url_for('static', filename='js/Chart.js') }}"></script>
<script src="{{ url_for('static', filename='js/d3.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/d3.v4.js') }}"></script>
<script src="{{url_for( 'static', filename='js/heavylifting.js' )}}"></script>
<script>
function openNav() {
document.getElementById("mySidenav").style.width = "285px";
......@@ -400,6 +544,7 @@
}
openNav();
</script>
<script src="{{url_for( 'static', filename='js/heavylifting.js' )}}"></script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment