part calculation algorithm for jminer

  • admin

    @luxe stealing some pseudo code from StackOverflow:

    You don't need to calculate all factors, but you can go in both directions from the number to find its closest number which is the factor of given number

    Pseduo code will be:

    n= given number(dividend);
    x= second number( whose closest number is required)
    if(n%x==0) print x;
    print x-i
    else if(n%(x+i)==0){
    print x+i;
    else i=i+1

  • admin

    @haitch thanks again, yes thats a improvement, calculate in both directions and take the best/first hit from both. I posted the problem here, cause maybe is a math genius around ... i can not belive there is no algoritm solution/formular except from testing ...

  • @luxe yeah I was thinking that both direction would have improved the speed of the script
    but still I think I get what you want! ELENGANT

  • admin

    @luxe If the plotters were modified to always convert the stagger to a power of two, then the # of parts would be trivial - the power of two number equal to or greater than the chunkpartnonce - but optimized plots would break that. It's feasible that the the staggersize could be prime, so the only valid values are 1 and stagger.

    If chunkpartnonce can be highly variable, then: X = floor ( sqrt (staggersize)); while staggersize mod X != 0, dec(x)

  • admin

    @haitch staggersize is always a multiple of 8 (should be)
    i will need some time to understand that formular, thanks.

  • admin

    @luxe the formula will find the two highest factors of staggersize.Sqrt(staggersize) will give the highest possible factors, but most likely non-integer, floor makes it integer, then the decrement loop takes that integer down until it's a factor of Staggersize. If staggersize mod X = 0 then X is a factor and Staggersize div X is the other factor.

    Lets me think if it can be optimized if staggersize is always a multiple of 8

  • admin

    @haitch ok i will try to implement/test that

  • admin

    @luxe Given staggersize being a multiple of 8, then this should work:

    X = (sqrt(staggersize / 8) div 8) * 8 // gives you the largest multiple of 8 possible factor < sqrt(Staggersize / 8);

    If X != 0 then while ((Staggersize div X) != 0) & (X > 0) do dec(X,8);
    If X = 0 then X = 8;

    // When we exit the loop X will be a multiple of 8 factor of Staggersize, or 8

  • admin

    @haitch ahh you are too fast for me :-) i just implemented your previous suggestion:

        int highestFactor = (int) Math.floor(Math.sqrt(staggeramt));
        while(staggeramt % highestFactor != 0)

    And on my real life example it leads to 8 :-)
    But it is surely better than always take 8 by default, thanks.

    I will also check your improvement ... but first i want to make something to eat :-)

  • admin

    @luxe when Brain digs into a problem it moves fast sometimes .....

    Let me know how the improved version goes - haven't tested it but it should be 8x faster.

Log in to reply

Looks like your connection to Burst - Efficient HDD Mining was lost, please wait while we try to reconnect.