Sign in to follow this  
Followers 0
Dieuz

Average Algorithm

4 posts in this topic

#1 ·  Posted (edited)

Hey guys,

I am facing a new problem. I would like Autoit to find several solutions to the Average equation below:

Posted Image

I choose "Average" and "N".

I want Autoit to find the possible values for a,b,c,d,e,f,g,h,i,j.

N= a+b+c+d+e+f+g+h+i+j

Values of N,Average, a,b,c,d,e,f,g,h,i,j are > 0 and Integer.

Anyone mind helping me?

Thanks alot guys!

Edited by Dieuz

Share this post


Link to post
Share on other sites



Disclaimer: It's been a couple of years since my last math course, so I could be wrong.

This is more of a math problem, and it's not really solvable without a system of equations that would give more information about each of these variables. Without more information there are an almost infinite number of solutions.


#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

That's an easy and small instance of the unbounded knapsack problem.

You can get decently fast results with almost any of the proven algorithms for solving it. Please note that there is no notion of optimality for the solutions. Also it can get more tough if you [very] significantly increase the size of the problem.

Make it:

a + 2*b + 3*c + 4*d + 5*e + 6*f + 7*g + 8*h + 9*i + 10*j = N*average

Depending on N*average there may exist number-theoretic considerations which could make a given instance trivial, due to the fact you use smooth (slowly increasing and even consecutive) integers as weights. But in the case of small size problems, I wouldn't even care as looking for such possibilities could prove way more complex than solving it directly.

Edit: at first I didn't notice your condition that coefficients should not be zero. If you really need that extra condition, you may have to change the presentation a bit because the generic problem traditionnally allows coefficients to be null.

That requires that N*average >= a+b+c+d+e+f+g+h+i+j but if that condition holds, you can always rewrite the problem this way:

B + 2*C + 3*D + 4*E + 5*F + 6*G + 7*H + 8*I + 9*J = N*average - (a + b + c + d + e + f + g + h + i + j)

and solve for {B .. J} allowing zeroes.

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Ahhh, my math knowledge failed me again, good catch jchd :(


#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0