-
Notifications
You must be signed in to change notification settings - Fork 0
Adding a bit more documentation + clarifying some interfaces #2
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
7b7c02b
started on more extensive README.md
kwesiRutledge 65738b4
Updated dependencies to less buggy SymbolicMath.go + MatProInterface.go
kwesiRutledge ec8ae5c
Attempting to fix bug in how we solve from tableau
kwesiRutledge 5b5c414
Upgraded package dependencies + introduced simplex solution object
kwesiRutledge fb0ed9f
Added iterations field to SimplexSolution
kwesiRutledge 4096194
Improved the documentation of the `SimplexSolution`
kwesiRutledge 4ea1230
Remove commented code
kwesiRutledge e9b2b4d
Tried to debug the new example
kwesiRutledge 16d1b2a
Cleaning up unused code in example
kwesiRutledge 18ca59b
Merge branch 'kr/feature/gonum-bug1' of github.com:MatProGo-dev/simpl…
kwesiRutledge 6df1ba7
Upgraded MatProInterface.go interface
kwesiRutledge b3d2996
Upgraded usage of modified methods throughout simplex
kwesiRutledge aca9aa1
Fixing bug in SimplexMethod Tableau method
kwesiRutledge 941a322
Added working box example
kwesiRutledge e0f2023
remove references to old MatProInterface.go
kwesiRutledge c58b3b9
Updated README.md
kwesiRutledge 1882ae9
Updated README.md example
kwesiRutledge ccc5f8a
upgraded MatProInterface
kwesiRutledge 5919a5e
With the introduction of improved termination detection + better exit…
kwesiRutledge 05e6179
Fixed issues with the unused exported member Objective in SimplexSolu…
kwesiRutledge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,82 @@ | ||
| # simplex | ||
| A small library used to demonstrate the concepts of the Simplex algorithm in convex optimization. | ||
|
|
||
| # Installation | ||
|
|
||
| You can add this module to your package using: | ||
| ```bash | ||
| go get github.com/MatProGo-dev/simplex | ||
| ``` | ||
|
|
||
| # Usage | ||
|
|
||
| ``` | ||
| package main | ||
|
|
||
| import ( | ||
| "github.com/MatProGo-dev/MatProInterface.go/problem" | ||
| getKVector "github.com/MatProGo-dev/SymbolicMath.go/get/KVector" | ||
| "github.com/MatProGo-dev/SymbolicMath.go/symbolic" | ||
| "github.com/MatProGo-dev/simplex/simplexSolver" | ||
| ) | ||
|
|
||
| func BuildOptimizationProblem() problem.OptimizationProblem { | ||
| // setup | ||
| varCount := 2 | ||
| out := problem.NewProblem("Box LP Problem") | ||
|
|
||
| // Create the variables | ||
| x := out.AddVariableVector(varCount) | ||
|
|
||
| // Create the objective | ||
| c := getKVector.From( | ||
| []float64{1, 2}, | ||
| ) | ||
| out.SetObjective( | ||
| c.Transpose().Multiply(x), | ||
| problem.SenseMinimize, | ||
| ) | ||
|
|
||
| // Create the constraints | ||
| // - x >= 0 | ||
| out.Constraints = append( | ||
| out.Constraints, | ||
| x.GreaterEq(symbolic.ZerosVector(varCount)), | ||
| ) | ||
|
|
||
| // - x <= 1 | ||
| out.Constraints = append( | ||
| out.Constraints, | ||
| x.LessEq(symbolic.OnesVector(varCount)), | ||
| ) | ||
|
|
||
| return *out | ||
| } | ||
|
|
||
| func main() { | ||
| // This is just a placeholder to make the package "main" valid. | ||
| trickyProblem := BuildOptimizationProblem() | ||
|
|
||
| // Use solver to solve the problem | ||
| solver := simplexSolver.New("Simplex Solver Example") | ||
| solver.IterationLimit = 100 | ||
|
|
||
| // Solve the problem | ||
| solution, err := solver.Solve(trickyProblem) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
|
|
||
| // Print the solution | ||
| solutionMessage, _ := solution.Status.ToMessage() | ||
| println("Solution Status: ", solutionMessage) | ||
| println("Objective Value: ", solution.Objective) | ||
| println("Number of Iterations: ", solution.Iterations) | ||
| println("Variable Values: ") | ||
| for varName, varValue := range solution.VariableValues { | ||
| println(" ", varName, ": ", varValue) | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| See the examples directory for more example use cases for the library. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package tableau_algorithm1 | ||
|
|
||
| type VariableSelectionError struct { | ||
| EnteringVarIndex int | ||
| ExitingVarIndex int | ||
| } | ||
|
|
||
| func (e VariableSelectionError) Error() string { | ||
| if e.ExitingVarIndex == -1 { | ||
| return "VariableSelectionError: No exiting variable found, problem can not be improved." | ||
| } | ||
|
|
||
| if e.EnteringVarIndex == -1 { | ||
| return "VariableSelectionError: No entering variable found, current solution is optimal." | ||
| } | ||
|
|
||
| return "VariableSelectionError: Unknown variable selection error." | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The VariableValues map is not initialized before use. This will cause a panic when trying to assign values to a nil map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will likely delete this soon.