2016-06-24 2 views
1

mco 패키지의 ngsa2를 사용하여 3 가지 목표로 최적화 문제를 해결하고 싶습니다. 요컨대 환경 문제를 해결하기 위해 최적의 토지 이용을 모색하고 있습니다. 여기 내 실험이 있습니다 : - 100 개의 토지 이용이 가능합니다 (아래 코드의 all.options). 각 토지 이용은 3 가지 공연 (main.goal1, main.goal2 및 main.goal3)이 특징입니다. - 50 개의 필드가 있습니다. 특성 (토양의 토양 Kq)은 100 개의 토지 용도를 부분 집합합니다. 즉, 모든 토지 용도가 각 필드에 대해 가능하지 않습니다. => options.soil1 및 options.soil2글로벌 다중 최적화 기능 사양은 R

내 목표는입니다. maintgoal1, main.goal2 및 main.goal3을 최소화하기 위해 각 50 개 필드에 토지 용도를 지정해야합니다. 내가 읽은 것에서, 유전자 알고리즘은 이러한 유형의 문제에 매우 강력합니다.

여기 내 가상 데이터가 있습니다.

set.seed(0) 
all.options<-data.frame(num.option=1:100,main.goal1 = abs(rnorm(100)), 
      main.goal2 = abs(rnorm(100)), 
      main.goal3 = abs(rnorm(100))) # all possible combinations of the 3 goals 
options.soil1<-subset(all.options, main.goal1>0.5) # possible combinations for soil1 
options.soil2<-subset(all.options, main.goal3<0.5) # possible combinations for soil2 

fields.Kq<-data.frame(num.field=1:50,soil=round(runif(50,0,1),0)) 

나는

my.function<-function(x) { 
    x[1]<-sum(A[,1) # main.goal1 for selected options for each of fields.Kq 
    x[2]<-sum(A[,2) # main.goal2 for selected options for each of fields.Kq 
    x[3]<-sum(A[,3) # main.goal3 for selected options for each of fields.Kq 
} # where A should be a matrix of 50 lines with one line per field, and  #"choosen" land use option 

nsga2(my.function) 

불행하게도 내가 더 갈 수 없었다처럼 나는 선택이 끝난 토지 이용으로, 행렬 A를 구축하는 방법 R.와 최적화에 새로운 오전 나의 목적 함수가 보일 것입니다 추측 각 분야마다? 그리고이 토지 용도를 반환하는 방법은 무엇입니까? (main.goal1, main.goal2 및 main.goal3에 대한 최적화 된 (최소화 된) 값과 함께)

당신이 나에게 제공 할 수있는 모든 도움을 미리 감사드립니다. 나는 정말로 조언/링크/책을 찾고 있습니다. . 내 최적화 문제에 진출하는

안부를

LH

다음

답변

0

내가 문제를 해결하는 방법입니다.

library("mco") 
set.seed(0) 
all.options<-data.frame(num.option=1:100,main.goal1 = abs(rnorm(100)), 
         main.goal2 = abs(rnorm(100)), 
         main.goal3 = abs(rnorm(100)),soil=c(rep("soilType1",50),rep("soilType2",50))) # all possible combinations of the 3 goals 

fields.Kq<-data.frame(num.field=1:50,soil=rep(c("soilType1","soilType2"),25)) 

main.goal1=function(x) # x - a vector 
{ 
    main.goal1=sum(all.options[x,1]) # compute main.goal1 
    return(main.goal1) } 

main.goal2=function(x) # x - a vector 
{ 
    main.goal2=sum(all.options[x,2]) # compute main.goal2 
    return(main.goal2) } 

main.goal3=function(x) # x - a vector 
{ 
    main.goal3=sum(all.options[x,3]) # compute main.goal3 
    return(main.goal3) } 

eval=function(x) c(main.goal1(x),main.goal2(x),main.goal3(x)) #objectivefunction 

D<-length(fields.Kq[,1]) # number of fields 
D2<-length(fields.Kq[,1])/2 # number of fields per type (simplified) 
D.soil1<-max(which(all.options$soil=="soilType1")) # get boundary for bound soil1 
D.soil2<-min(which(all.options$soil=="soilType2")) # get boundary for bound soil2 

G=nsga2(fn=eval,idim=D,odim=3, 
     lower.bounds=c(rep(1,D2),rep(D.soil2,D2)),upper.bounds=c(rep(D.soil1,D2),rep(100,D2)), # lower/upper bound: min/max num option 
     popsize=20,generations=1:1000, cprob = 0.7, cdist = 5, 
     mprob = 0.2, mdist = 10) 

내가 정의를 Paulo Cortez가 작성한 매우 유익하고 유익한 책 "R in Modern optimization"에서 발견 된 사례 덕택입니다.

lh