Solving Linear Diophantine Equation Systems in C++ - c++

For my research I'm confronted with a system of linear diophantine equations.
I found several research papers on the topic but before I start to create
a solver myself, I would like to know if one does know of a (lightweight)
C++ math library, which solves such a system.

I suggest to try to use Octave embedded:
http://octave.sourceforge.net/docs.html

Related

Is there a CAS for Pharo?

While learning Python, I found the SymPy module, that is actually a entire computer algebra system (CAS) you can use to solve symbolic problems in mathemathics, like differential equations, polynomials et cetera. Now I'm learning Pharo, and I'd like to know if there's a way to do symbolic maths from within Pharo, something similar to SymPy.
There is a CAS in PolyMath, which is ported from CUIS, and there is Mathemagics

Solving linear equations in Fortran 95

I'm newbie in programming and at the moment I'm working on a project that I need to use Fortran 95. Is there any subroutine for solving linear equation, for example finding matrix x in the A*x=b where A is a 2*2 matrix.
I would appreciate if you give me any useful link that help me to solve this problem.
thank for your help
For 2x2 system of equations you should code the Cramer's rule, since the expression of det(A) is fairly simple (also for 3x3).
https://en.wikipedia.org/wiki/Cramer%27s_rule
There are many libraries you can use. A de facto standard is the LAPACK package with more algorithms you can choose. There are many free and commercial implementations of the same subroutines, for example, OpenBLAS, Intel MKL or Sun Performance Library.
If your system is very large, you would look for some iterative solver. There are many of them, just search for GMRES, BiCGSTAB or similar methods and their implementations (for example, http://people.sc.fsu.edu/~%20jburkardt/f_src/templates/templates.html).

Iterative Solver Library in Fortran

I wrote a code which solves large systems of PDEs using some discretization methods which basically involves solving large, sparse systems Ax=b many times at each time steps.
I currently use the PARDISO solver (from the intel MKL library) which is a direct LU factorization of A to solve the system. I would like to compare this method with the use of iterative solvers (which, with the use of preconditioners, might perform better since I could use the same preconditioner over many time steps if my Jacobian matrix does not vary too much).
My question is then, what library do you suggest for sparse iterative solvers in fortran ? I found one (SLATEC) which was written in 1993 so I wonder if there is something more performant which was written more recently ?
Thanks :)
I would also add:
LIS
AGMG
Oh, well ... the complete list of Linear Algebra Solvers
Thanks for the comments, PETSc seems to be exactly what I was looking for, just need to learn how to link C calls into fortran now :)

How to choose an integer linear programming solver?

I am newbie for integer linear programming.
I plan to use a integer linear programming solver to solve my combinatorial optimization problem.
I am more familiar with C++/object oriented programming on an IDE.
Now I am using NetBeans with Cygwin to write my applications most of time.
May I ask if there is an easy use ILP solver for me?
Or it depends on the problem I want to solve ? I am trying to do some resources mapping optimization. Please let me know if any further information is required.
Thank you very much, Cassie.
If what you want is linear mixed integer programming, then I would point to Coin-OR (and specifically to the module CBC). It's Free software (as speech)
You can either use it with a specific language, or use C++.
Use C++ if you data requires lots of preprocessing, or if you want to put your hands into the solver (choosing pivot points, column generation, adding cuts and so on...).
Use the integrated language if you want to use the solver as a black box (you're just interested in the result and the problem is easy or classic enough to be solved without tweaking).
But in the tags you mention genetic algorithms and graphs algorithms. Maybe you should start by better defing your problem...
For graphs I like a lot Boost::Graph
I have used lp_solve ( http://lpsolve.sourceforge.net/5.5/ ) on a couple of occasions with success. It is mature, feature rich and is extremely well documented with lots of good advice if your linear programming skills are rusty. The integer linear programming is not a just an add on but is strongly emphasized with this package.
Just noticed that you say you are a 'newbie' at this. Well, then I strongly recommend this package since the documentation is full of examples and gentle tutorials. Other packages I have tried tend to assume a lot of the user.
For large problems, you might look at AMPL, which is an optimization interpreter with many backend solvers available. It runs as a separate process; C++ would be used to write out the input data.
Then you could try various state-of-the-art solvers.
Look into GLPK. Comes with a few examples, and works with a subset of AMPL, although IMHO works best when you stick to C/C++ for model setup. Copes with pretty big models too.
Linear Programming from Wikipedia covers a few different algorithms that you could do some digging into to see which may work best for you. Does that help or were you wanting something more specific?

Equation Solvers for linear mathematical equations

I need to solve a few mathematical equations in my application. Here's a typical example of such an equation:
a + b * c - d / e = a
Additional rules:
b % 10 = 0
b >= 0
b <= 100
Each number must be integer
...
I would like to get the possible solution sets for a, b, c, d and e.
Are there any libraries out there, either open source or commercial, which I can use to solve such an equation? If yes, what kind of result do they provide?
Solving linear systems can generally be solved using linear programming. I'd recommend taking a look at Boost uBLAS for starters - it has a simple triangular solver. Then you might checkout libraries targeting more domain specific approaches, perhaps QSopt.
You're venturing into the world of numerical analysis, and here be dragons. Seemingly small differences in specification can make a huge difference in what is the right approach.
I hesitate to make specific suggestions without a fairly precise description of the problem domain. It sounds superficiall like you are solving constrained linear problems that are simple enough that there are a lot of ways to do it but "..." could be a problem.
A good resource for general solvers etc. would be GAMS. Much of the software there may be a bit heavy weight for what you are asking.
You want a computer algebra system.
See https://stackoverflow.com/questions/160911/symbolic-math-lib, the answers to which are mostly as relevant to c++ as to c.
I know it is not your real question, but you can simplify the given equation to:
d = b * c * e with e != 0
Pretty sure Numerical Recipes will have something
You're looking for a computer algebra system, and that's not a trivial thing.
Lot's of them are available, though, try this list at Wikipedia:
http://en.wikipedia.org/wiki/Comparison_of_computer_algebra_systems
-Adam
This looks like linear programming. Does this list help?
In addition to the other posts. Your constraint sets make this reminiscent of an integer programming problem, so you might want to check that kind of thing out as well. Perhaps your problem can be (re-)stated as one.
You must know, however that the integer programming problems tends to be one of the harder computational problems so you might end up using many clock cycles to crack it.
Looking only at the "additional rules" part it does look like linear programming, in which case LINDO or a similar program implementing the simplex algorithm should be fine.
However, if the first equation is really typical it shows yours is NOT a linear algebra problem - no 2 variables multiplying or dividing each other should appear on a linear equation!
So I'd say you definitely need either a computer algebra system or solve the problem using a genetic algorithm.
Since you have restrictions similar to those found in linear programming though you're not quite there, if you just want a solution to your specific problem I'd say pick up any of the libraries mentioned at the end of Wikipedia's article on genetic algorithms and develop an app to give you the result. If you want a more generalist approach, then you've got to simulate algebraic manipulations on your computer, no other way around.
The TI-89 Calculator has a 'solver' application.
It was built to solve problems like the one in your example.
I know its not a library. But there are several TI-89 emulators out there.