Mopta08 Executables

Since the links on Miguel Anjos’ website seem to be dead, I thought I’d post the executables for the MOPTA08 competition here.

Link to Fortran source code and description:
MOPTA2008 Benchmark Data

They are binaries for Linux, and they are compiled for i386, x86_64, and ARM.

Here is also the accompanying presentation from the conference: mopta08_jones.pdf

Example call in Python:

import os
import subprocess
import sys
import tempfile
from pathlib import Path
from platform import machine

import numpy as np

if __name__ == '__main__':
	sysarch = 64 if sys.maxsize > 2 ** 32 else 32
	machine = machine().lower()

	if machine == "armv7l":
		assert sysarch == 32, "Not supported"
		mopta_exectutable = "mopta08_armhf.bin"
	elif machine == "x86_64":
		assert sysarch == 64, "Not supported"
		mopta_exectutable = "mopta08_elf64.bin"
	elif machine == "i386":
		assert sysarch == 32, "Not supported"
		mopta_exectutable = "mopta08_elf32.bin"
	else:
		raise RuntimeError("Machine with this architecture is not supported")

	mopta_full_path = os.path.join(
		Path(__file__).parent, "mopta08", mopta_exectutable
	)

	directory_file_descriptor = tempfile.TemporaryDirectory()
	directory_name = directory_file_descriptor.name

	x = np.random.rand(124)
	with open(os.path.join(directory_name, "input.txt"), "w+") as tmp_file:
		for _x in x:
			tmp_file.write(f"{_x}\n")
	popen = subprocess.Popen(
		mopta_full_path,
		stdout=subprocess.PIPE,
		cwd=directory_name,
	)
	popen.wait()
	output = (
		open(os.path.join(directory_name, "output.txt"), "r")
		.read()
		.split("\n")
	)
	output = [x.strip() for x in output]
	output = np.array([float(x) for x in output if len(x) > 0])
	value = output[0]
	constraints = output[1:]
	print(value, constraints)

value is the function value. If all constraints are ≤0\leq 0, they are satisfied and the solution is feasible.


The code is copyright Miguel Anjos and is provided under the Creative Commons License: Attribution 4.0 International license.