Andre, Altere sua função fxy para
fxy=function(x) -x[1]^2 - x[2]^2 e a tua maximização vai funcionar. Para colocar a escala no eixo (se é que entendi corretamente a sua dúvida), rode o comando persp(x[, 1], x[, 2], -z, theta=30, phi=30, col="green", xlab="X", ylab="Y", zlab="Produção", ticktype="detailed") 2015-05-17 18:36 GMT-03:00 Andre Oliveira <[email protected]>: > Pessoal, > como devo escrever a função fxy para que o optim pegue fxy e maximize > mesma? Estou pesquisando aqui, mas não consegui. Este é um exemplo apenas > para fins didáticos! > x = seq(-2,2,length=20) > y = seq(-2,2,length=20) > f = function(x,y){ > fxy = -x^2 - y^2 > return(fxy) > } > z = outer(x,y,f) > persp(x,y,z,theta=30,phi=30, > col="green",xlab="x",ylab="Y",zlab="Produção") # Gostaria de acrescentar a > escala no eixo! > > > fxy=function(x,y) -x^2 - y^2 > > optim(c(2,2),fxy, method="BFGS", control=list(fnscale=-1)) > > obrigado > > > > _______________________________________________ > R-br mailing list > [email protected] > https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br > Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forneça > código mínimo reproduzível. > -- Marcus Nunes http://marcusnunes.me/
_______________________________________________ R-br mailing list [email protected] https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forneça código mínimo reproduzível.
