Displaying 20 results from an estimated 23 matches for "amat".

Did you mean:
ama

2005 Jan 13

1

how to use solve.QP

...bLo=0 <= w <= 1=bUp
Cov <- var(S)
mu <- apply(S, 2, mean)
mu.target <- 0.1
#subject to cLo <= A <= cUp and bLo=0 <= b <= 1=bUp
A <- rbind(1,mu)
cLo <- c(1, mu.target)
cUp <- c(1, Inf)
bLo <- rep(0, n)
bUp <- rep(1, n)
#I convert [cLo <= A <= cUp] to Amat >= bvec and [bLo=0 <= w #<=1=bUp] to
Amat <- rbind(-1, 1, -mu, mu)
dim(bLo) <- c(n,1)
dim(bUp) <- c(n,1)
bvec <- rbind(-1, 1, mu.target, Inf, bLo, -bUp)
zMat <- matrix(rep(0,2*n*n),ncol=n, nrow=n*2)
zMat[,1] <- c(rep(1,n), rep(-1,n))
Amat <- t(rbind(Amat, zMat))
#So I...

2003 Jun 02

1

Help with factorized argument in solve.QP

...en factorized=TRUE, the Dmat argument should
be a matrix R^(-1), such that the Hessian of the objective function is
t(R) %*% R.
I modified the example in the helpfile slightly to test this out:
R = matrix(rnorm(9),3,3)
R.inv = solve(R)
Dmat = t(R) %*% R
dvec = c(0,5,0)
Amat = matrix(c(-4,-3,0,2,1,0,0,-2,1),3,3)
bvec = c(-8,2,0)
x1 = solve.QP(Dmat=Dmat, dvec=dvec, Amat=Amat, bvec=bvec,
factorized=FALSE)
x2 = solve.QP(Dmat=R.inv, dvec=dvec, Amat=Amat, bvec=bvec,
factorized=TRUE)
print(x1$solution)
print(x2$solution)
I would have expected that...

2009 Feb 16

2

solve.QP with box and equality constraints

...l periods from aggregate data using restricted least
squares.
I seem to be making headway using solve.QP(quadprog) as the unrestricted
solution matches the example I am following, and I can specify simple
equality and inequality constraints. However, I cannot correctly specify a
constraint matrix (Amat) with box constraints per cell and equality
constraints that span multiple cells. Namely the solution matrix I am aiming
for needs to respect the following conditions:
- each row must sum to 1
- each cell must >= 0
- each cell must <= 1
I understand the general principle of creating bo...

2011 May 11

1

Problem with constrained optimization with maxBFGS

...ar all,
I need to maximize the v:
v= D' W D
D is a column vector ( n , 1)
W is a given matrix (n, n)
subject to:
sum D= 1
(BTW, n is less than 300)
I´ve tried to use maxBFGS, as follows:
#####################################
objectiveFunction<-function(x)
{
return(t(D)%*%W%*%D)
}
Amat<-diag(nrow(D))
Amat<-rbind((rep(-1, nrow(D))), Amat)
bvec<-matrix( c(0), nrow(D)+1, 1)
bvec[1,1]<-c(1)
startValues=rep(1/nrow(D),nrow(D)) #Istart value is homogeneous distribution
res <<- maxBFGS(objectiveFunction, start=startValues,
constraints=list(ineqA=Amat, ineqB=bvec))
#...

2005 Nov 29

1

Constraints in Quadprog

...9;m having difficulty figuring out how to implement the
following set of constraints in Quadprog:
1). x1+x2+x3+x4=a1
2). x1+x2+x5+x6=a2
3). x1+x3+x5+x7=a3
4). x1+x2=b1
5). x1+x3=b2
6). x1+x5=b3
for the problem: MIN (x1-c1)2+(x2-c2)2+...+(x8-c8)2.
As far a I understand, "solve.QP(Dmat, dvec, Amat, bvec, meq=0,
factorized=FALSE)" reads contraints using an element-by-element
multiplication, i.e. Amat'*x, not using the matrix-product, i.e.
Amat'%*%x, required for the sums on the left-hand-side of 1-6).
I would very much appreciate a suggestion on this problem.
Thank you,
Sergue...

2012 Mar 16

1

quadprog error?

...act Berwin A. Turlach <Berwin.Turlach at gmail.com>
(maintainer for quadprog package) a week ago, with no success.
##############################################################
load(file='quadprog.Rdata')
# solve QP using quadprog
require(quadprog)
sol = solve.QP(Dmat, dvec, Amat, bvec, meq)
x = sol$solution
check = x %*% Amat - bvec
# for some reason last equality constraint is violated
round(check[1:meq], 4)
# solve QP using kernlab
require(kernlab)
n = nrow(Amat)
sv = ipop(c = matrix(dvec), H = Dmat, A = t(Amat[,1:meq]),
b = bvec[1:meq], l = rep(-1000,...

2005 Dec 14

6

mysql connection problems

Hi
hi i have a problem trying to connect to the mysql database when I do a
rake it says: Access denied for user: ''@localhost'' to database ''''
My database.yml file is fine
Any ideas why this is happening
--
Posted via http://www.ruby-forum.com/.

2010 Dec 04

1

Quadratic programming with semi-definite matrix

...re there any (fast) packages
that allows me to do QP with (large) semidefinite matrices?
Example:
t <- 100
y <- signalConvNoisy[1,]
D <- crossprod(H,H)
d <- crossprod(H,y)
A <- cbind(rep(-1, nrow(H)), diag(ncol(H)))
b0 <- c(t, rep(0, ncol(H)))
sol <- solve.QP(Dmat=D, dvec = d, Amat = A, bvec = b0)$solution
Error in solve.QP(Dmat = D, dvec = d, Amat = A, bvec = b0) :
matrix D in quadratic function is not positive definite!
Thanks in advance,
Andreas Jensen

2010 Dec 06

1

use pcls to solve least square fitting with constraints

Hi,
I have a least square fitting problem with linear inequality
constraints. pcls seems capable of solving it so I tried it,
unfortunately, it is stuck with the following error:
> M <- list()
> M$y = Dmat[,1]
> M$X = Cmat
> M$Ain = as.matrix(Amat)
> M$bin = rep(0, dim(Amat)[1])
> M$p=qr.solve(as.matrix(Cmat), Dmat[,1])
> M$w = rep(1, length(M$y))
> M$C = matrix(0,0,0)
> p<-pcls(M)
Error in t(qr.qty(qra, t(M$X))[(j + 1):k, ]) :
error in evaluating the argument 'x' in selecting a method for function 't'
Af...

2004 Sep 01

0

not positive definite D matrix in quadprog

...8.232288e+01 1.961199e+00 5.976441e-01
[6] 2.810968e-01 1.253140e-09 1.428534e-12
Dmat <- D.vectors%*%D.quad%*%ginv(D.vectors)
dvec <-
-c(-2910.533769,-2905.609008,-3012.223863,-16274.97455,-17222.46423,-18380.6
391,-357.8878464,-379.6371849)
#this ensures that coefficients are positive:
Amat <- matrix(0,8,8)
diag(Amat) <- 1
bvec <- rep(0,8)
#it says D is not positive definite ...
solve.QP(Dmat,dvec,Amat,bvec=bvec)
Error in solve.QP(Dmat, dvec, Amat, bvec = bvec) :
matrix D in quadratic function is not positive definite!
------------------------------------------...

2006 Feb 01

1

output hessian matrix in constrOptim

Hi,
Is there any way to get the hessian matrix from the "constrOptim" function without supplying gradient function? Thanks.
---------------------------------
Bring words and photos together (easily) with
[[alternative HTML version deleted]]

2012 Apr 26

0

Problem with constrOptim when hitting boundary

...and so I don't know if it is always a pathological example like this. This is just an example I found where I know it failed.
Thanks for your help,
Elizabeth Purdom
Example data:
> x <- c(12, 17, 9, 15, 15, 9, 15, 11, 12, 7)
> m <- c(12,17, 9, 15, 15, 9, 15, 11, 12, 7)
> AMat<-matrix(c(1,0,0,1),byrow=T,nrow=2,ncol=2)
> eventTiming(x, m, history = AMat)
Error message:
Error in optim(theta.old, fun, gradient, control = control, method = method, :
initial value in 'vmmin' is not finite
Enter a frame number, or 0 to exit
1: eventTiming(x, m, history...

2006 Nov 08

0

Solving a maximization problem using QUADPROD

...) %*% b + 1/2 b^T b
# under the constraints: A^T b >= b0
# with b0 = (-8,2,0)^T
# and (-4 2 0)
# A = (-3 1 -2)
# ( 0 0 1)
# we can use solve.QP.compact as follows:
#
library(quadprog)
Dmat <- matrix(0,3,3)
diag(Dmat) <- 1
dvec <- c(0,5,0)
Aind <- rbind(c(2,2,2),c(1,1,2),c(2,2,3))
Amat <- rbind(c(-4,2,-2),c(-3,1,1))
bvec <- c(-8,2,0)
solve.QP.compact(Dmat,dvec,Amat,Aind,bvec=bvec)
Thanks,
Serguei

2007 Jan 12

0

Linear Optimization

...ible, 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,...

2014 Jun 19

1

Restrict a SVAR A-Model on Matrix A and Variance-Covariance-Matrix

...6 more restrictions.
So in total I would have 4+6+6=16 restrictions. The SVAR would be just
identified.
My problem is that I don't know how to implement this
Variance-Covariance-Matrix within R and {vars}.
My Code so far is:
# Prediction SVAR - A-Model (B-Matrix = NULL)
# restrictions:
# 1) Amat = A_Matrix
# 2) ????
VAR.est <- VAR(data.ts, p = 4, type = "none")
SVAR.A.est <- SVAR(x=VAR.est, estmethod = "direct", Amat = A_Matrix ,
Bmat = NULL, hessian = TRUE, lrtest = TRUE)
#--------------------------------------------------------------------...

2006 Apr 13

1

Read User Agent

Does anyone know how to read the user agent from a controller ?
Thanks
--
Posted via http://www.ruby-forum.com/.

2007 Jul 11

0

Some questions about quadratic programming (QP)

...for that?
3- In QP formulation we have a constant 1/2 in objective function. This should be multiplied by the user or it is done by the algorithm?
4- More important, when I multiply a b*b matrix by D in quadratic term of objective function, I get thise message:
Error in solve.QP(Dmat, dvec, Amat, bvec) :
matrix D in quadratic function is not positive definite!
How to multiply b*b matrix by the diagonal matrix ?
Thank you very much for any help.
Amir
---------------------------------
Park yourself in front of a world of choices in alternative vehicles.
[[alternativ...

2011 May 30

0

definition of meq at spg

For my problem I have
#Constraints
b11<-0
b21<-0
b12<-0
b22<-0
n1>=0
n2>=0
n1<=1
n1<=1
n1+n2=1
In order to use spg I set
Amat<-matrix(rbind(c(rep(0,10)),c(rep(0,10)),c(rep(0,2),1,rep(0,7)),
c(rep(0,3),1,rep(0,6)),c(rep(0,10)),c(rep(0,10)),
c(rep(0,6),1,rep(0,3)),c(rep(0,7),1,rep(0,2)),
c(rep(0,8),1,rep(0,1)),c(rep(0,9),1,rep(0,0)),
c(rep(0,8),1,rep(0,1)),c(rep(0,9),1,rep(0,0)),
c(rep(0,8),1,1)),ncol=10)
b<-c(rep(0,...

2007 Dec 28

1

Which kernel for Xen 3.1 on Etch ?

Hello,
I'm trying to get Xen 3.1 from backports.org to work on a Debian Etch server.
I can't find a kernel corresponding to Xen 3.1. Which kernel should I use ?
Is there an installation guide somewhere ?
Thanks a lot
--
S?bastien Munch - http://www.yeiazel.net
Qui bene amat, bene castigat

2007 Jan 29

1

SOAP4R Error in Rails

Hi all
I have a ruby script that calls a web service which works just fine,
However when i try to use the same code from a rails model I get the
following error:
uninitialized constant SOAP::Mapping::EncodedRegistry
I have tried to load the gem soap4r from both the model and the
config/environment.rb files but i still get the same error
Any ideas on what I''m doing wrong ???