Quantitative Finance Stack Exchange is a question and answer site for finance professionals and academics. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am at the moment writing a program focusing on asset allocation and I am thinking about how I should represent my constraints in the data model.

The first approach that came to mind was to define some categories to classify the constraints so that they could be stored in a table according to their "category" (for example, unary constraints x>=y, binary constraints y

I then came up with another idea which is to define my own "constraint language" with its own grammar and to store it as a string in the database (like Sum("Equities")<Percent(20,Portfolio)). This would imply writing a parser. I could also opt to use an XML representation of the constraints to use one of the many XML parsers.

I wanted to know if anyone had another potential solution and if you knew about some papers discussing this subject?

share|improve this question
What kind of restrictions are you talking about? For the linear restrictions you mention a matrix is the way to go. – Bob Jansen Jul 5 '11 at 17:45
yeah they're not all linear – SRKX Jul 7 '11 at 7:04
up vote 4 down vote accepted

A lot of people use mathematical modelling languages/formats like the proprietary AMPL (see http://en.wikipedia.org/wiki/AMPL) or MPS (see http://en.wikipedia.org/wiki/MPS_%28format%29) to define optimization problems. There are also open source alternatives for a subset of problems (like for example the GNU Linear Programming Kit with its language).

Hans Mittelmann has collected a lot of useful information including test cases under http://plato.asu.edu/guide.html. However, using an optimizer that understands for example AMPL may be not the best approach.

share|improve this answer

This seems like it would be well-suited for implementation in a Prolog. That family of languages is built around a constraint programming model. Specifically, take a look at ECLiPSe. It's mature (originally developed in the 90's by Cisco I believe) and has external hooks to e.g. Java & C++ if you don't want to implement your whole system in prolog.

Prologs are well suited for scheduling and distribution problems: distribute this sum of time/money/points in some way that satisfies this other list of constraints.

It's worth pointing out that the constraints are declarative, so you can just add new constraints or remove old constraints and rerun the program to get new results without having to re-build or re-compile any of the core code.

share|improve this answer
Actually I'm not really looking at a software to solve the problem, just a model to be able to store the constraints in a DB – SRKX Jul 7 '11 at 7:02
Understand. Still, a model like you proposed in the OP needs to be interpreted when it comes out of the DB so you do have to account for the logic representation. – Greg Jul 7 '11 at 20:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.