kennyledet / Algorithm-Implementations

Share, discuss and learn about algorithm implementations!
http://algorithm.zone
MIT License
2.2k stars 532 forks source link

Error in findEnteringColumn #514

Open miguel14 opened 7 years ago

miguel14 commented 7 years ago

I use your code, and this have issues when I run this program

Maximize p = x + y subject to 2x + y <= 4, x + 2y <= 3

I solve it changing findEnteringColumn function

`// finds the next entering column private int findEnteringColumn(){ //float[] values = new float[cols]; //int location = 0;

    int count = 0; 
    for(int pos = 0; pos < cols-1; pos++){
        if(table[rows-1][pos] < 0){
            return pos;
            //System.out.println("negative value found");
            //count++;
        }
    }

    return -1; // This case never exist

    /*
    if(count > 1){
        for(int i = 0; i < cols-1; i++)
            values[i] = Math.abs(table[rows-1][i]);
        location = findLargestValue(values);
    } else location = count - 1;

    return location;
   */
}`

To validate I use this web https://www.zweigmedia.com/RealWorld/simplex.html

My complete code is here

`/*

import lp.LPObjects.Simplex.ERROR;

/**

} `

mik30s commented 7 years ago

Ok, I'll fix it up. Thanks

MiKaminskas commented 7 years ago

@miguel14 could you please again upload somethere your fix? All your links is broken :(

miguel14 commented 7 years ago

@MiKaminskas Hi, I found several bugs, so I better used the solver of CommonsMath3 of Apache. Sorry I delete the code.

http://commons.apache.org/proper/commons-math/