moptipyapps.spoc package

Tools for the ESA SPOC challenges.

The European Space Agency (ESA) regularly holds its Space Optimisation Competition (SpOC), e.g., at the Genetic and Evolutionary Computation Conference (GECCO, see, e.g. <https://gecco-2026.sigevo.org/Competitions>).

The website of the challenge is <https://optimise.esa.int>. Here we provide tools for this challenge.

All data contained in here is taken from <https://github.com/esa/SpOC4>, which is also under the GPL-3 License. The copyright belongs to the authors of this data.

Subpackages

Submodules

moptipyapps.spoc.submission module

Create submission data for the SPOC challenge.

>>> from moptipy.spaces.permutations import Permutations
>>> perms = Permutations((0, 1, 2, 3))
>>> submit = SubmissionSpace(perms, "The Challenge", "The Problem")
>>> submit.initialize()
>>> the_x = submit.create()
>>> the_x[:] = perms.blueprint[:]
>>> the_str = submit.to_str(the_x)
>>> print(the_str)
0;1;2;3

----------- SUBMISSION -----------

[
      {
            "challenge": "The Challenge",
            "problem": "The Problem",
            "decisionVector": [
                  0,
                  1,
                  2,
                  3
            ]
      }
]
>>> the_x2 = submit.from_str(the_str)
>>> submit.is_equal(the_x, the_x2)
True
class moptipyapps.spoc.submission.SubmissionSpace(space, challenge_id, problem_id)[source]

Bases: Space

A space that also provides the submission data.

This space is designed to wrap around an existing space type and to generate the SPOC submission text when textifying space elements.

challenge_id: Final[str]

the challenge ID

from_str(text)[source]

Transform a string text to one element of the space.

Parameters:

text (str) – the input string

Return type:

Any

Returns:

the element in the space corresponding to text

log_parameters_to(logger)[source]

Log the parameters to a logger.

Parameters:

logger (KeyValueLogSection) – the logger

Return type:

None

problem_id: Final[str]

the problem ID

space: Final[Space]

the internal space copy

to_str(x)[source]

Obtain a textual representation of an instance of the data structure.

Parameters:

x – the instance

Return type:

str

Returns:

the string representation of x

moptipyapps.spoc.submission.to_submission(challenge_id, problem_id, x)[source]

Create a submission file text.

This function follows the specification given in <https://api.optimize.esa.int/data/tools/submission_helper.py>, with the exception that it tries to convert floating points to integers, where possible without loss of precision.

Parameters:
  • challenge_id (str) – a string of the challenge identifier (found on the corresponding problem page)

  • problem_id (str) – a string of the problem identifier (found on the corresponding problem page)

  • x (Any) – the result data

Return type:

str

>>> print(to_submission("a", "b", (1, 2, 3)))
[
      {
            "challenge": "a",
            "problem": "b",
            "decisionVector": [
                  1,
                  2,
                  3
            ]
      }
]
>>> print(to_submission("a", "b", np.array(((1, 2, 3), (0.2, 4, 4.3)))))
[
      {
            "challenge": "a",
            "problem": "b",
            "decisionVector": [
                  [
                        1,
                        2,
                        3
                  ],
                  [
                        0.2,
                        4,
                        4.3
                  ]
            ]
      }
]