# Welcome to Rehearse, algebraic modeling library in C++

## Introduction

Rehearse is a C++ library designed to describe linear optimization problems programmatically.

You can describe linear objectives and constraints using native C++ algebraic expressions, in a similar way you write a mathematical model on a paper.

### Usage :

First declare your variables :

```CelNumVar x1;
CelNumVar x2;
```

That's it! Now you are ready to use them in algebraic expressions.

For example, to set the objective :

model.setObjective ( 7 * x1 + 9 * x2 );

and to add constraints :

```   model.addConstraint(       1 * x1 +     x2 == 18  );
model.addConstraint(                    x2 <= 14  );
model.addConstraint(       2 * x1 + 3 * x2 <= 50  );

```

Then the solver will try to find values for x1 and x2 which give the biggest value for 7*x1 + 9*x2, subject to constraints we described.

The complete example:

```   void exemple1(){
OsiClpSolverInterface solver;
CelModel model(solver);

CelNumVar x1;
CelNumVar x2;

model.setObjective (       7 * x1 + 9 * x2 );

model.addConstraint(       1 * x1 +     x2 == 18  );
model.addConstraint(                    x2 <= 14  );
model.addConstraint(       2 * x1 + 3 * x2 <= 50  );

solver.setObjSense(-1.0);
model.builderToSolver();
solver.setLogLevel(0);
solver.initialSolve();

printf("Solution for x1 : %g\n", model.getSolutionValue(x1));
printf("Solution for x2 : %g\n", model.getSolutionValue(x2));
printf("Solution objective value = : %g\n", solver.getObjValue());

}
```

## Getting started

You can obtain Rehearse source code from github.

The following commands may be used to obtain and build Rehearse from the source code using git:

1. git clone https://github.com/coin-or/Rehearse.git coin-Rehearse
2. cd coin-Rehearse
4. ./configure
5. make
6. make test
7. make install

## Mailing list

To join the Rehearse mailing list, register at

To send a mail to the list use rehearse@…

## Reporting a bug

You can use the Rehearse-ticket mailing list to report a bug or suggest a new feature :

or create a new ticket directly by following this link

## Documentation

Last modified on May 4, 2015 4:31:21 PM