0
$\begingroup$

I am trying to implement simplex method algorithm in PHP language. But I am facing with precision problem.

For example if I try to solve these equations:

1 0 0 0 0 0 0 0 0 0 >= 1 
0 1 0 0 0 0 0 0 0 0 >= 10 
0 0 1 0 0 0 0 0 0 0 >= 1 
0 0 0 1 0 0 0 0 0 0 >= 1 
0 0 0 0 1 0 0 0 0 0 >= 8 
0 0 0 0 0 1 0 0 0 0 >= 9 
0 0 0 0 0 0 1 0 0 0 >= 4 
28.46295 6.76625 32.8487 21.39885 1.41525 1.1381 2.5575 0 0 0 <= 375 
28.46295 6.76625 32.8487 21.39885 1.41525 1.1381 2.5575 0 0 0 >= 125 
17.2515 1.1718 24.8496 17.68302 0.093 0.10695 0.07905 0 0 0 <= 93.75 
17.2515 1.1718 24.8496 17.68302 0.093 0.10695 0.07905 0 0 0 >= 31.25 
6.61125 4.8667 3.81505 1.77735 0.984 0.83435 0.16605 0 0 0 <= 93.75 
6.61125 4.8667 3.81505 1.77735 0.984 0.83435 0.16605 0 0 0 >= 31.25 
4.6002 0.72775 4.18405 1.93848 0.33825 0.1968 2.3124 0 0 0 <= 187.5 
4.6002 0.72775 4.18405 1.93848 0.33825 0.1968 2.3124 0 0 0 >= 62.5 
17.2515 1.1718 24.8496 17.68302 0.093 0.10695 0.07905 1 0 0 >= 62.5 
17.2515 1.1718 24.8496 17.68302 0.093 0.10695 0.07905 -1 0 0 <= 62.5 
6.61125 4.8667 3.81505 1.77735 0.984 0.83435 0.16605 0 1 0 >= 62.5 
6.61125 4.8667 3.81505 1.77735 0.984 0.83435 0.16605 0 -1 0 <= 62.5 
4.6002 0.72775 4.18405 1.93848 0.33825 0.1968 2.3124 0 0 1 >= 125 
4.6002 0.72775 4.18405 1.93848 0.33825 0.1968 2.3124 0 0 -1 <= 125 

and in few steps I am dealing with numbers like -2.2204460492503E-16 PHP is not capable to deal with very small number without an precision error...

So my question is, is there any point of calculation where I can for example round the numbers? Because just working with bigger precision is not a solution (I think) because when we have a number 1/3 there is not enough space after decimal point....

Thanks

$\endgroup$
0
$\begingroup$

Ok well what I did and is working as solution is that after each elimination I check whole table and numbers which has absolute value smaller then 0.000001 I set to 0....

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.