Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overflow error in Gomory Cutting Plane method #1

Closed
nol0n opened this issue Apr 16, 2024 · 3 comments
Closed

Overflow error in Gomory Cutting Plane method #1

nol0n opened this issue Apr 16, 2024 · 3 comments

Comments

@nol0n
Copy link
Owner

nol0n commented Apr 16, 2024

How to reproduse

in application main.cpp

...
obv::Table table;
table.readFile("./test.txt"); // with problem given below

obv::lpalgs::simplexMethod(table);
obv::lpalgs::cuttingPlane(table);
std::cout << table << "\n\n";
...

Example

problem

max F = 1 * x1 + 15 * x2 + 24 * x3 + 3 * x4

3 * x1 +  4 * x2 +  1 * x3 +  2 * x4 <= 29
2 * x1 + 15 * x2 + 12 * x3 +  3 * x4 <= 61
3 * x1 +  5 * x2 +  2 * x3 + 14 * x4 <= 37
2 * x1 + 98 * x2 + 32 * x3 + 23 * x4 <= 57

format for input file

4  4
1 15 24  3
3  4  1  2 29
2 15 12  3 61
3  5  2 14 37
2 98 32 23 57

Expected answer

9 * x1 + x3 = 33

Now

It can't solve this problem because of integer overflow

@nol0n
Copy link
Owner Author

nol0n commented Apr 22, 2024

Fixed this method, at least I think so.

@nol0n nol0n closed this as completed Apr 22, 2024
@nol0n
Copy link
Owner Author

nol0n commented Apr 24, 2024

After fixing other errors, this algorithm started causing overflow errors for integer values in rational numbers when trying to solve some problems, including this. The only fix I see is to use some library like GMP, but I'm not doing it because it will require me to rewrite everything. For now, the base cutting plane algorithm can't solve all problems (I think it will be correct to say it can solve some).

@nol0n nol0n reopened this Apr 24, 2024
@nol0n nol0n changed the title Error in Gomory Cutting Plane method Overflow error in Gomory Cutting Plane method Apr 24, 2024
@nol0n
Copy link
Owner Author

nol0n commented Apr 26, 2024

And so... I decided to fix this issue by using BigInt class made by this kind man. It works for now, but I saw this issue and I think I'll also implement GMP variant later.

@nol0n nol0n closed this as completed Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant