This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<article> | |
<table> | |
<tr> | |
<th> | |
<asp:Label ID="Label1" runat="server" Text="Sugarlevel"> | |
</asp:Label> | |
</th> | |
<td> | |
<asp:TextBox ID="sugarlevel" ToolTip="Hit Enter to update" runat="server" Width="140px"></asp:TextBox > |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install.packages("shape") # in case shape is not installed | |
require(shape) | |
# install.packages("plotrix") # in case plotrix is not installed | |
require(plotrix) | |
################################################################################################################################## | |
################################################################################################################################## | |
############################################# Helper functions ################################################################# | |
################################################################################################################################## | |
################################################################################################################################## |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plottitle <- function(t){ | |
### Plot "Folie ###" | |
plot(NA,NA,frame.plot=FALSE, xlab="", ylab="", xlim= c(-1,1), ylim=c(-1,1), axes=FALSE) | |
text(0,0,t, cex=2, ) | |
} | |
getPolar <- function(n0,n1){ | |
# Polarwinkel berechnung zum vekürzen der Pfeile | |
x1 <- n1$x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getNumberOfStops <- function(tour){ | |
# wieviele Stops führen zum Depot zurück? | |
n <- which(tour==1) # 1=depot | |
return (length(n)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
calcTourplan <- function(cij, tour){ | |
F <- 0 | |
# Speichere die Orte, die keinen Vorgänger haben --> Also vom Depot aus angesteuert werden | |
hasPreDecessor <- rep(FALSE, nrow(locations)) | |
for(i in 1:ncol(tour)){ | |
F<- F + cij[i+1, tour[i]] | |
hasPreDecessor[tour[i]] <- TRUE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mutation | |
mutate <- function(tour){ | |
# suche zufällig einen Start knoten aus, der mit einem Endknoten verbunden wird. | |
# combine which stop o[1] with wich stop o[2] | |
o <- sample(1:length(tour), 2) | |
tour[o[1]] <- o[2] + 1 # 1 is depot | |
# mutated tour | |
#immediate Repair |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
repair2 <- function(tour){ | |
#repair short cycles (DFJc) | |
# iteriere über jeden Stop im Tourenplan | |
for(i in 1:length(tour)){ | |
# wenn der Nachfolger nicht das Depot ist (hier index = 1) | |
# dann kann es Kurzzyklen geben | |
if(tour[i]>1){ # not returning to depot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
searchFor <- function(tour, index, start){ | |
#helper function für recursiven Aufruf | |
if(tour[index -1] == 1) # 1 == depot | |
{ | |
return(TRUE) | |
}else{ | |
if(tour[index -1] == start) # Kurzzyklus gefunden | |
{ | |
return(FALSE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
repair1 <- function(tour){ | |
#cond 1/2 once arrive/leave | |
#substitute multiple indices by 0(1) --> ALL! | |
#getunique stops | |
y<-unique(tour) | |
y<- y[y!=1] # 1 --> 0 # elminate Depot-Stops | |
#iterate over potentail multiple Stop indices |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
recombine<- function(tours, f, m, recomb){ | |
# tours = Genpool | |
# f = father index | |
# m = mother index | |
# recomb = Predefined Recombination vector | |
t.f <- tours[f,] #get tourplan father | |
t.m <- tours[m,] #get tourplan mother | |
t.c <- t.f # use father as template |