willauld / lpsimplex

Golang implementation of the Linear Programming (LP) Simplex algorithm
MIT License
11 stars 1 forks source link

Unable to input bounds && missing x[0], x[1],etc values in output && Incomprehensible error message #1

Closed ChenhuaWANG22 closed 5 years ago

ChenhuaWANG22 commented 5 years ago

Hi, firstly thank you for sharing you project.

I am looking a linear programming solver in Golang for my project and just did a quick test with this package and found below issues:

  1. Unable to input "bounds" parameter as below image showed, I can't use struct literal to initialize "bounds" variable. And I think the reason is in struct "lpsimplex.Bound", the field "lb" and "ub" are capitalized with lowercase which prevents access from package other than "lpsimplex".

Also, I notice in "lpsimplex_test.go", the test is under package "lpsimplex" instead of individual package "lpsimplex_test" like go official code. I guess that's the reason which prevents the test to discover this issue.

this is an example of test from go repository: https://github.com/golang/go/blob/master/src/bytes/buffer_test.go

  1. Missing x[0], x[1],etc values in output If I don't miss something, I can't find the x[0], x[1],etc values in the output with which the target function will be the optimal value.

  2. Incomprehensible error message as below image showed, I got an error message "A_eq Matrix error: Invalid input, must be two-dimensional" while the input parameter "Aeq" does be a two-dimensional slice while just without values (as no constraints with "equal" ).

And also, although this error message shown, the function still returns with "successfully" which is a little bit weird.

image

Besides, I used to use https://github.com/JWally/jsLPSolver this package in Javascript. I think it's welled designed and handy to use. You may have a look if you want some inspiration.

willauld commented 5 years ago

I’ll take a look at this.

Are you still thinking about using this or have you moved on?

Thanks,

Will

From: chenhua [mailto:notifications@github.com] Sent: Friday, September 20, 2019 11:16 PM To: willauld/lpsimplex lpsimplex@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [willauld/lpsimplex] Unable to input bounds && missing x[0], x[1],etc values in output && Incomprehensible error message (#1)

Hi, firstly thank you for sharing you project.

I am looking a linear programming solver in Golang for my project and just did a quick test with this package and found below issues:

  1. Unable to input "bounds" parameter as below image showed, I can't use struct literal to initialize "bounds" variable. And I think the reason is in struct "lpsimplex.Bound", the field "lb" and "ub" are capitalized with lowercase which prevents access from package other than "lpsimplex".

Also, I notice in "lpsimplex_test.go", the test is under package "lpsimplex" instead of individual package "lpsimplex_test" like go official code. I guess that's the reason which prevents the test to discover this issue.

this is an example of test from go repository: https://github.com/golang/go/blob/master/src/bytes/buffer_test.go

  1. Missing x[0], x[1],etc values in output If I don't miss something, I can't find the x[0], x[1],etc values in the output with which the target function will be the optimal value.

  2. Incomprehensible error message as below image showed, I got an error message "A_eq Matrix error: Invalid input, must be two-dimensional" while the input parameter "Aeq" does be a two-dimensional slice while just without values (as no constraints with "equal" ).

And also, although this error message shown, the function still returns with "successfully" which is a little bit weird.

https://user-images.githubusercontent.com/17723793/65368722-772a7180-dc77-11e9-9c03-bb88c1485099.png

Besides, I used to use https://github.com/JWally/jsLPSolver this package in Javascript. I think it's welled designed and handy to use. You may have a look if you want some inspiration.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/willauld/lpsimplex/issues/1?email_source=notifications&email_token=ACMHEOJ4BMG4MDGYX463GI3QKW3ZZA5CNFSM4IY5D232YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HMZZ6CA , or mute the thread https://github.com/notifications/unsubscribe-auth/ACMHEOKIGI3KFLPKGRY6KHDQKW3ZZANCNFSM4IY5D23Q . https://github.com/notifications/beacon/ACMHEOJCVV5CSO7TUKJSEMDQKW3ZZA5CNFSM4IY5D232YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HMZZ6CA.gif

ChenhuaWANG22 commented 5 years ago

Currently I have no luck with Golang and it seems I have to go back to C++ using something like google/or-tools. However, I do be interested in your project as the best solution for my project is to make the algorithm part written in Golang. If in future your project become mature enough, I definitely will consider to use it and rework my algorithm.

Below is the current situation I find these days (linear programming solver in Golang):

Besides, if you are open to have some opinions from me: After using simplex in gonum/gonum and taking a glancing on some efficient libraries like google/or-tools, JWally/jsLPSolver, coin-or/Clp, it seems only using originally simplex is not enough to make an efficient linear programming solver. However, I am not really familiar with linear programming algorithm, thus it's just my intuition without prove.

willauld commented 5 years ago

After some review I was able to recreate all your issues.

  1. Bound, I will export its fields.
  2. X[0], X[1], ..., The struct returned by LPSimplex() is complex but you can see what is in it by changing your print statement to: fmt.Printf("%+v\n", r). This will result in output of: {X:[4 0] Fun:-4 Nitr:1 Status:0 Slack:[18 0] Message:Optimization terminated successfully. Success:true Y:[0 1] Z:[0 6]}. From this you can see that X[0] is 4 and X[1] is 0 with a minimized value of -4, number of iterations being 1, clear status, success is true, Slack, Y and Z arrays as well as the message string.
  3. Strange error message, It was correct but inconsequential because the objects where empty. You have Aeq := [][]float64{{},{}} which is an array of two empty arrays (dimention 2x0). However, sense it is empty as is beq it has no effect on the calculation. My remedy will be to remove this check and let it hit other fatal errors which require your code to be changed before it will be run. Two approaches are possible. First change you definition of Aeq to Aeq := [][]float64{}, an empty matrix. Second, replace Aeq and beq with nil in the call to LPSimplex().

I should have my changes ready soon.

This implementation is using the original simplex algorithm which is also true of the implementation in gonum. I have been, not much lately, moving toward an implementation of the Revised Simplex Algorithm which is much faster in general. This is the algorithm used by most of the fast solvers.

I'll post again when I have this ready.

willauld commented 5 years ago

OK, I believe I have addressed all the issues in the current committed code.

If you see anything I missed please let me know.

Thanks,

ChenhuaWANG22 commented 5 years ago

As you mentioned you are moving toward Revised Simplex Algorithm, may I have an estimated date of this? I do be interested in it.

willauld commented 4 years ago

I didn't see this until now. I don't really have an estimate. Best I can do is off hand guess, that would be some time next summer.