Write Your Model

If you want to write your own model, you are free to modify the OSDEA Library. This page shows the key areas of the library to edit in order to add your own model. Because OSDEA is still a failry young library and project, please consider sharing your modifications if you can! You can find details on how to contact us on the About Page.

Code Changes

In order to code your own DEA model with OSDEA, you should follow the process detailed below. The example illustrates what could be added to the SBM model to write the SBM-GRS Model (Slack Based Model under General Return to Scale). All models extend the Model class. In order for the model to work, you will need to override the createAndSolve() method.

Add the new model to the dea package in the ModelType.java enum. Following the example above, you will need to add the corresponding parameters (type of efficiency, model description…) as follows:

  SBMGRS ("The Non-Oriented version of the SBM model assuming General RTS." +
      "This model requires a set of two parameters Lower Limit and Upper Limit.",
      DEAModelOrientation.NonOriented,
      DEAEfficiencyType.MIX,
      DEAReturnToScale.General);

Create a new Model Class in the deaModels package or modify an existing class (The only changes necessary to the SBM class consisted in adding the code corresponding to the two extra rows for the GRS constraints in the SBM class):

  /*Under the createAndSolve method:*/
  else { /*if (deaP.getModelType() == DEAModelType.SBMGRS)*/
    RHS = new double [NbVariables + 3]; //dim the right hand side vector
    SolverEqualityType = new int [NbVariables + 3]; //dim the vector holding the type of equalities (equal, lower than, greater than etc...)
  }
 
  /*Under the createModel method*/
  if(deaP.getModelType() == DEAModelType.SBMGRS) {
    double[] TempConstraintRow = new double[NbDMUs + NbVariables + 1];
    for (int k = 1; k <= NbDMUs; k++) {
      TempConstraintRow[k] = -1;
    }
    //Lower Bounds (General RTS)
    double[] ConstraintRow = new double[NbDMUs + NbVariables + 1];
    System.arraycopy(TempConstraintRow, 1, ConstraintRow, 1, NbDMUs);
    ConstraintRow[0] = deaP.getRTSLowerBound();
    Constraints.add(ConstraintRow);
    RHS[NbVariables + 1] = 0;
    SolverEqualityType[NbVariables + 1] = LpSolve.LE;
 
    //Upper Bounds (General RTS)
    ConstraintRow = new double[NbDMUs + NbVariables + 1];
    System.arraycopy(TempConstraintRow, 1, ConstraintRow, 1, NbDMUs);
    ConstraintRow[0] = deaP.getRTSUpperBound();
    Constraints.add(ConstraintRow);
    RHS[NbVariables + 2] = 0;
    SolverEqualityType[NbVariables + 2] = LpSolve.GE;
  }

Because the SBM class inherits its solve() method from the Model class, this is all what needed to create the GRS version of the SBM model. If you are creating a new model, your own model class should extend the Model class. In most situations, you should be able to use the inherited solve() method although in rare cases this is not ideal. For example, it is not a good idea to call the createAndSolve() method at each evaluation for the SBM Output oriented model as the constraints array created is the same for all the optimisations. This is why the SBM_O class overrides the solve() method.
Optional: you might also want to add the appropriate tests in the tests package. To do so, you can easily copy and paste an existing test class.

These modifications do not generally take very long. If you are familiar with the code and with your DEA model and if your model only requires small changes to an existing model, writing your own model should only take you between 30 minutes to an hour. If you can, don’t forget to share your modifications!.