oj! Algorithms – ojAlgo – is Open Source Java code to do mathematics, linear algebra and optimisation.

High Performance on a Rich Feature Set with Zero Dependencies

Highlights/changes since v38:

- Significant performance improvements to (all) matrix decompositions for small and medium sized matrices.
- Extensive set of tweaks and improvements to the optimisation package. In particular:
- Huge amount of refactoring resulting in more than the usual amount of deprecations and api-breaking changes.

The changelog, covering the latest 10 releases, will give more details on what's new.

Download the latest prebuilt version of ojAlgo from SourceForge, fork the source code at GitHub or add the dependency from The Central Repository with your favourite build tool.

As of v38.0 ojAlgo requires Java 8.

Java 7 users should instead use ojAlgo v37.1.1

The author of EJML benchmark his library against several other libraries – ojAlgo is one of them. To do that he created the Java Matrix Benchmark. Executing that benchmark takes about 2 weeks. It doesn't get executed very often! It is almost 2 years since the Java Matrix Benchmark site last published any results. Now, finally the wait is over...

ojAlgo is now available at The Central Repository to be used with your favourite dependency management tool. v38.0, that was released today, is the first official Maven release. The versions currently existing as downloads from SourceForge will also be made available. (Previously v31.0 existed by a third party independant effort.) The intention is that all future releases will be available at The Central Repository.

- ojAlgo is the fastest pure Java linear algebra library available. That statement is backed by the latest Java Matrix Benchmark results - that's a third party independant benchmark (not written by anyone associated with ojAlgo).
- Optimisation (mathematical programming) tools including LP, QP and MIP solvers – again this is pure Java with zero dependecies.

The feature set is extensive...

Much of the development has been motivated by various financial applications. ojAlgo contains code that allow you to:

- Download historical data from Yahoo Finance or Google Finance
- Patch, transform and analyse time series data
- Construct/optimise portfolios
- Generate future market scenarios
- Simulate the behaviour of portfolios

Everything necessary to do that is in ojAlgo itself – it has zero dependencies.

The portfolio optimisation functionality is backed by a set of mathematical programming tools:

- Full featured general purpose modelling tool
- Linear program (LP) solver
- Collection of quadratic/convex (QP) solvers
- Mixed Integer Program (MIP) solver

When using the mathematical programming models and solvers there is nothing "financial" about them – they're simply optimisation tools equally useful to any domain. To build the various solvers wouldn't be possible without a full featured linear algebra package. ojAlgo is a full featured high performace linear package. It supports three element types:

- double
- BigDecimal
- ComplexNumber

and includes all the most common matrix decompositions:

ojAlgo is an Open Source project. It is available as source code, and every single source code file contain a copyright statement and a license agreement. All files have the same copyright and license. Optimatika holds the copyright, and the license used is the generous and easy to understand MIT license. Please read and comply with the license agreement – it's not hard.

Typically the top of every java source code file looks like this:

/*

* Copyright © 2015 Optimatika (www.optimatika.se)

*

* Permission is hereby granted, free of charge,
to any person obtaining a copy

* of this software and associated documentation files (the "Software"), to deal

*
in the Software without restriction, including without limitation the rights

* to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell

* copies of the Software, and to permit persons to whom the Software is

* furnished to do so,
subject to the following conditions:

*

* The above copyright notice and this permission notice shall be included in

* all copies or substantial portions of the Software.

*

* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT
WARRANTY OF ANY KIND, EXPRESS OR

* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

* FITNESS FOR
A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER

* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

* OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

* SOFTWARE.

*/

Well... There is this web site, the JavaDoc. and a growing number of wiki pages. More will follow, but the JavaDoc (and source code) will always be the main source of documentation. Improving the documentation will mainly be improving the JavaDoc.

For bug reports, questions or discussions related to ojAlgo; please use the ojAlgo-user mailing list.

- Code for the JVM: There are no calls to native (C or Fortran) libraries.
- No dependencies: NOTHING besides a JDK is needed to compile or execute the code. In fact ojAlgo only requires the Compact Profile compact1.
- "Conventional" Java: Names of attributes and methods are chosen to comply with Java standards rather than legacy mathematics code (Fortran, C, Matlab...) conventions.
- Write code that scales: When choosing algorithms and data structures ojAlgo often favours designs that perform well on larger more complex cases, even if it's more than what's currently required.
- Anything and everything may change in the future (breaking API compatibility). Part of the code is "in production" in commercial systems – but will be changed if improvements require it. Interfaces are less likely to change than implementations. Versions are frequently tagged in CVS/Git.

*"In a mathematical programming (or optimisation) problem, one seeks to minimize or maximize a real function of real or integer
variables, subject to constraints on the variables. The term mathematical programming refers to the study of these problems: their mathematical
properties, the development and implementation of algorithms to solve these problems, and the application of these algorithms to real world
problems. Note in particular the word "programming" does not specifically refer to computer programming. In fact, the term
"mathematical programming" was coined before the word "programming" became closely associated with computer software. This
confusion is sometimes avoided by using the term optimisation as an approximate synonym for mathematical programming."*

Mathematical Optimisation Society

ojAlgo contains LP (Linear Programming), QP (Quadratic Programming) and MIP (Mixed Integer Programming) solvers:

There's also a simple framework to model problems using standardised expressions as well as the ability to read MPS (Mathematical Programming System) files.

The ojAlgo LP/QP/MIP solvers are designed for when you need a pure Java solver for a smaller/simpler problem. Today the best commercial solvers (typically not written i Java) are very capable. ojAlgo can not compete with them. On the other hand, in many cases, a commercial solver is total overkill. There's a huge set of use cases where something like ojAlgo is a better choice.

The ojAlgo solvers have been around for years - particularly the QP solver. It dates back to the very beginning of ojAlgo 10 years ago. ojAlgo is extensively tested. Among the current test cases the only thing that doesn't work is semi continuous variables in MPS files/models. (This feature simply isn't supported at the moment.)

The Mixed Integer Problem Library (MIPLIB) maintains a collection of reference MIP problems. Among these a problem is considered "easy" if a commercial solver can solve it in less than 1 hour, and some problems are not yet solved by any solver. ojAlgo can solve several cases from that collection, but it typically takes longer than 1 hour. If you need to solve problems of this caliber you probably should get one the commercial solvers, but in many other cases ojAlgo will do just fine.

*"Modern portfolio theory (MPT)—or portfolio theory—was introduced by Harry Markowitz with his paper "Portfolio Selection,"
which appeared in the 1952 Journal of Finance. Thirty-eight years later, he shared a Nobel Prize with Merton Miller and William Sharpe for what
has become a broad theory for portfolio selection.*

*Prior to Markowitz's work, investors focused on assessing the risks and rewards of individual securities in constructing their portfolios.
Standard investment advice was to identify those securities that offered the best opportunities for gain with the least risk and then construct
a portfolio from these. Following this advice, an investor might conclude that railroad stocks all offered good risk-reward characteristics and
compile a portfolio entirely from these. Intuitively, this would be foolish. Markowitz formalized this intuition. Detailing a mathematics of
diversification, he proposed that investors focus on selecting portfolios based on their overall risk-reward characteristics instead of merely
compiling portfolios from securities that each individually have attractive risk-reward characteristics. In a nutshell, inventors should select
portfolios not individual securities."*

ojAlgo contains a collection of portfolio selection models, notably:

The classes in the FinancePortfolio hierarchy/package are designed to complement each other to, as a whole, offer extensive and flexible portfolio selection features.

In addition ojAlgo supports other things useful with "finance":

- Download historical financial data from Yahoo and Google. (Before using this code, or the data you download using it, you should check if your intentions comply with Yahoo's and Google's "terms of use".)
- Extensive set of tools to work with time series; CalendarDateSeries, CoordinationSet, PrimitiveSeries...
- RandomNumber implementions for a collection of Distributions, as well as stochastic processes (1- or multidimensional). The PortfolioSimulator allows you to project portfolio growth using multi-dimensional geometric Brownian motion with (optional) periodic rebalancing.

There are currently 8 modules in CVS, but perhaps only 1 is relevant to you:

**DevProj**is the ojAlgo source code module. This is it! The Java source in this module has no (as in zero) dependencies. Contents end up in ojalgo-?.?.jar. (Nothing else ends up there.)

**BizProj**depends on DevProj and contains business logic code. This is experimental and highly volatile code. Don't even consider using this code unless you plan to actively participate in its development. Contents end up in ojalgo-biz-?.?.jar. (Nothing else ends up there.)

**ExtAMPL**depends on DevProj and AMPL. Contents end up in ojalgo-ext-?.?.jar.**ExtJavaMail**depends on DevProj and JavaMail. Contents end up in ojalgo-ext-?.?.jar.**ExtJExcel**depends on DevProj and JExcelApi. Contents end up in ojalgo-ext-?.?.jar.**ExtJFree**depends on DevProj and JFreeChart. Contents end up in ojalgo-ext-?.?.jar.**ExtPriDE**depends on DevProj and PriDE. Contents end up in ojalgo-ext-?.?.jar.

**TestProj**contains unit tests. All unit tests, regardless of which module's code they test, are in this module. Contents is not part of the build/distribution.

ojAlgo currently targets Java 7. Up until v33 Java 5 was enough.

The SourceForge CVS module DevProj is mirrored at GitHub. The two source code repositories are used in parallel. It may not always be like this, but for now they're equally good. Use whichever you prefer.

Each of the CVS modules mentioned above are complete eclipse projects. Once you've set up your CVS repository location, in eclipse, all you need to do is "Check Out As..." on one of the modules (most likely DevProj). You do not need to do anything else! Required libraries (if any) are in the module/project. Some projects/modules may require you to also get one or some of the other projects/modules.

To build ojAlgo from source using the supplied ant script you need to check out all 8 cvs modules. Further the script assumes that DevProj, BizProj and TestProj are renamed ojAlgo, ModBusiness and ojAlgoTests respectively. (Actually you can name any of the 8 modules/projects anything you want. You just modify build.properties to match.)

There is this web site, the JavaDoc. and a couple of wiki pages. More will follow, but the JavaDoc (and source code) will always be the main source of documentation. Improving the documentation will mainly be improving the JavaDoc.

First of all you should look at What's in it? and its subsections Linear Algebra, Mathematical Programming and Modern Portfolio Theory.

To dig a little deeper browse the JavaDoc available at this site. Scanning through the change log and following its links to the JavaDoc might be a good way to do that.

For bug reports, questions or discussions related to ojAlgo; please use the ojAlgo-user mailing list. And remember... others have done this before you. The list archives may answer some of your questions.

For bug reports, questions or discussions related to ojAlgo; please use the ojAlgo-user mailing list.

Please use the mailing list. Do not contact Optimatika directly with bug reports, support requests, and/or academic discussions.

Regarding the list:

- You have to be a member to be able to post to the list - anyone can sign up.
- All new members are moderated until the administrator decides to trust them (usually with their first post).
- There is a searchable list archive. It's a llow volume list, but it's been around since 2003 so there is content to search and information to find.

Please also note that the source code repository is browsable online.

Optimatika is a software consulting company specialising in advanced decision support systems. The ojAlgo code base only represents a small part of what we know. We build complete systems, and work extensively with databases and application servers as well as commercially available mathematics, optimisation and decision support tools.

- Optimatika offers commercial support for ojAlgo.
- Optimatika accepts commissions to extend ojAlgo.
- Optimatika can build complete, highly complex, systems (even if they have nothing to do with ojAlgo).

In these cases please contact Optimatika directly.

No one knows the ojAlgo code base better than Optimatika!

BLaadin is a financial market simulation tool. It facilitates market analysis and forecasting as well as making portfolio recommendations. In particular it asserts consistency between forecasts and recommendations. At its core it makes use of the Black-Litterman model.

Information about BLaadin is currently maintained at the BLaadin Edge Financial Systems site.

There is a "public beta" version of BLaadin available on-line as a cloud service. The BLaadin Edge Financial Systems site contains information about how to find and use it.

BLaadin has its origin in a cooperation between Optimatika and the Royal Institute of Technology in Stockholm (KTH). That cooperation aimed to develop a prototype system/application using the Black-Litterman model, and to use that application in a behavioural finance case study. The case study resulted in a PhD thesis.

That was years ago... The prototype died and was revitalised several times until it was finally completely rewritten with a much more ambitious goal. BLaadin is now a full-fledged market simulation and portfolio construction tool.

BLaadin is programmed in Java, and everything related to mathematics and financials is in ojAlgo. BLaadin is NOT open source! ojAlgo is, but not BLaadin. The on-line "public beta" is free for you to try.

Project and site sponsored by Optimatika

Copyright © 2000 - 2015

Using JProfiler from ej-technologies