Fork me on GitHub

oj! Algorithms

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

2017-07-21: New wiki page about sparse data structures

2017-06-19: Downloading from Yahoo Finance fixed

About a month ago Yahoo deliberately broke downloading historical data from their web site. This was not a problem with ojAlgo – it broke for everyone. ojAlgo has now adapted to Yahoo's new method. The new code in the master branch of the repository at GitHub, and will of course be part the next release.

2017-04-22: Released ojAlgo v43

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

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

Download oj! Algorithms

As of v38 ojAlgo requires Java 8.

Java 7 users should instead use ojAlgo v37.1.1

2017-02-03: Stopped using the CVS repository at SourceForge

With the v42 release the CVS repository at SourceForge will be abandoned. From now on the source code will be maintained at GitHub only.

2017-02-03: Released ojAlgo v42

2015-07-20: New Java Matrix Benchmark results

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...

2015-05-15: Now at The Central (Maven) Repository

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 independent effort.) The intention is that all future releases will be available at The Central Repository.

What's in ojAlgo?

  1. 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 independent benchmark (not written by anyone associated with ojAlgo).
  2. Optimisation (mathematical programming) tools including LP, QP and MIP solvers – again this is pure Java with zero dependencies.

The feature set is extensive...

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

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:

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 performance linear package. It supports three element types:

and includes all the most common matrix decompositions:

Copyright and License

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. 

OSI certified

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

 * Copyright © 2015 Optimatika (
 * 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.

Is it documented?

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.

Design concepts

Mathematical Programming

"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

"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":

What's in CVS

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

Which Java version?

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 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.

Support & Services


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:

  1. You have to be a member to be able to post to the list - anyone can sign up.
  2. All new members are moderated until the administrator decides to trust them (usually with their first post).
  3. 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.

  1. Optimatika offers commercial support for ojAlgo.
  2. Optimatika accepts commissions to extend ojAlgo.
  3. 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 Edge Financial Systems

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. Logo

Project and site sponsored by Optimatika
Copyright © 2000 - 2015


Using JProfiler from ej-technologies