-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
54 additions
and
59 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,47 @@ | ||
setwd("~/Documents/heuristics/FlowShop") | ||
load("instances/TaillardFS.RData") #load instances | ||
source("code/FSfunctions.R") #load code with functions | ||
SA(test$tij, 1:20, 500, 10000) #simulated annealing | ||
test <- tai20.5[[1]] | ||
makespan(test$tij, 1:20) | ||
HillClimbing(test$tij, 1:20) | ||
SA(test$tij, 1:20, 500, 10000) #simulated annealing | ||
TS(test$tij, 1:20, 1000) #tabu search | ||
rm(list=ls()) | ||
source("code/functionsFS2.R") | ||
Instance <- matrix(sample(10:50, 100, replace = TRUE), 5, 20) | ||
SA01 <- SAFS(Instance, 1:20, Tmax=10000) | ||
TS01 <- TSFS(Instance, 1:20, eval = TRUE) | ||
setwd("~/Documents/heuristics/TSP") | ||
source("code/functionsTSP2.R") | ||
TestSample <- SampleTSP(30, seed=1313) | ||
set.seed(1313) | ||
SA01 <- SATSP2opt(TestSample, sol, Tmax=3000, mu=10, eval = TRUE) | ||
sol <- 1:30 | ||
SA01 <- SATSP2opt(TestSample, sol, Tmax=3000, mu=10, eval = TRUE) | ||
SA01 <- SATSP2opt(TestSample$distances, sol, Tmax=3000, mu=10, eval = TRUE) | ||
TS01 <- TSTSP2opt(TestSample$distances, sol, asp=TRUE, eval=TRUE) | ||
View(TS01) | ||
SA01 <- SATSP2opt(TestSample$distances, sol, Tmax=30000, mu=10, eval = TRUE) | ||
SA01 <- SATSP2opt(TestSample$distances, sol, Tmax=300000, mu=10, eval = TRUE) | ||
set.seed(1313) | ||
SA01 <- SATSP2opt(TestSample$distances, sol, Tmax=300000, mu=100, eval = TRUE) | ||
setwd("~/Documents/heuristics/KP") | ||
source("code/functionsKP.R") | ||
easy <- list(w=c(30, 45, 15, 40, 35, 5), u=c(24, 108, 30, 100, 80.5, 3), W=100) | ||
hard <- list(w=c(30, 45, 15, 70, 35, 5), u=c(24, 108, 30, 175, 80.5, 3), W=100) | ||
InstanceKP10 <- KPInstance01(1000, 10, 40) | ||
InstanceKP50 <- KPInstance01(1000, 50, 40, 2424) | ||
InstanceKP100 <- KPInstance01(1000, 100, 40, 3333) | ||
bandb.easy <- BandBKP(easy) | ||
bandb.hard <- BandBKP(hard) | ||
bandb.KP10 <- BandBKP(InstanceKP10) | ||
bandb.KP50 <- BandBKP(InstanceKP50) | ||
bandb.KP100 <- BandBKP(InstanceKP100) | ||
source("code/functionsKP.R") | ||
#generating large instance | ||
set.seed(111) | ||
LargeInstance <- EasyInstance(1000, 0.4) | ||
#starting solution | ||
inisolLIEmpty <- sample(c(TRUE, FALSE), 1000, replace = TRUE, prob = c(0.1, 0.9)) | ||
#solving with heuristic | ||
LIheuristic <- HeuristicKP(LargeInstance) | ||
Tmax <- 1000 | ||
SA01 <- SAKP(Inst=LargeInstance, Tmax=Tmax, inisol = inisolLIEmpty, eval=TRUE) | ||
#optimal solution with LP | ||
LILP <- LPKP(LargeInstance) | ||
Tmax <- 1000 | ||
Tmax <- 10000 | ||
SA01 <- SAKP(Inst=LargeInstance, Tmax=Tmax, inisol = inisolLIEmpty, eval=TRUE) | ||
plot(1:100, SA01$evalfit[1:100], type="l", col="red", xlab = "", ylab = "") | ||
lines(1:100, SA01$evalbest[1:100], col="blue") | ||
lines(1:100, SA01$evaltest[1:100], col="green") | ||
#simulated annealing with same evals of objective function as TS | ||
Tmax <- 500000 | ||
SA02 <- SAKP(Inst=LargeInstance, Tmax=500000, mu=1, inisol = inisolLIEmpty, eval=FALSE) | ||
#aspiration condition | ||
TS01 <- TSKP(Inst=LargeInstance, inisol = inisolLIEmpty, tabu.size = 100, iter=500, asp = TRUE, eval=TRUE) | ||
plot(1:500, TS01$evalfit[1:500], type="l", col="red", xlab = "", ylab = "") | ||
lines(1:500, TS01$evalbest[1:500], col="blue") | ||
TS02 <- TSKP(Inst=LargeInstance, inisol = inisolLIEmpty, tabu.size = 100, asp=FALSE, iter=500, eval=TRUE) | ||
plot(1:500, TS02$evalfit, type="l", col="red", xlab = "", ylab = "") | ||
lines(1:500, TS02$evalbest, col="blue") | ||
#analyzing last iterations | ||
plot(350:500, TS01$evalfit[350:500], type="l", col="red", xlab = "", ylab = "") | ||
lines(350:500, TS01$evalbest[350:500], col="blue") | ||
plot(350:500, TS02$evalfit[350:500], type="l", col="red", xlab = "", ylab = "") | ||
lines(350:500, TS02$evalbest[350:500], col="blue") | ||
#behaviour of last iterations with aspiration condition | ||
TS01$move[450:500] | ||
TS01$evalfit[450:500] | ||
LargeInstance$u[c(781, 777, 380, 485, 721, 768, 679)] | ||
TS03 <- TSKP(Inst=LargeInstance, inisol = LIheuristic$sol, tabu.size = 100, asp=FALSE, iter=500, eval=TRUE) | ||
SA03 <- SAKP(Inst=LargeInstance, Tmax=500000, mu=1, inisol = LIheuristic$sol, eval=FALSE) | ||
SA04 <- SAKP(Inst=LargeInstance, Tmax=500000, mu=1, inisol = inisolLIEmpty, eval=FALSE) | ||
plot(1:500, TS03$evalfit, type="l", col="red", xlab = "", ylab = "") | ||
lines(1:500, TS03$evalbest, col="blue") | ||
plot(1:10, TS03$evalfit[1:10], type="l", col="red", xlab = "", ylab = "") | ||
lines(1:10, TS03$evalbest[1:10], col="blue") | ||
SA02 <- SAKP(Inst=LargeInstance, Tmax=500000, mu=100, inisol = inisolLIEmpty, eval=FALSE) | ||
SA02 <- SAKP(Inst=LargeInstance, Tmax=500000, mu=1000, inisol = inisolLIEmpty, eval=FALSE) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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