[R-sig-ME] Genetic Algorithm in R

Ben Bolker bbolker at gmail.com
Thu Jan 8 14:54:50 CET 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 15-01-08 08:34 AM, Narahara Chari D via R-sig-mixed-models wrote:
> Hi All, I am trying to implement Genetic Algorithm based on the 
> request to fill 500 ask based on the inventory. Algorithm should
> pick optimized combinations based on the rank (low rank inventory
> should be selected first) and update the inventory after fulfilling
> the request.
> 
> dataGA Inventory Rank 1        200    2 2        150    1 3 300
> 3 4        100    4 5         50    1 6        250    1 7 350    2
> 8        100    2 9        250    3 10        25    4 11 125    4
> 12       100    5 13       225    1 14       220    2 15 150    3
> 
> library(GA) Rastrigin <- function(x1, x2) { x1*x2 - 500 }
> 
> x1 <- dataGA$Inventory x2 <- seq(0.01, 1, by = 0.01)
> 
> f <- outer(x1, x2, Rastrigin) GA <- ga(type = "real-valued",
> fitness = function(x) -Rastrigin(x1, x2), min = c(1000, 0.01), max
> = c(10000000, 1), popSize = 50, maxiter = 100) summary(GA)I have 
> solutions +-----------------------------------+ |         Genetic 
> Algorithm         | +-----------------------------------+
> 
> GA settings: Type                  =  real-valued Population size =
> 50 Number of generations =  100 Elitism               =  2 
> Crossover probability =  0.8 Mutation probability  =  0.1 Search 
> domain x1   x2 Min  25 0.01 Max 350 1.00
> 
> GA results: Iterations             = 100 Fitness function value =
> 498 Solutions              = x1        x2 [1,]  194.44965 0.3886958
> [2,] 191.24609 0.4016915 [3,]  243.08729 0.3699107 [4,]  137.36235 
> 0.4050092 [5,]  177.33917 0.4570788 [6,]  139.32841 0.3755744 [7,] 
> 137.68704 0.3534409 [8,]  156.28470 0.3825039 [9,]  196.84368 
> 0.4089103 [10,]  80.42056 0.3796008 ... [48,] 183.48574
> 0.4611285For the ask of 500, I want solutions to be
> x1[c(2,5,6,13),] and x2[c(2,5,6,13),] with uniqueID which is a row
> number here. Or please suggest any other Package/Algorithm
> combination for this problem, Thank You,Best Regards,Chari

  Sorry, this is not a mixed model problem -- not even particularly
closely related to mixed models.  (When you send your question
elsewhere, you may want to provide a reproducible example, and to
explain your question more clearly -- I couldn't understand it.)

  sincerely,
    Ben Bolker

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQEcBAEBAgAGBQJUrowqAAoJEOCV5YRblxUHfacH/RKMTV4YQmwgXwfUf8NP0lA6
hYh6afVL1NxYh9P0GAPxxeGIbf3FC3R6gpsbGCfpHP9WYQjXkOjunBaw4eNo44Ry
P20eAUogj2Yr+zluUIzNHXcsOSaUeyAHNTOM2a63z2eUJ9MTCAnT9NAdPG2H8xDi
RC7am/NWsyGj47u9BWjZubGOBFBITnpWjV52HOficGxCLOT9Ssm+9q6fnsdLlvyC
wDS2hamNzxzu7+IZS2oCvDM0KHVZxIX+GZ2O3vChuUVOoJOPQWmypsXfaAWeBuo8
qu6ZYth4Me/jzXm+aYI18qj7oH6KH77Z/3TsR+PaXCdTZJgrRtJoToJYGuV18pE=
=Huy+
-----END PGP SIGNATURE-----



More information about the R-sig-mixed-models mailing list