Rank: 3174 based on 19 downloads (last 30 days) and 1 file submitted
photo

Andrew Jackson

E-mail
Lat/Long
52.1983184814453, 0.120700001716614

Personal Profile:

Professional Interests:
civil engineering, structural engineering

 

Watch this Author's files

 

Files Posted by Andrew
Updated   File Tags Downloads
(last 30 days)
Comments Rating
04 Aug 2008 EliminateConstraints Eliminates variables from a problem with linear equality constraints to give an unconstrained proble Author: Andrew Jackson eliminate, linear, linear algebra, contraint, mathematics, algebra 19 3
  • 4.0
4.0 | 2 ratings
Comments and Ratings by Andrew
Updated File Comments Rating
19 Nov 2008 grTheory - Graph Theory Toolbox 27 functions for different tasks of graph theory Author: Sergii Iglin

Comments and Ratings on Andrew's Files View all
Updated File Comment by Comments Rating
04 Aug 2008 EliminateConstraints Eliminates variables from a problem with linear equality constraints to give an unconstrained proble Author: Andrew Jackson D'Errico, John

If I could recommend something...

I'd add a published m-file to this that has several examples of how to use it, and what features it has. When you publish the file, it will be seen as a list of examples that clearly show how to use your code. In fact, I'll even give you a start on it. Publish the code I've included below, then zip it all up with your m-file and update the zipped file here on the FEX.

%% Minimize an equality constrained optimization problem
A = [1 1 1];
b = 1;
[C,d] = eliminateConstraints(A,b)

%%
% set up a quadratic form to minimize.
%
% With no constraints, the minimizer is at [0 0 0].
H = [2 -1 0;-1 2 -1;0 -1 2];

fun = @(Y) (C*Y+d)'*H*(C*Y+d);
Y = fminsearch(fun,[1 1]',optimset('tolx',1.e-7))

%%
% The solution should be [.3 .4 .3]
X = C*Y+d

%% Solve a constrained linear least squares
% G*X = h, aubject to the constraint A*x = b.
G = rand(10,5);
h = rand(10,1);

A = rand(2,5);
b = rand(2,1);

%%
% Solve it using lsqlin (in the optimization toolbox)
X0 = lsqlin(G,h,[],[],A,b)

%%
% Use eliminateConstraints instead
[C,d] = eliminateConstraints(A,b)

%%
% and solve it using backslash
Y1 = (G*C)\(h - G*d)
X1 = C*Y1 + d

%%
% Show that X0 and X1 were the same
[X0,X1]

%% Show that for a sparse matrix A that C is also sparse
A = sprand(10,100,.05);
spy(A)
title 'Spy of A matrix'
b = rand(10,1);
[C,d] = eliminateConstraints(A,b);
figure
spy(C)
title 'Spy for C matrix'

02 Aug 2008 EliminateConstraints Eliminates variables from a problem with linear equality constraints to give an unconstrained proble Author: Andrew Jackson D'Errico, John

Dimitri is not being dumb here. The author has failed to provide a tool that has any useful documentation. Your job as a programmer does not stop when you write the last line of code. If you think so, then you should be fired. You should document your code. Provide help. Otherwise, that code is just a bunch of random bits, useful to nobody else in the world.

This code has a couple of uses that I might think of. (The fact that I need to document the author's code is a major failure on this author's part. Does my irritation show through?)

You MIGHT choose to use this tool to enable an unconstrained nonlinear least squares solver to solve a linearly equality constrained problem, with a nonlinear objective function. For example, suppose you wish to use fminsearch to solve a problem where the sum of the parameters must be 1. You could use this function to help. You would still need to know what to do, but the author failed to provide any hints. Too bad.

Another possible use might be to solve a linear least squares problem with linear equality constraints. Suppose you wished to solve the problem

  G*x = h

subject to the equality constraint(s)

  A*x = b

This code provides a transformation x = C*y + d, so that the linear least squares problem reduces to

  A*(C*y+d) = b

or

  (A*C)*y = b - A*d

Solve it as

  y = (A*C)\(b - A*d)

and then recover the value of x from the supplied relation

  x = C*y + d

So, in theory, this code has some utility. Without the comments I've just provided, it is useless though to anybody who does not know enough about the problem that what it does is trivial. My point is that while I personally might in theory have found a tool like this of some use, I also know how to do what it does in only a few lines, so it still offers no value to me.

How about the help? Poor. It does not tell you what the inputs should be, in terms of their order, shape, class, or size. The outputs are similarly undescribed.

There is error checking, but since there is no real description of the inputs, how can you check for errors? There is no error check on the number of columns of b either (should be 1).

I feel there is also a flaw in the error checks. If you pass in an inconsistent system, the code will error out, but the error generated will be a very confusing one.

There are some internal comments, and the author has chosen descriptive variable names, so you can read the code.

How about the code itself? This uses loops to do what can be done in one line of code, at least if your matrix is full. I've not checked the algorithm itself to decide if it is as stable, as say, a call to null, but on a few tests I found that a numerically nonsingular (although poorly conditioned) matrix caused this code to fail.

An interesting point is, if A has many columns (i.e., x has many elements) but few rows, then the resulting C matrix will be very large, but if A is sparse, then C will be stored in a sparse format, and it will be sparse. The null solution would yield a full matrix here.

Had this code full documentation, coupled with complete examples on how to use it for at least the two classes of problems I've described, and if it had good help, then it would have earned a better rating from me. As it is, I can't justify a better rating than to say it needs improvement.

01 Aug 2008 EliminateConstraints Eliminates variables from a problem with linear equality constraints to give an unconstrained proble Author: Andrew Jackson Shvorob, Dimitri

I'll be happy to apologize if I'm being dumb, but: 'solution' of what? In what sense does this finding of C and d 'eliminate linear constraints'? What is it for?

Top Tags Applied by Andrew
algebra, cm thompson, contraint, eliminate, linear
Files Tagged by Andrew View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
26 Nov 2008 Screenshot Quiverc Creates a color quiver plot with arrows colors according to the magnitude of the vector. Author: Bertrand Dano cm thompson, vectors, coding theory, quiver, velocity, information theory 175 11
  • 4.3
4.3 | 10 ratings
04 Aug 2008 EliminateConstraints Eliminates variables from a problem with linear equality constraints to give an unconstrained proble Author: Andrew Jackson eliminate, linear, linear algebra, contraint, mathematics, algebra 19 3
  • 4.0
4.0 | 2 ratings
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com