I'd like to know if it is possible to introduce an initial basic feasible solution to the simplex in glpk, this in order to avoid de initialization phase of the algorithm and save computation time. I also want to know if glpk library uses the standard simplex or the revised simplex. Thanks.
Yes, you can set a custom basis by using
glp_set_col_stat(). You will have to set each column to be Basic (GLP_BS) or Non-basic (GLP_NL). You could also use the API glp_adv_basis method, though I don't think it lets you customize the basis.
I recommend the very readable Section 2.6 in the LP Basis Construction Routines here.
And yes, GLPK uses the Revised Simplex. I believe this is the default setting.
Related
I want to model an optimization problem that contains quite some bilinear terms. As such, I want to make use of the functionality of Gurobi 9.0 to solve bilinear problems. Clearly, I can use the GurobiPy API. However, I might want to compare other solvers (like BARON). So, I wonder whether it is possible to use Pyomo to formulate the problem and then solve it using Gurobi? Will there be any problems?
As far as I can tell, there should not be a problem. The same Gurobi solver will be used. Your problem will just be modelled in a somewhat different syntax (PYOMO) which is easily portable for solving with a wider range of solvers.
If still in doubt, I suggest you try a very simple problem with a bilinear term.
Note however that BARON requires a commercial license unlike Gurobi which offers free academic licenses.
Best of luck!
I have a set of data z(0), z(1), z(2)...,z(n) that I am currently fitting with a 2 variables polynomial of the kind p(x,y) = a(1)*x^2+a(2)*y^2+a(3)*x*y+a(4). I have i=1,...,n (x(i),y(i)) coordinates that I impose to be p(x(i),y(i))=z(i). In this way I have a Overdetermined System that I can solve using Eigen SVD . I am looking for a more sophisticated method that can take care of outliers, like a Least Median of Squares robust regression (as described here) but I haven't found a C++ implementation for 2 variables. I looked in GSL but it seems there is nothing for 2 variable functions. The only other solution I can think of is using a TGraph2D in ROOT. Do you know any other solution? Numerical recipes maybe? Since I am writing C++ code I would prefer C or C++ implementations.
Since non answer has been given yet, but I am still working on this problem, I will share my progresses here.
The class TLinearFitter has a fit method that allows you to select Robust fitting - Least Trimmed Squares regression (LTS):
https://root.cern.ch/root/html532/TLinearFitter.html
Another possible solution, more time consuming maybe, but maybe more efficient on the long run is to write my own function to be minimized, and the use:
https://projects.coin-or.org/Ipopt to minimize it. Although in this approach there is a bigger "step". I don't know how to use the library and I haven't (yet?) found a nice tutorial to understand it.
here: https://wis.kuleuven.be/stat/robust/software there is a Fortran implementation of the LMedS algorithm called PROGRESS. So another possible solution could be to port this software to C/C++ and make a library out of it.
There is boost 1.53 out and OdeInt in it. It has a range of numerical ode solvers in it. Yet I wonder if there is lsode analog in it - for cases when you have garanteed analitical solution?
I don't fully understand your question. LSODE solves any generic ODE of the form dx/dt = f(x,t) [1], just like the methods in odeint. However, LSODE checks for stiffness of the problem and chooses the right scheme (predictor corrector for non-stiff, and backward differentiation for stiff problems). odeint does not provide this automatic selection, but rather relies on the user to choose the right scheme for the problem. None of the two implementations use a possible existing analytical solution, as far as I know.
[1] https://computation.llnl.gov/casc/odepack/odepack_home.html
Most ODE solvers does imply some kind of restrictions over original LSODE (the Fortran implementation). The closest alternative I know is Octave from GNU for now.
were can I find reliable code for critical values for probability distributions? For instance, F critical values for the fisher test...
?
Thanks for any relevant reference.
The Boost Math Toolkit contains the F distribution. To get critical values, use the quantile non-member function. If you can't use any third party tools, then you are in for a lot of work since most distributions do not have a closed form analytical expression for critical values. E.g. the normal distribution requires numerical integration.
I hope they re-propose statistical special functions for C++ TR2. Also Boost has a similar proposal. I know that doesn't help now but I think this stuff should be canned for everyone to just pick up and use.
I'm doing some linear algebra math, and was looking for some really lightweight and simple to use matrix class that could handle different dimensions: 2x2, 2x1, 3x1 and 1x2 basically.
I presume such class could be implemented with templates and using some specialization in some cases, for performance.
Anybody know of any simple implementation available for use? I don't want "bloated" implementations, as I'll running this in an embedded environment where memory is constrained.
Thanks
You could try Blitz++ -- or Boost's uBLAS
I've recently looked at a variety of C++ matrix libraries, and my vote goes to Armadillo.
The library is heavily templated and header-only.
Armadillo also leverages templates to implement a delayed evaluation framework (resolved at compile time) to minimize temporaries in the generated code (resulting in reduced memory usage and increased performance).
However, these advanced features are only a burden to the compiler and not your implementation running in the embedded environment, because most Armadillo code 'evaporates' during compilation due to its design approach based on templates.
And despite all that, one of its main design goals has been ease of use - the API is deliberately similar in style to Matlab syntax (see the comparison table on the site).
Additionally, although Armadillo can work standalone, you might want to consider using it with LAPACK (and BLAS) implementations available to improve performance. A good option would be for instance OpenBLAS (or ATLAS). Check Armadillo's FAQ, it covers some important topics.
A quick search on Google dug up this presentation showing that Armadillo has already been used in embedded systems.
std::valarray is pretty lightweight.
I use Newmat libraries for matrix computations. It's open source and easy to use, although I'm not sure it fits your definition of lightweight (it includes over 50 source files which Visual Studio compiles it into a 1.8MB static library).
CML matrix is pretty good, but may not be lightweight enough for an embedded environment. Check it out anyway: http://cmldev.net/?p=418
Another option, altough may be too late is:
https://launchpad.net/lwmatrix
I for one wasn't able to find simple enough library so I wrote it myself: http://koti.welho.com/aarpikar/lib/
I think it should be able to handle different matrix dimensions (2x2, 3x3, 3x1, etc) by simply setting some rows or columns to zero. It won't be the most fastest approach since internally all operations will be done with 4x4 matrices. Although in theory there might exist that kind of processors that can handle 4x4-operations in one tick. At least I would much rather believe in existence of such processors that than go optimizing those low level matrix calculations. :)
How about just store the matrix in an array, like
2x3 matrix = {2,3,val1,val2,...,val6}
This is really simple, and addition operations are trivial. However, you need to write your own multiplication function.