Comments (7)
float is used in some parts of ojAlgo, but is not available with the optimisation solvers. And it wont be easy to add. Further I'm not convinced it would be much faster. For larger models you could potentially save a lot of memory and that would improve L1/L2/L3 cache usage.
There may be other things to do. Do you have inequality constraints? Are all problems the same size (same number of variables AND constraints)? Do you use ExpressionsBasedModel?
from ojalgo.
We do have inequality contraints. (All x >= 0). If it helps, we can even make a reasonable guess on upper bounds for x too. I've been doing some thinking, though, and I suspect that floats would probably achieve somewhere between 50% to 100% improvement, though I understand that it may require a fair bit of dev (or more importantly, testing.)
The problems are not exactly all the same size, but your question gave me a pretty big idea. Although there are ~100 million matrix As to optimize (the equation is the standard least squares of --> min ||Y - A.X||^2, with X >= 0) , all (or maybe say 90%) of the 100 million matrix As could probably be represented by a handful (eg ~40 to ~100) distinct matrixes...(The observation Y would all vary, but at least AtA and, more importantly, its inverse could be cached and so it would not need to recomputed). This idea occurred to me once you mentioned "Are all problems the same size". (Also, the x >= 0 constraint is the same, though the size of x vairies of course from problem to problem.) Thoughts regarding the idea of caching AtA and its inverse? For caching the invese, though, I presume I would need to modify the solver code to "handle caching"? Is there a "recommened" approach that's clean to do this, or does it ultimately require copying the code for that class and performing the needed surgery?
On a different note, I like the "premultiply" options. However, I couldn't figure out how to do a similar "preTranspose" operation. Specifically, after I create A, I wish to do something like "preTranspose" A, but it doensn't seem possible to do so. (matrix "A" is generated through PrimitiveDenseStore.Factory.rows(...) statement.) Is it possible? (One workaround is to premultiply matrix A with the Identity Matrix, and then do the transpose, but that's an necessary multiplication.) Also, on a related note, if I understood the code correctly, the matrixes are stored in column major order, right? So would A.x (where A is a matrix and x is a vector) be slighly less efficient (due to caching) that if matrix A were stored in row major order like say ejml? (I'm just trying to understand at this stage, so no big deal if this question is esoteric.)
Finally, how would Expression Builder improve performance in this case compared to simply using the ConveSolver.Builder(). As near as I can tell, the ExpressionBasedModel will call the ConvexSolver but in my case it seem both simpler and more direct (possibly even faster) to just supply matrix Q and C directly to the convex solver rather than (artificially) introducing an intermediary layer via Expression Builder (which would require some more coding for the translation of matrix A etc into the Expression Builder format.) Thoughts? Thanks in advance, apete.
from ojalgo.
from ojalgo.
To answer your original question...
The requirements to make the ConvexSolver:s optionally work with float rather than double has little to do with the solvers themselves. What's needed is a PhysicalStore.Factory implementation that produces suitable DecompositionStore instances (based on float[]).
That factory would then be used when instantiating the solvers, and in turn when instantiating the various internal matrix decomposers and solvers.
Copy-and-paste and search-and-replace on PrimitiveDenseStore will get you underway.
public final class Primitive32DenseStore extends Primitive32Array implements PhysicalStore<Float>, DecompositionStore<Float> {
The Primitive32Array you need to extend already exists. Then there is a collection of supporting classes like FunctionSet, AggregatorSet and Scalar.Factory. To make everything work you also need to "copy-and-paste and search-and-replace" one method in each of the classes in the org.ojalgo.matrix.store.operation package.
Then I assume there will be cases where one would have to reconsider various interface declarations...
from ojalgo.
Awesome! Thank you. What about the last 2 remaining questions:
On a different note, I like the "premultiply" options. However, I couldn't figure out how to do a similar "preTranspose" operation. Specifically, after I create A, I wish to do something like "preTranspose" A, but it doensn't seem possible to do so. (matrix "A" is generated through PrimitiveDenseStore.Factory.rows(...) statement.) Is it possible? (One workaround is to premultiply matrix A with the Identity Matrix, and then do the transpose, but that's an necessary multiplication.) Also, on a related note, if I understood the code correctly, the matrixes are stored in column major order, right? So would A.x (where A is a matrix and x is a vector) be slighly less efficient (due to caching) that if matrix A were stored in row major order like say ejml? (I'm just trying to understand at this stage, so no big deal if this question is esoteric.)
from ojalgo.
Not sure I understand the problem. Can't you just call matrix.transpose();
ojAlgo's matrix multiplication implementations do not differentiate between vector och matrix arguments, and they're proven to be quite efficient.
from ojalgo.
As far as I know your questions have been answered.
I have created a project here at GitHub to review matrix element type support: https://github.com/optimatika/ojAlgo/projects/2
from ojalgo.
Related Issues (20)
- how to use Expression to form expression like x/1-x? HOT 1
- Solution does not balance based on weight HOT 3
- make ExpressionsBasedModel.isInfeasible() public HOT 13
- Expression should have "add" method that takes Variable as argument. HOT 4
- Eigenvalues and Eigenvectors differing from MatLab implementation? HOT 3
- getEigenpairs() doesn't work on hermitian complex matrix HOT 2
- Generalised Eigenvalue Problems do not work on complex matrices HOT 4
- Array index out of bounds exception while using IntegerStrategy HOT 7
- Non linear programming HOT 2
- hardware profile HOT 6
- Add a bibtex reference for citing this software HOT 1
- Do you have the ojAlgo js library HOT 1
- Get UNEXPLORED status after sometime, HOT 4
- Request: Support Implicit Expansion with Arithmetic Operations HOT 2
- Issue with Cholesky decomposition - symmetric positive-definite matrix decomposition is not solvable HOT 2
- invert method got wrong result HOT 3
- Solver returns INFEASIBLE on a simple problem with a clear solution HOT 6
- Allocation of number of non-zero elements in SparseStore HOT 4
- QR Decomposition's getInPlace returns null HOT 4
- ConvexSolver didn't found correct solution HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ojalgo.