It works for me:
> x <- 2*c(1,0.5,0.8,0.5,1,0.9, 0.8,0.9,1)
> Dmat <- matrix(x, byrow=T, nrow=3, ncol=3)
> dvec <- numeric(3)
> Amat <- matrix(0,3,4)
> Amat[,1 ] <- c(1,1,1)
> Amat[,2:4 ]<- t(diag(3))
> bvec <- c(3,0,0,0)
>
> solve.QP(Dmat,dvec,Amat,bvec=bvec, meq=1)
$solution
[1] 1.5 1.5 0.0
$va
You have merely found a little used
entry point into Circle 1 of 'The R Inferno'.
The third element of your answer is zero
to the precision of the QP algorithm. So it
is obeying the non-negative constraints that
you put on the problem to the best of its
ability. You should not expect numerical
e
Hi,
thanks!
I added meq=1 and it did not seem to work. The result is the same as before.
> x <- 2*c(1,0.5,0.8,0.5,1,0.9, 0.8,0.9,1)
> Dmat <- matrix(x, byrow=T, nrow=3, ncol=3)
> dvec <- numeric(3)
> Amat <- matrix(0,3,4)
> Amat[,1 ] <- c(1,1,1)
> Amat[,2:4 ]<- t(diag(3))
> bvec <- c(3,0,0,0)
>
Add meq=1 to the arguments.
On Sun, Apr 11, 2010 at 9:50 AM, li li wrote:
> Hi, thank you very much for the reply!
>
> Consider minimize quadratic form w'Aw with A be the following matrix.
>> Dmat/2
> [,1] [,2] [,3]
> [1,] 1.0 0.5 0.8
> [2,] 0.5 1.0 0.9
> [3,] 0.8 0.9 1.0
> I need t
Hi, thank you very much for the reply!
Consider minimize quadratic form w'Aw with A be the following matrix.
> Dmat/2
[,1] [,2] [,3]
[1,] 1.0 0.5 0.8
[2,] 0.5 1.0 0.9
[3,] 0.8 0.9 1.0
I need to find w=(w1,w2,w3), a 3 by 1 vector, such that sum(w)=3, and wi>=0
for all i.
Below is th
Check out the quadprog package.
On Sat, Apr 10, 2010 at 5:36 PM, li li wrote:
> Hi, thanks for the reply.
> A will be a given matrix satisfying condition 1. I want to find the
> vector w that minimizes the
> quadratic form. w satisfies condition 2.
>
>
> 2010/4/10 Paul Smith
>
>> On Sat, Apr 1
Hi, thanks for the reply.
A will be a given matrix satisfying condition 1. I want to find the
vector w that minimizes the
quadratic form. w satisfies condition 2.
2010/4/10 Paul Smith
> On Sat, Apr 10, 2010 at 5:13 PM, Paul Smith wrote:
> >>I am trying to minimize the quardratic form w'
On Sat, Apr 10, 2010 at 5:13 PM, Paul Smith wrote:
>> I am trying to minimize the quardratic form w'Aw, with certain
>> constraints.
>> In particular,
>> (1) A=(a_{ij}) is n by n matrix and it is symmetric positive definite,
>> a_{ii}=1 for all i;
>> and 0> (2) w'1=n;
>>
On Sat, Apr 10, 2010 at 4:58 PM, li li wrote:
> I am trying to minimize the quardratic form w'Aw, with certain
> constraints.
> In particular,
> (1) A=(a_{ij}) is n by n matrix and it is symmetric positive definite,
> a_{ii}=1 for all i;
> and 0 (2) w'1=n;
> (3) w_{i}>=0
Hi all,
I am trying to minimize the quardratic form w'Aw, with certain
constraints.
In particular,
(1) A=(a_{ij}) is n by n matrix and it is symmetric positive definite,
a_{ii}=1 for all i;
and 0=0
Analytically, for n=2, it is easy to come up with a result. For larger n, it
10 matches
Mail list logo