2024 Volume 41 Issue 2 Pages 2_80-2_95
The opportunities for writing mathematical optimization programs have become much wider in recent years through competitive programming contests. Despite this, frequently-used algorithmic frameworks, i.e., metaheuristics, such as simulated annealing and beam search are not well abstracted by focusing on common features. As a result, the programmer is often forced to write similar programs from scratch. In addition, the programmer has to write complex code, which could be generated automatically, for the computation of the difference in evaluation values. To solve these problems, we have designed and developed a domain-specific language (DSL) that abstracts several typical metaheuristics appropriately and converts the DSL code into C++. The DSL enables the programmer to write efficient mathematical optimization programs in a minimal amount of code. After explaining the design and programming method of the DSL. this paper compares the case written in C++ and the case written in the DSL from the viewpoint of the number of lines required to describe given contents and execution times, and demonstrates the effectiveness of the DSL. Furthermore, we discuss the problems with the current DSL and future extensions for practical use.