[R] Linear Optimization

From: Amit Soni <amitsoni.84_at_gmail.com>
Date: Fri 12 Jan 2007 - 04:53:22 GMT


Hi,

I am using constrOptim for a linear optimization problem. But it is giving an error that initial value is not feasible, even though the initial value provided is feasible.
I am using the following code.

------------------Code----------------

fr<-function(x){
x1=x[1]
x2=x[2]
x3=x[3]
x4=x[4]
x5=x[5]
x6=x[6]
x7=x[7]
x8=x[8]
x9=x[9]

x10=x[10]
2*x1+3*x2+4*x3-6*x4+x5+3*x8-4*x9+x10}
x0<-c(0,0,0,0,0,0,0,0,1.4,0)
Amat<-
matrix(c(1,3,4,2,-2,-3,2,-1,0,6,2,4,1,-2,5,3,0,-3,-4,0,5,6,1,1,0,1,3,-1,-1,1,0,0,5,0,5,0,1,2,2,-2,1,4,-6,-3,-2,-1,5,2,1,0,-1,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,-1),10,15) bvec<-c(1,-2,-1,3,5,0,0,0,0,0,0,0,0,0,0) constrOptim(x0,fr,NULL,ui=-t(Amat),ci=-bvec)

Can anyone help me with this.

Thanks
Amit

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri Jan 12 15:59:12 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 12 Jan 2007 - 05:30:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.