Fork me on GitHub

oj! Algorithms

oj! Algorithms - ojAlgo - is Open Source Java code that has to do with mathematics, linear algebra and optimisation; particularly (but certainly not exclusively) suitable for the financial domain.

2014-10-10: Released v37

This is the last release to targets Java 7. There's no real new features or specific bug fixes from v36 - just some improvements. Development will switch to target Java 8 from now on.

Download the latest prebuilt version of ojAlgo from SourceForge, or fork the source code at GitHub.

Download Latest Version

For an outline of recent changes there is a change log covering the latest 10 releases.

2014-07-30: New Java Matrix Benchmark results

What is it?

ojAlgo is Open Source Java code that has to do with mathematics, linear algebra and optimisation. ojAlgo really is 100% pure Java source code. There are no calls to native (C or Fortran) libraries. In fact there are no dependencies at all. Nothing besides a Java SDK is needed to compile or execute the code. Its feature set make it particularly suitable for use within the financial domain. Then again, it's just maths...   More...

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

Where can I get it?

You get ojAlgo from SourceForge; either as a compiled and packaged download, or as source code directly from CVSMore...

Is it documented?

Well... There is this web site, the JavaDoc. and a couple of wiki pages over at Google Code. 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.  More...

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

ojAlgo is Open Source Java code that has to do with mathematics, linear algebra and optimisation. ojAlgo really is 100% pure Java source code. There are no calls to native (C or Fortran) libraries. In fact there are no dependencies at all. Nothing besides a Java SDK is needed to compile or execute the code. Its feature set make it particularly suitable for use within the financial domain. Then again, it's just maths...   

Main ingredients

Presumably there are three main reasons why users/developers become interested in ojAlgo:

  1. Linear Algebra in Java - ojAlgo is a "high performance" multi-threaded feature-complete linear algebra package.
  2. Optimisation (mathematical programming) including LP, QP and MIP solvers.
  3. Finance related code (certainly usable in other areas as well):

Design concepts

License agreement

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

Linear Algebra

ojAlgo is a "high performance" multi-threaded feature-complete linear algebra package. It sports two implementation layers; BasicMatrix (higher/application level interface) and MatrixStore/PhysicalStore (lower/algorithm level interface) and supports three element types: double, BigDecimal and ComplexNumber. Further ojAlgo incorporates an unmodified copy/version of JAMA (implementing both the BasicMatrix and PhysicalStore interfaces).

 
double
BigDecimal

The table below shows that ojAlgo contains the most common matrix decompositions, and that most of them are also available for BigDecimal and ComplexNumber elements.

 
double
BigDecimal
Y
Y
Y
Y
Y
Y
Eigenvalue (symmetric/hermitian)
Y
Y
Y
Eigenvalue (general)
Y
N
N
Y
Y
Y
Y
Y
Y
Y
Y
Y
Y
N
N
Y
Y
Y
Y
Y
Y

High Performance

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

riskglossary.com

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

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. 

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

/*
 * Copyright © 2007 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.
 */

Where can I get it?

You get ojAlgo from SourceForge; either as a compiled and packaged download, or as source code directly from CVSMore...

Download ojAlgo

You get ojAlgo from SourceForge; either as a compiled and packaged download, or as source code directly from CVS. There is no schedule for when code changes or new releases are made. If you work directly from CVS you must be aware that the code may change, back and forth, at any time. It will however, 99% of the time, compile and run without any problem.

Download the latest prebuilt version of ojAlgo from SourceForge, or fork the source code at GitHub.

Download Latest Version

For an outline of recent changes there is a change log covering the latest 10 releases.

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.

GitHub

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.

eclipse

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

Documentation

There is this web site, the JavaDoc. and a couple of wiki pages over at Google Code. 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.

At Google Code there's some "getting started" docs. Start by reading the Getting Started Linear Algebra and/or Getting Started Optimisation wiki pages.

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

Support

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.

Services

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. In addition to that there is a facebook page as well as a a twitter channel.

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 Edge facebook facebook

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

Change Log

Do NOT use anything deprecated - it will be removed very soon! Most of what was deprecated at the time of the last release has already been removed. Removing something that was already deprecated is not mentioned in the change log. If you're lagging behind and need to update over several versions it is recommended that you upgrade incrementally to each intermediate version (and finally to the latest snapshot).

About the version numbers: You should not think of a ".1" version as v66 with only a small number of minor changes. v66.1 is probably already closer to v67 than it is to v66.

All versions ever released have a tag/version in CVS
Release Version CVS tag/version
1 jar_1_0
2 jar_2
3 - 31 Version3, Version4, Version5 ... Version31
32 - v32, v33, v34...

v38 (not yet released; corresponds to the latest snapshot)

The first version to require Java 8!

v37 (latest release)

Last version to not require Java 8! (Targets Java 7) No real new features compared to v36.

v36

v35

Apart from this a significant amount of time has been spent improving the unit tests.

v34

First version to target Java 7!

v33

Last version to target Java 5!

v32

v31

v30

v29

v28


SourceForge.net Logo

Project and site sponsored by Optimatika
Copyright © 2000 - 2014

Google+

Using JProfiler from ej-technologies