Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cost Opimization #29

Merged
merged 17 commits into from
Aug 15, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
working commit
  • Loading branch information
walkeri committed Aug 15, 2018
commit e2126b3b5827b59ddeed0b29b0b86666a30f5ea8
31 changes: 18 additions & 13 deletions htdocs/route.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<br>
Travel time: <div id="time" class="grad-text"></div></div>

<div class="button-container" id="learn-more-container" onclick="fadeOverlay()">
<div class="button-container" id="learn-more-container" onclick="showRoute()">
<div class="button">
<div class="button-text" id="learn-more-text">
See my route
Expand Down Expand Up @@ -130,21 +130,26 @@



<div class="button-container-transparent" id="see-stats-container" onclick="showStats()">
<div class="button">
<div class="button-text" id="see-stats-text">
Show stats
</div>
</div>
</div>
<div id="map-buttons">

<div class="button-container-transparent" id="see-stats-container" onclick="showGraphs()">
<div class="button">
<div class="button-text" id="see-graphs-text">
Show Graphs
</div>
<div class="button-container-transparent" id="see-stats-container" onclick="showStats()">
<div class="button">
<div class="button-text" id="see-stats-text">
Show Stats
</div>
</div>
</div>

<div class="button-container-transparent" id="dashboard-container" onclick="showGraphs()">
<div class="button">
<div class="button-text" id="see-graphs-text">
Show Graphs
</div>
</div>
</div>

</div>




Expand Down
24 changes: 16 additions & 8 deletions htdocs/script/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,19 +291,26 @@ function fadeOverlay() {

$('#overlay').css({"opacity": 0})
$('#map-container').css({"display": "flex", "opacity" : "100"})
$('#left-map-graphs').css({"display": "flex", "opacity" : "0"})
$('#right-map-graphs').css({"display": "flex", "opacity" : "0"})
$('#dashboard-container').css({"opacity" : "0"});
$('#dashboard-container').prop('disabled', true);



setTimeout(hideOverlay, 800)

zoomToRoute();

}

function showRoute() {

generation = numGenerations - 1;
$('#left-map-graphs').css({"display": "flex", "opacity" : "0"})
$('#right-map-graphs').css({"display": "flex", "opacity" : "0"})
$('#dashboard-container').css({"opacity" : "0"});
$('#dashboard-container').prop('disabled', true);
$('#see-stats-container').css({"opacity" : "100"});
fadeOverlay();
updateMap();

}

function hideOverlay() {

$('#overlay').css({"display": "none"})
Expand Down Expand Up @@ -440,13 +447,14 @@ function fancyLengthFormat(length) {
}

function startVisualization() {
fadeOverlay();
generation = 0;
updateMap();
initGraphs();
$('#map-container').css({"display": "flex", "opacity" : "100"});
fadeOverlay();
$('#dashboard-container').css({ "opacity" : "100"});
$('#dashboard-container').prop('disabled', false);
$('#see-stats-container').css({ "opacity" : "100"});



// $('#left-map-graphs').css({"display": "flex", "opacity" : "100"})
Expand Down
30 changes: 24 additions & 6 deletions htdocs/style/route.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,21 @@ html {
background-color: transparent;
}

#map-buttons {
position: absolute;
display: table;
margin-top: auto;
margin-bottom: auto;
width: 25%;
height: 10%;
top: 0;
left: 0;
white-space: nowrap;
background-color: transparent;
}

#see-stats-container {
-webkit-appearance: none;
position: absolute;
display: table;
width: 7%;
Expand All @@ -42,17 +56,17 @@ html {
left: 0;
white-space: nowrap;
background-color: transparent;

}

#dashboard-container {
-webkit-appearance: none;
position: absolute;
display: table;
width: 2%;
height: 3.2%;
margin-top: auto;
margin-bottom: auto;
top: 10%;
top: 100%;
left: 0;
white-space: nowrap;
background-color: transparent;
Expand Down Expand Up @@ -179,25 +193,25 @@ html {
}

#track {
right: 100%;
right: 95%;
top: 0;
float: right;
}

#curve {
right: 100%;
right: 95%;
top: 25%;
float: right;
}

#grade {
right: 100%;
right: 95%;
top: 50%;
float: right;
}

#length {
right: 100%;
right: 95%;
top: 75%;
float: right;
}
Expand Down Expand Up @@ -227,5 +241,9 @@ html {

}

#see-graphs-text {
font-size: 23.2px;
}



7 changes: 2 additions & 5 deletions opencl/kernel_cost.opencl
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,8 @@ __kernel void mo(__read_only image2d_t image, __global float4* individuals, int
float below_cost = (-fabs(pylon_height + excavation_depth) + pylon_height + excavation_depth);
float below_cost_den = 2.0 * pylon_height + 2.0 * (excavation_depth);

if (below_cost_den == 0) {
below_cost = (below_cost) * tunnel_cost;
} else {
below_cost = (below_cost / below_cost_den) * tunnel_cost;
}
below_cost = below_cost_den == 0 ? 1.0 : (below_cost / below_cost_den) * tunnel_cost;

track_cost += (above_cost + below_cost) * spacing;

if (isnan(track_cost)) {
Expand Down
2 changes: 1 addition & 1 deletion src/routes-lib/genetics/population.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ glm::vec4 Population::getFitness() const {

double Population::totalFitness(glm::vec4 costs) {

return costs.x * 1.2 + costs.y * 1.3 + costs.z + costs.w * 2.0;
return costs.x * 1.2 + costs.y * 0.8 + costs.z + costs.w * 1.5;

}

Expand Down
2 changes: 1 addition & 1 deletion src/routes-lib/routes.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define POP_SIZE 1000

/** The default number of generations that the population should be bred for */
#define NUM_GENERATIONS 300
#define NUM_GENERATIONS 600

/** This is a simplelass to handle the complete calculation of a route. */
class Routes {
Expand Down