Hello everyone, I have to solve a very difficult problem in R.
I have to maximise the function f(x,y) = x^2 +xy+y^2+3y+2 and I have two constraints:
- I have to maximise inside the parabola y=x^2-2
- and I have to respect the constraint y<= 1
I would solve it like this, but I don’t know how to write the matrix A and the vector b.
f ← function (xx,y) xx^2 + xxy +y^2 +3y +2
fv ← function (x) f(x,x)
xx ← seq (-5,5,len=51)
y ← seq (-5,5,len=51)
z = outer (xx,y,f)
curve (x^2 -2 ,-5,5,add=T)
constrOptim (c(0,0),fv,NULL,A,bcontrol=list (fnscale=-1))
I have the exam on Monday, so please help me this weekend.
Thank you in advance,
good by and sorry for my bad english.