- Linear programming help
- Posted by dave on October 12th, 2004
I'm developing in VB and I'm looking for a linear programming function
like solver in Microsoft Excel. I have tried trial and error approach
although the most
accurate so far it takes forever.In case where I have 100 variables with
40 possible values for each, I get 40^100 iterations.
My function is (x1*wt1)+(x2*wt2)+...(x100*wt100).
I use 2 constraints to keep the values realistic, x=>0,x<40.
I save each iteration with a certain increase over previous iteration.
I need a better VB algorithm.
- Posted by Paul Lutus on October 13th, 2004
dave wrote:
You need a better language. VB is simply not suited for this sort of task.
Have you considered Mathematica or one of its cheaper alternatives? These
tools are actually meant for this class of problem.
--
Paul Lutus
http://www.arachnoid.com
- Posted by Robert Wessel on October 13th, 2004
"dave" <nospam@nospam.net> wrote in message news:<XrXad.153170$as2.79426@bignews3.bellsouth.ne t>...
Gaussian Elimination like you learned in algebra class? There are
more sophisticated and fast ways, but start there.
Google is your friend.
- Posted by Dan Tex1 on October 13th, 2004
From: robertwessel2@yahoo.com (Robert Wessel)
Yes. As Robert indicates, choice of algorithms can make an astonishing
difference!
Although... based on your description, I'm not totally sure what it is you
are trying to solve. If you have to do 40^100 iterations of anything... it's
going to take a while!!! My hand calculator can't even display a number that
large.
In any case... try converting your code to fortran. Converting from VB to
Fortran isn't much more than child's play. Fortran was designed for speed with
this type of algorithm in mind. Basic wasn't. Speedwise, I absolutely
guarantee that a fortran version of your algorithm will beat the snot out of
your VB version of the algorithm - it won't even be close ( I have nothing at
all against VB, it's just that Microsoft has apparently spent no real time
attempting to optimize the efficiency of their VB produced executables... thus
not making it a great language when you need speed ).
Dan :-)
- Posted by Georg Scholz on October 13th, 2004
Well that's right, but even Mathematica isn't able to handle 40^100
iterations WITHOUT ANOTHER algorithm.
Most probably the OP has some reasons why he wants to stick to VB. In this
case it is correct to say that he needs a better algorithm.
Granted, VB is not a language designed for high-speed execution of
statements.
E.g. all sorts of loops execute rather slow in VB.
On the other side, it is a fully functional procedural language just like
Pascal or C.
Well, I can't tell the OP which algorithm to use, since it is years ago
since I did some linear programming tasks. But I'm sure there exists a
better algorithm, and in this case it can be notated in VB, too.
Georg Scholz
- Posted by Paul Lutus on October 13th, 2004
Georg Scholz wrote:
/ ...
My point was Mathematica will know how to manage the problem, at the risk of
overlooking a statistically improbable ideal result. It is designed to deal
with these problems.
--
Paul Lutus
http://www.arachnoid.com
- Posted by Will Twentyman on October 14th, 2004
dave wrote:
If you are getting 40^100 iterations, you must be doing a trial and
error approach. Look up the Simplex Method.
--
Will Twentyman
email: wtwentyman at copper dot net
- Posted by Robert Wessel on October 14th, 2004
dantex1@aol.com (Dan Tex1) wrote in message news:<20041013034607.11452.00004287@mb-m23.aol.com>...
Converting to Fortran would likely result in a several-times constant
factor improvement in performance (perhaps on the order of 4-10
times), given the same algorithm. (Ignoring the likelihood of finding
a highly efficient canned Fortran library procedure for this task.)
Converting to Fortran is *not* the answer, at least not yet. Reducing
the OP's runtime by 150 orders of magnitude with the use of an
appropriate algorithm is the first order of business. If it still
needs to be five times faster after that's done, we can talk about
changing languages.
- Posted by gswork on October 14th, 2004
"dave" <nospam@nospam.net> wrote in message news:<XrXad.153170$as2.79426@bignews3.bellsouth.ne t>...
if you check the Excel helpfile you find that:
"The Microsoft Excel Solver tool uses the Generalized Reduced Gradient
(GRG2) nonlinear optimization code developed by Leon Lasdon,
University of Texas at Austin, and Allan Waren, Cleveland State
University.
Linear and integer problems use the simplex method with bounds on the
variables, and the branch-and-bound method, implemented by John Watson
and Dan Fylstra, Frontline Systems, Inc. For more information on the
internal solution process used by Solver"
The first paragraph is interesting enough, but the second one is
knowlegde you can use to check google:
http://www.google.com/search?hl=en&l...plex+vb+source
no guarantees, but i think you're enroute now. good luck
- Posted by Dan Tex1 on October 15th, 2004
Very true. Sounds like the "algorithm" is what is most important here to start
with.
Dan :-)