Commit 4c4c58f6 authored by Brice Videau's avatar Brice Videau
Browse files

Updated bindings. Add strict ordering to binding subclass for hashing.

parent 6220c0f6
......@@ -15,6 +15,7 @@ from .expression import *
from .expression_parser import *
from .context import *
from .configuration_space import *
from .binding import *
from .configuration import *
from .objective_space import *
from .evaluation import *
......
......@@ -25,6 +25,7 @@ ccs_hyperparameter = ccs_object
ccs_expression = ccs_object
ccs_context = ccs_object
ccs_configuration_space = ccs_object
ccs_binding = ccs_object
ccs_configuration = ccs_object
ccs_objective_space = ccs_object
ccs_evaluation = ccs_object
......@@ -216,7 +217,8 @@ class ccs_error(CEnumeration):
'SAMPLING_UNSUCCESSFUL',
'INACTIVE_HYPERPARAMETER',
'OUT_OF_MEMORY',
'UNSUPPORTED_OPERATION' ]
'UNSUPPORTED_OPERATION',
'INVALID_EVALUATION' ]
class ccs_data_type(CEnumeration):
_members_ = [
......@@ -230,7 +232,9 @@ class ccs_data_type(CEnumeration):
class ccs_datum_flag(CEnumeration):
_members_ = [
('FLAG_DEFAULT', 0) ]
('DEFAULT', 0),
('TRANSIENT', (1 << 0)),
('UNPOOLED', (1 << 1))]
ccs_datum_flags = ct.c_uint
......@@ -332,7 +336,7 @@ class ccs_datum(ct.Structure):
self.type = ccs_data_type.STRING
self._string = str.encode(v)
self._value.s = ct.c_char_p(self._string)
self.flags = 0
self.flags = ccs_datum_flag.TRANSIENT
elif v is ccs_inactive:
self.type = ccs_data_type.INACTIVE
self._value.i = 0
......@@ -341,7 +345,7 @@ class ccs_datum(ct.Structure):
self.type = ccs_data_type.OBJECT
self._object = v
self._value.o = v.handle
self.flags = 0
self.flags = ccs_datum_flag.TRANSIENT
else:
raise Error(ccs_error(ccs_error.INVALID_VALUE))
......@@ -473,5 +477,6 @@ from .hyperparameter import Hyperparameter
from .expression import Expression
from .configuration_space import ConfigurationSpace
from .configuration import Configuration
from .objective_space import ObjectiveSpace
from .evaluation import Evaluation
from .tuner import Tuner
import ctypes as ct
from .base import Object, Error, ccs_error, _ccs_get_function, ccs_context, ccs_binding, ccs_hyperparameter, ccs_datum, ccs_datum_fix, ccs_hash, ccs_int
from .hyperparameter import Hyperparameter
ccs_binding_get_context = _ccs_get_function("ccs_binding_get_context", [ccs_binding, ct.POINTER(ccs_context)])
ccs_binding_get_user_data = _ccs_get_function("ccs_binding_get_user_data", [ccs_binding, ct.POINTER(ct.c_void_p)])
ccs_binding_get_value = _ccs_get_function("ccs_binding_get_value", [ccs_binding, ct.c_size_t, ct.POINTER(ccs_datum)])
ccs_binding_set_value = _ccs_get_function("ccs_binding_set_value", [ccs_binding, ct.c_size_t, ccs_datum_fix])
ccs_binding_get_values = _ccs_get_function("ccs_binding_get_values", [ccs_binding, ct.c_size_t, ct.POINTER(ccs_datum), ct.POINTER(ct.c_size_t)])
ccs_binding_get_value_by_name = _ccs_get_function("ccs_binding_get_value_by_name", [ccs_binding, ct.c_char_p, ct.POINTER(ccs_datum)])
ccs_binding_hash = _ccs_get_function("ccs_binding_hash", [ccs_binding, ct.POINTER(ccs_hash)])
ccs_binding_cmp = _ccs_get_function("ccs_binding_cmp", [ccs_binding, ct.POINTER(ccs_int)])
class Binding(Object):
@property
def user_data(self):
if hasattr(self, "_user_data"):
return self._user_data
v = ct.c_void_p()
res = ccs_binding_get_user_data(self.handle, ct.byref(v))
Error.check(res)
self._user_data = v
return v
@property
def context(self):
if hasattr(self, "_context"):
return self._context
v = ccs_context()
res = ccs_binding_get_context(self.handle, ct.byref(v))
Error.check(res)
self._context = Object.from_handle(v)
return self._context
@property
def num_values(self):
if hasattr(self, "_num_values"):
return self._num_values
v = ct.c_size_t()
res = ccs_binding_get_values(self.handle, 0, None, ct.byref(v))
Error.check(res)
self._num_values = v.value
return self._num_values
def set_value(self, hyperparameter, value):
if isinstance(hyperparameter, Hyperparameter):
hyperparameter = self.context.hyperparameter_index(hyperparameter)
elif isinstance(hyperparameter, str):
hyperparameter = self.context.hyperparameter_index_by_name(hyperparameter)
pv = ccs_datum(value)
v = ccs_datum_fix()
v.value = pv._value.i
v.type = pv.type
v.flags = pv.flags
res = ccs_binding_set_value(self.handle, hyperparameter, v)
Error.check(res)
def value(self, hyperparameter):
v = ccs_datum()
if isinstance(hyperparameter, Hyperparameter):
res = ccs_binding_get_value(self.handle, self.context.hyperparameter_index(hyperparameter), ct.byref(v))
elif isinstance(hyperparameter, str):
res = ccs_binding_get_value_by_name(self.handle, str.encode(hyperparameter), ct.byref(v))
else:
res = ccs_binding_get_value(self.handle, hyperparameter, ct.byref(v))
Error.check(res)
return v.value
@property
def values(self):
sz = self.num_values
if sz == 0:
return []
v = (ccs_datum * sz)()
res = ccs_binding_get_values(self.handle, sz, v, None)
Error.check(res)
return [x.value for x in v]
def cmp(self, other):
v = ccs_int()
res = ccs_binding_cmp(self.handle, other.handle, ct.byref(v))
Error.check(res)
return v.value
def __lt__(self, other):
v = ccs_int()
res = ccs_binding_cmp(self.handle, other.handle, ct.byref(v))
Error.check(res)
return v.value < 0
def __le__(self, other):
v = ccs_int()
res = ccs_binding_cmp(self.handle, other.handle, ct.byref(v))
Error.check(res)
return v.value <= 0
def __gt__(self, other):
v = ccs_int()
res = ccs_binding_cmp(self.handle, other.handle, ct.byref(v))
Error.check(res)
return v.value > 0
def __ge__(self, other):
v = ccs_int()
res = ccs_binding_cmp(self.handle, other.handle, ct.byref(v))
Error.check(res)
return v.value >= 0
def __eq__(self, other):
v = ccs_int()
res = ccs_binding_cmp(self.handle, other.handle, ct.byref(v))
Error.check(res)
return v.value == 0
def __ne__(self, other):
v = ccs_int()
res = ccs_binding_cmp(self.handle, other.handle, ct.byref(v))
Error.check(res)
return v.value != 0
@property
def hash(self):
v = ccs_hash()
res = ccs_binding_hash(self.handle, ct.byref(v))
Error.check(res)
return self.value
def __hash__(self):
return self.hash
def asdict(self):
res = {}
hyperparameters = self.context.hyperparameters
values = self.values
for i in range(len(hyperparameters)):
res[hyperparameters[i].name] = values[i]
return res
......@@ -4,19 +4,13 @@ from .context import Context
from .rng import Rng
from .hyperparameter import Hyperparameter
from .configuration_space import ConfigurationSpace
from .binding import Binding
ccs_create_configuration = _ccs_get_function("ccs_create_configuration", [ccs_configuration_space, ct.c_size_t, ct.POINTER(ccs_datum), ct.c_void_p, ct.POINTER(ccs_configuration)])
ccs_configuration_get_configuration_space = _ccs_get_function("ccs_configuration_get_configuration_space", [ccs_configuration, ct.POINTER(ccs_configuration_space)])
ccs_configuration_get_user_data = _ccs_get_function("ccs_configuration_get_user_data", [ccs_configuration, ct.POINTER(ct.c_void_p)])
ccs_configuration_get_value = _ccs_get_function("ccs_configuration_get_value", [ccs_configuration, ct.c_size_t, ct.POINTER(ccs_datum)])
ccs_configuration_set_value = _ccs_get_function("ccs_configuration_set_value", [ccs_configuration, ct.c_size_t, ccs_datum])
ccs_configuration_get_values = _ccs_get_function("ccs_configuration_get_values", [ccs_configuration, ct.c_size_t, ct.POINTER(ccs_datum), ct.POINTER(ct.c_size_t)])
ccs_configuration_get_value_by_name = _ccs_get_function("ccs_configuration_get_value_by_name", [ccs_configuration, ct.c_char_p, ct.POINTER(ccs_datum)])
ccs_configuration_check = _ccs_get_function("ccs_configuration_check", [ccs_configuration])
ccs_configuration_hash = _ccs_get_function("ccs_configuration_hash", [ccs_configuration, ct.POINTER(ccs_hash)])
ccs_configuration_cmp = _ccs_get_function("ccs_configuration_cmp", [ccs_configuration, ccs_configuration, ct.POINTER(ccs_int)])
class Configuration(Object):
class Configuration(Binding):
def __init__(self, handle = None, retain = False, auto_release = True,
configuration_space = None, values = None, user_data = None):
if handle is None:
......@@ -39,16 +33,6 @@ class Configuration(Object):
def from_handle(cls, handle, retain = True, auto_release = True):
return cls(handle = handle, retain = retain, auto_release = auto_release)
@property
def user_data(self):
if hasattr(self, "_user_data"):
return self._user_data
v = ct.c_void_p()
res = ccs_configuration_get_user_data(self.handle, ct.byref(v))
Error.check(res)
self._user_data = v
return v
@property
def configuration_space(self):
if hasattr(self, "_configuration_space"):
......@@ -59,109 +43,6 @@ class Configuration(Object):
self._configuration_space = ConfigurationSpace.from_handle(v)
return self._configuration_space
@property
def num_values(self):
if hasattr(self, "_num_values"):
return self._num_values
v = ct.c_size_t()
res = ccs_configuration_get_values(self.handle, 0, None, ct.byref(v))
Error.check(res)
self._num_values = v.value
return self._num_values
@property
def hash(self):
v = ccs_hash()
res = ccs_configuration_hash(self.handle, ct.byref(v))
Error.check(res)
return self.value
def set_value(self, hyperparameter, value):
if isinstance(hyperparameter, Hyperparameter):
hyperparameter = self.configuration_space.hyperparameter_index(hyperparameter)
elif isinstance(hyperparameter, str):
hyperparameter = self.configuration_space.hyperparameter_index_by_name(hyperparameter)
pv = ccs_datum(value)
v = ccs_datum_fix()
v.value = pv._value.i
v.type = pv.type
res = ccs_configuration_set_value(self.handle, hyperparameter, v)
Error.check(res)
def value(self, hyperparameter):
v = ccs_datum()
if isinstance(hyperparameter, Hyperparameter):
res = ccs_configuration_get_value(self.handle, self.configuration_space.hyperparameter_index(hyperparameter), ct.byref(v))
elif isinstance(hyperparameter, str):
res = ccs_configuration_get_value_by_name(self.handle, str.encode(hyperparameter), ct.byref(v))
else:
res = ccs_configuration_get_value(self.handle, hyperparameter, ct.byref(v))
Error.check(res)
return v.value
@property
def values(self):
sz = self.num_values
if sz == 0:
return []
v = (ccs_datum * sz)()
res = ccs_configuration_get_values(self.handle, sz, v, None)
Error.check(res)
return [x.value for x in v]
def check(self):
res = ccs_configuration_check(self.handle)
Error.check(res)
def cmp(self, other):
v = ccs_int()
res = ccs_configuration_cmp(self.handle, other.handle, ct.byref(v))
Error.check(res)
return v.value
def __lt__(self, other):
v = ccs_int()
res = ccs_configuration_cmp(self.handle, other.handle, ct.byref(v))
Error.check(res)
return v.value < 0
def __le__(self, other):
v = ccs_int()
res = ccs_configuration_cmp(self.handle, other.handle, ct.byref(v))
Error.check(res)
return v.value <= 0
def __gt__(self, other):
v = ccs_int()
res = ccs_configuration_cmp(self.handle, other.handle, ct.byref(v))
Error.check(res)
return v.value > 0
def __ge__(self, other):
v = ccs_int()
res = ccs_configuration_cmp(self.handle, other.handle, ct.byref(v))
Error.check(res)
return v.value >= 0
def __eq__(self, other):
v = ccs_int()
res = ccs_configuration_cmp(self.handle, other.handle, ct.byref(v))
Error.check(res)
return v.value == 0
def __ne__(self, other):
v = ccs_int()
res = ccs_configuration_cmp(self.handle, other.handle, ct.byref(v))
Error.check(res)
return v.value != 0
def __hash__(self):
return self.hash
def asdict(self):
res = {}
hyperparameters = self.configuration_space.hyperparameters
values = self.values
for i in range(len(hyperparameters)):
res[hyperparameters[i].name] = values[i]
return res
import ctypes as ct
from .base import Object, Error, ccs_error, _ccs_get_function, ccs_context, ccs_hyperparameter
from .base import Object, Error, ccs_error, _ccs_get_function, ccs_context, ccs_hyperparameter, ccs_datum, ccs_datum_fix
from .hyperparameter import Hyperparameter
ccs_context_get_name = _ccs_get_function("ccs_context_get_name", [ccs_context, ct.POINTER(ct.c_char_p)])
......@@ -11,6 +11,7 @@ ccs_context_get_hyperparameter_index_by_name = _ccs_get_function("ccs_context_ge
ccs_context_get_hyperparameter_index = _ccs_get_function("ccs_context_get_hyperparameter_index", [ccs_context, ccs_hyperparameter, ct.POINTER(ct.c_size_t)])
ccs_context_get_hyperparameter_indexes = _ccs_get_function("ccs_context_get_hyperparameter_indexes", [ccs_context, ct.c_size_t, ct.POINTER(ccs_hyperparameter), ct.POINTER(ct.c_size_t)])
ccs_context_get_hyperparameters = _ccs_get_function("ccs_context_get_hyperparameters", [ccs_context, ct.c_size_t, ct.POINTER(ccs_hyperparameter), ct.POINTER(ct.c_size_t)])
ccs_context_validate_value = _ccs_get_function("ccs_context_validate_value", [ccs_context, ct.c_size_t, ccs_datum_fix, ct.POINTER(ccs_datum)])
class Context(Object):
......@@ -74,3 +75,18 @@ class Context(Object):
res = ccs_context_get_hyperparameters(self.handle, count, v, None)
Error.check(res)
return [Hyperparameter.from_handle(ccs_hyperparameter(x)) for x in v]
def validate_value(self, hyperparameter, value):
if isinstance(hyperparameter, Hyperparameter):
hyperparameter = hyperparameter_index(hyperparameter)
elif isinstance(hyperparameter, str):
hyperparameter = hyperparameter_index_by_name(hyperparameter)
pv = ccs_datum(value)
v = ccs_datum_fix()
v.value = pv._value.i
v.type = pv.type
v.flags = pv.flags
vo = ccs_datum()
res = ccs_context_validate_value(self.handle, hyperparameter, v, ct.byref(vo))
Error.check(res)
return vo.value
......@@ -5,6 +5,7 @@ from .hyperparameter import Hyperparameter
from .configuration_space import ConfigurationSpace
from .configuration import Configuration
from .objective_space import ObjectiveSpace
from .binding import Binding
class ccs_comparison(CEnumeration):
_members_ = [
......@@ -16,18 +17,14 @@ class ccs_comparison(CEnumeration):
ccs_create_evaluation = _ccs_get_function("ccs_create_evaluation", [ccs_objective_space, ccs_configuration, ccs_result, ct.c_size_t, ct.POINTER(ccs_datum), ct.c_void_p, ct.POINTER(ccs_evaluation)])
ccs_evaluation_get_objective_space = _ccs_get_function("ccs_evaluation_get_objective_space", [ccs_evaluation, ct.POINTER(ccs_objective_space)])
ccs_evaluation_get_configuration = _ccs_get_function("ccs_evaluation_get_configuration", [ccs_evaluation, ct.POINTER(ccs_configuration)])
ccs_evaluation_get_user_data = _ccs_get_function("ccs_evaluation_get_user_data", [ccs_evaluation, ct.POINTER(ct.c_void_p)])
ccs_evaluation_get_error = _ccs_get_function("ccs_evaluation_get_error", [ccs_evaluation, ct.POINTER(ccs_result)])
ccs_evaluation_set_error = _ccs_get_function("ccs_evaluation_set_error", [ccs_evaluation, ccs_result])
ccs_evaluation_get_value = _ccs_get_function("ccs_evaluation_get_value", [ccs_evaluation, ct.c_size_t, ct.POINTER(ccs_datum)])
ccs_evaluation_set_value = _ccs_get_function("ccs_evaluation_set_value", [ccs_evaluation, ct.c_size_t, ccs_datum_fix])
ccs_evaluation_get_values = _ccs_get_function("ccs_evaluation_get_values", [ccs_evaluation, ct.c_size_t, ct.POINTER(ccs_datum), ct.POINTER(ct.c_size_t)])
ccs_evaluation_get_value_by_name = _ccs_get_function("ccs_evaluation_get_value_by_name", [ccs_evaluation, ct.c_char_p, ccs_datum])
ccs_evaluation_get_objective_value = _ccs_get_function("ccs_evaluation_get_objective_value", [ccs_evaluation, ct.c_size_t, ct.POINTER(ccs_datum)])
ccs_evaluation_get_objective_values = _ccs_get_function("ccs_evaluation_get_objective_values", [ccs_evaluation, ct.c_size_t, ct.POINTER(ccs_datum), ct.POINTER(ct.c_size_t)])
ccs_evaluation_cmp = _ccs_get_function("ccs_evaluation_cmp", [ccs_evaluation, ccs_evaluation, ct.POINTER(ccs_comparison)])
ccs_evaluation_compare = _ccs_get_function("ccs_evaluation_compare", [ccs_evaluation, ccs_evaluation, ct.POINTER(ccs_comparison)])
ccs_evaluation_check = _ccs_get_function("ccs_evaluation_check", [ccs_evaluation])
class Evaluation(Object):
class Evaluation(Binding):
def __init__(self, handle = None, retain = False, auto_release = True,
objective_space = None, configuration = None, error = ccs_error.SUCCESS, values = None, user_data = None):
if handle is None:
......@@ -50,16 +47,6 @@ class Evaluation(Object):
def from_handle(cls, handle, retain = True, auto_release = True):
return cls(handle = handle, retain = retain, auto_release = auto_release)
@property
def user_data(self):
if hasattr(self, "_user_data"):
return self._user_data
v = ct.c_void_p()
res = ccs_evaluation_get_user_data(self.handle, ct.byref(v))
Error.check(res)
self._user_data = v
return v
@property
def objective_space(self):
if hasattr(self, "_objective_space"):
......@@ -92,49 +79,6 @@ class Evaluation(Object):
res = ccs_evaluation_set_error(self.handle, v)
Error.check(res)
def set_value(self, hyperparameter, value):
if isinstance(hyperparameter, Hyperparameter):
hyperparameter = self.objective_space.hyperparameter_index(hyperparameter)
elif isinstance(hyperparameter, str):
hyperparameter = self.objective_space.hyperparameter_index_by_name(hyperparameter)
pv = ccs_datum(value)
v = ccs_datum_fix()
v.value = pv._value.i
v.type = pv.type
res = ccs_evaluation_set_value(self.handle, hyperparameter, v)
Error.check(res)
def value(self, hyperparameter):
v = ccs_datum()
if isinstance(hyperparameter, Hyperparameter):
res = ccs_evaluation_get_value(self.handle, self.objective_space.hyperparameter_index(hyperparameter), ct.byref(v))
elif isinstance(hyperparameter, str):
res = ccs_evaluation_get_value_by_name(self.handle, str.encode(hyperparameter), ct.byref(v))
else:
res = ccs_evaluation_get_value(self.handle, hyperparameter, ct.byref(v))
Error.check(res)
return v.value
@property
def num_values(self):
if hasattr(self, "_num_values"):
return self._num_values
v = ct.c_size_t()
res = ccs_evaluation_get_values(self.handle, 0, None, ct.byref(v))
Error.check(res)
self._num_values = v.value
return self._num_values
@property
def values(self):
sz = self.num_values
if sz == 0:
return []
v = (ccs_datum * sz)()
res = ccs_evaluation_get_values(self.handle, sz, v, None)
Error.check(res)
return [x.value for x in v]
@property
def num_objective_values(self):
if hasattr(self, "_num_objective_values"):
......@@ -155,8 +99,12 @@ class Evaluation(Object):
Error.check(res)
return [x.value for x in v]
def cmp(self, other):
def compare(self, other):
v = ccs_comparison(0)
res = ccs_evaluation_cmp(self.handle, other.handle, ct.byref(v))
res = ccs_evaluation_compare(self.handle, other.handle, ct.byref(v))
Error.check(res)
return v.value
def check(self):
res = ccs_evaluation_check(self.handle)
Error.check(res)
import ctypes as ct
from .base import Object, Error, CEnumeration, ccs_error, _ccs_get_function, ccs_context, ccs_hyperparameter, ccs_configuration_space, ccs_configuration, ccs_rng, ccs_distribution, ccs_expression, ccs_datum, ccs_objective_space
from .base import Object, Error, CEnumeration, ccs_error, _ccs_get_function, ccs_context, ccs_hyperparameter, ccs_configuration_space, ccs_configuration, ccs_evaluation, ccs_rng, ccs_distribution, ccs_expression, ccs_datum, ccs_objective_space
from .context import Context
from .hyperparameter import Hyperparameter
from .expression import Expression
......@@ -20,6 +20,8 @@ ccs_objective_space_add_objective = _ccs_get_function("ccs_objective_space_add_o
ccs_objective_space_add_objectives = _ccs_get_function("ccs_objective_space_add_objectives", [ccs_objective_space, ct.c_size_t, ct.POINTER(ccs_expression), ct.POINTER(ccs_objective_type)])
ccs_objective_space_get_objective = _ccs_get_function("ccs_objective_space_get_objective", [ccs_objective_space, ct.c_size_t, ct.POINTER(ccs_expression), ct.POINTER(ccs_objective_type)])
ccs_objective_space_get_objectives = _ccs_get_function("ccs_objective_space_get_objectives", [ccs_objective_space, ct.c_size_t, ct.POINTER(ccs_expression), ct.POINTER(ccs_objective_type), ct.POINTER(ct.c_size_t)])
ccs_objective_space_check_evaluation = _ccs_get_function("ccs_objective_space_check_evaluation", [ccs_objective_space, ccs_evaluation])
ccs_objective_space_check_evaluation_values = _ccs_get_function("ccs_objective_space_check_evaluation_values", [ccs_objective_space, ct.c_size_t, ct.POINTER(ccs_datum)])
class ObjectiveSpace(Context):
def __init__(self, handle = None, retain = False, auto_release = True,
......@@ -94,3 +96,18 @@ class ObjectiveSpace(Context):
res = ccs_objective_space_get_objectives(self.handle, sz, v, t, None)
Error.check(res)
return [(Expression.from_handle(ccs_expression(v[x])), t[x].value) for x in range(sz)]
def check(self, evaluation):
res = ccs_objective_space_check_evaluation(self.handle, evaluation.handle)
Error.check(res)
def check_values(self, values):
count = len(values)
if count != self.num_hyperparameters:
raise Error(ccs_error(ccs_error.INVALID_VALUE))
v = (ccs_datum * count)()
for i in range(count):
v[i].value = values[i]
res = ccs_objective_space_check_evaluation_values(self.handle, count, v)
Error.check(res)
......@@ -24,18 +24,21 @@ class TestEvaluation(unittest.TestCase):
ev1.set_value(v2, 0.6)
self.assertEqual( [0.5, 0.6], ev1.values )
self.assertEqual( [0.5, 0.6], ev1.objective_values )
ev1.check
os.check(ev1)
os.check_values(ev1.values)
ev2 = ccs.Evaluation(objective_space = os, configuration = cs.sample(), values = [0.5, 0.6])
self.assertEqual( [0.5, 0.6], ev2.values )
self.assertEqual( [0.5, 0.6], ev2.objective_values )
self.assertEqual( ccs.EQUIVALENT, ev1.cmp(ev2) )
self.assertEqual( ccs.EQUIVALENT, ev1.compare(ev2) )
ev3 = ccs.Evaluation(objective_space = os, configuration = cs.sample(), values = [0.6, 0.5])
self.assertEqual( [0.6, 0.5], ev3.objective_values )
self.assertEqual( ccs.WORSE, ev1.cmp(ev3) )
self.assertEqual( ccs.BETTER, ev3.cmp(ev1) )
self.assertEqual( ccs.WORSE, ev1.compare(ev3) )
self.assertEqual( ccs.BETTER, ev3.compare(ev1) )
ev4 = ccs.Evaluation(objective_space = os, configuration = cs.sample(), values = [0.6, 0.7])
self.assertEqual( [0.6, 0.7], ev4.objective_values )
self.assertEqual( ccs.NOT_COMPARABLE, ev1.cmp(ev4) )
self.assertEqual( ccs.NOT_COMPARABLE, ev4.cmp(ev1) )
self.assertEqual( ccs.NOT_COMPARABLE, ev1.compare(ev4) )
self.assertEqual( ccs.NOT_COMPARABLE, ev4.compare(ev1) )
if __name__ == '__main__':
unittest.main()
......@@ -67,7 +67,7 @@ class TestTuner(unittest.TestCase):
if discard:
new_optimums.append(o)
else:
c = e.cmp(o)
c = e.compare(o)
if c == ccs.EQUIVALENT or c == ccs.WORSE:
discard = True
new_optimums.append(o)
......
......@@ -9,6 +9,7 @@ require_relative 'cconfigspace/expression'
require_relative 'cconfigspace/expression_parser'
require_relative 'cconfigspace/context'
require_relative 'cconfigspace/configuration_space'
require_relative 'cconfigspace/binding'
require_relative 'cconfigspace/configuration'
require_relative 'cconfigspace/objective_space'
require_relative 'cconfigspace/evaluation'
......