Here at our institute, we work on a couple of (larger scale) economics related GAMS models. Different teams, involved in different projects make adaptations to the models in order to answer their specific research questions. The models are equipped with a Graphical User Interface (GUI), and are version controlled through SVN. The general idea is that the SVN master branch depicts the most recent, stable model version, which should be capable of running all possible GUI settings (and their combinations), or should be returning appropriate abort statements if the selected combinations are deemed logically infeasible (e.g. growing Oranges without any Orange trees).
The problem
Imagine a team focuses on a specific problem, e.g. the production of Oranges. As they improve details on the production process of Oranges, e.g. required machinery, labor need, etc., they now want to commit their changes into the master SVN branch, as their additions improve the overall state and abilities of the model.
However, due to the structure of the model, the production of Oranges is not separated (and should not be) from the rest of the operation, and has implications on other parts of the model as well. With the way their changes were implemented, now imagine that the production of Apples has become mathematical infeasible (which it should not be).
Now with the (erroneous) changes committed, the research team involved in Apple production faces an infeasible model, and in order to correct the bug introduced by the other team, has to first go through the changes made by the other team, understand them, come up with a fix, and eventually commit to the master branch once again.
After this final commit, the production of Bananas is not working anymore… I guess everyone get’s the idea
Tests to the rescue - Our current solution
In order to prevent such a scenario, each team defines a set of GUI settings which needs to work for their current project in a so called batch file. This batch file is a textual representation of the settings selected in the GUI. Before every commit, each team is supposed to run the model with their local modifications with the batch file settings of every team. The model outcome for the past revisions are stored on a server, where selected variables levels for each model run and revision are stored.
Especially with an economic model, this is a tedious task. Commits often bring updates in policies or input/output prices, which are expected to change the model results. However, judging whether the new results are “correct” due to the introduced changes or the deviations being “too far” from their past level (indicating a bug) often requires hours of manual checking. This is obviously not a popular task, and quickly facilitates the “this change is so minimal, I don’t need to run the tests” mindsets, after time leading again to the problem(s) initially described.
Best practices
I strongly believe that we are not the only group facing this (methodological) issue. Tests are a significant part of software engineering in general, though I have the feeling that with mathematical programming models, the overall procedure on how tests can be conducted is/should be different.
That’s why my actual question is: How do you (fellow modelers) resolve this issue? What are best practices that you implement in your projects/teams that facilitate writing clean, well tested code? Are there methods that have been proven to work well?