[R] optimization problem

Ravi Varadhan rvaradhan at jhmi.edu
Sat Jan 16 20:01:32 CET 2010


Yes, it can be formulated as an LSAP.  It works just fine.  I have checked it with several 3 x 3 examples.

Here is another convincing example:

n <- 50

A <- matrix(rnorm(n*n), n, n)

> # Find P such that ||PA - C|| is minimum

vec <- sample(1:n, n, rep=FALSE)  # a random permutation
  
C <- A[vec, ]  # the target matrix is just a permutation of original matrix
 
B <- pMatrix.min(A, C)$A

> dist(B, C)
[1] 0

> dist(A, C)
[1] 69.60859

Ravi.
____________________________________________________________________

Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvaradhan at jhmi.edu


----- Original Message -----
From: Erwin Kalvelagen <erwin.kalvelagen at gmail.com>
Date: Saturday, January 16, 2010 1:36 pm
Subject: Re: [R] optimization problem
To: Ravi Varadhan <rvaradhan at jhmi.edu>
Cc: r-help at stat.math.ethz.ch


> I also have doubts this can be formulated correctly as a linear assignment
> problem. You may want to check the results with a small example.
> 
> Erwin
> 
> ----------------------------------------------------------------
> Erwin Kalvelagen
> Amsterdam Optimization Modeling Group
> erwin at amsterdamoptimization.com
> 
> ----------------------------------------------------------------
> 
> 
> On Sat, Jan 16, 2010 at 9:59 AM, Ravi Varadhan <rvaradhan at jhmi.edu> wrote:
> 
> >
> > Thanks, Erwin, for pointing out this mistake.
> >
> > Here is the correct function for Frobenius norm.
> >
> > Klaus - Just replace the old `dist' with the following one.
> >
> > dist <- function(A, B) {
> >  # Frobenius norm of A - B
> >  n <- nrow(A)
> >  sqrt(sum((B - A)^2))
> >  }
> >
> > Ravi.
> >
> > ____________________________________________________________________
> >
> > Ravi Varadhan, Ph.D.
> > Assistant Professor,
> > Division of Geriatric Medicine and Gerontology
> > School of Medicine
> > Johns Hopkins University
> >
> > Ph. (410) 502-2619
> > email: rvaradhan at jhmi.edu
> >
> >
> > ----- Original Message -----
> > From: Erwin Kalvelagen <erwin.kalvelagen at gmail.com>
> > Date: Saturday, January 16, 2010 2:35 am
> > Subject: Re: [R] optimization problem
> > To: r-help at stat.math.ethz.ch
> >
> >
> > > Ravi Varadhan <rvaradhan <at> jhmi.edu> writes:
> > > > dist <- function(A, B) {
> > > > # Frobenius norm of A - B
> > > >     n <- nrow(A)
> > > >     sum(abs(B - A))
> > > > }
> > > >
> > >
> > > See  for a definition of the
> > > Frobenius norm.
> > >
> > >
> > > Erwin
> > >
> > > ----------------------------------------------------------------
> > > Erwin Kalvelagen
> > > Amsterdam Optimization Modeling Group
> > > erwin at amsterdamoptimization.com
> > >
> > >
> > > ______________________________________________
> > > R-help at r-project.org mailing list
> > >
> > > PLEASE do read the posting guide
> > > and provide commented, minimal, self-contained, reproducible code.
> >



More information about the R-help mailing list