Closed maxrodkin closed 5 years ago
Please update the package with the current version available in GitHub. Then
library(GA)
f <- function(x) (x^2+x)*cos(x) # -10 < x < 10
monitor <- function(obj)
{
cat(paste("iteration =", obj@iter , "solution =" , obj@bestSol[[obj@iter]]), "\n")
}
GA <- ga(type = "real-valued", fitness = f, lower = -10, upper = 10,
keepBest = TRUE, monitor = monitor)
@luca-scr , thanks for support! unfortunatelly, i got unsuccessfull resuls. My actions:
> remove.packages("GA")
Removing package from ‘C:/Users/mrodkin/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
> devtools::install_github("luca-scr/GA", build_vignettes = TRUE)
Downloading GitHub repo luca-scr/GA@master
....
* DONE (GA)
In R CMD INSTALL
Warning messages:
1: In untar2(tarfile, files, list, exdir) :
skipping pax global extended headers
2: In untar2(tarfile, files, list, exdir) :
skipping pax global extended headers
After that, i ran this code, and obj@bestSol[[obj@iter]]) are still empty...
> GA <- ga(type = "real-valued", fitness = f, lower = -10, upper = 10,
+ keepBest = TRUE, monitor = monitor)
iteration = 1 solution =
iteration = 2 solution =
iteration = 3 solution =
may be i miss something important in GA updating? Will glad with your answer. Respect, Maxim
Please try the following and check that your output matches:
> packageDescription("GA")$Version
[1] "3.2.1"
> packageDescription("GA")$Date
[1] "2019-05-29"
@luca-scr , you was right! now i got desired monitoring
@luca-scr - Extending the following thread. Is it possible to store the population at every evolutionary iteration rather than have it printed? I am thinking of a user defined slot in ga to store a list of population matrices from first to last iteration?
hello! i`d liketo debug my ga. cancerning that, i tryed to print current solution in monitor function
but obj@solution is empty
Call: ga(type = "real-valued", fitness = fitness, lower = rep(0, nrow(UsingInstr)), upper = rep(1, nrow(UsingInstr)), pcrossover = 0.05, maxiter = 50000, run = 100, names = files, suggestions = rep(1/nrow(UsingInstr), nrow(UsingInstr)), parallel = TRUE, monitor = monitor, seed = 1) How to print solution in iteration?