Coverage for moptipyapps / spoc / spoc_4 / challenge_1 / beginner / base_obj.py: 92%

13 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-03 04:37 +0000

1"""A base object with stuff for handling the beginner problem.""" 

2 

3from typing import Final 

4 

5import numpy as np 

6from pycommons.types import type_error 

7 

8from moptipyapps.spoc.spoc_4.challenge_1.beginner.instance import Instance 

9 

10 

11class BaseObjectWithArrays: 

12 """The objective function of the beginner problem.""" 

13 

14 def __init__(self, instance: Instance) -> None: 

15 """ 

16 Create the objective function of the beginner problem. 

17 

18 :param instance: the instance of the objective function. 

19 """ 

20 super().__init__() 

21 if not isinstance(instance, Instance): 

22 raise type_error(instance, "instance", Instance) 

23 #: the instance 

24 self.instance: Final[Instance] = instance 

25 

26 #: the earth orbit usage 

27 self.earth = np.ndarray(instance.lengths[0], dtype=np.bool) 

28 #: the lunar orbit usage 

29 self.lunar = np.ndarray(instance.lengths[1], dtype=np.bool) 

30 #: the destination orbit usage 

31 self.dest = np.ndarray(instance.lengths[2], dtype=np.bool)