diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am index 995a0032..c0ceeff8 100644 --- a/bindings/python/Makefile.am +++ b/bindings/python/Makefile.am @@ -2,7 +2,7 @@ EXTRA_DIST = \ cconfigspace/rng.py \ cconfigspace/context.py \ cconfigspace/parameter.py \ - cconfigspace/features_space.py \ + cconfigspace/feature_space.py \ cconfigspace/distribution.py \ cconfigspace/map.py \ cconfigspace/expression_parser.py \ @@ -43,7 +43,7 @@ EXTRA_DIST = \ test/test_features_tuner.py \ test/test_objective_space.py \ test/test_configuration_space.py \ - test/test_features_space.py \ + test/test_feature_space.py \ setup.py if ISMACOS diff --git a/bindings/python/cconfigspace/__init__.py b/bindings/python/cconfigspace/__init__.py index 446aa70a..00540633 100644 --- a/bindings/python/cconfigspace/__init__.py +++ b/bindings/python/cconfigspace/__init__.py @@ -23,7 +23,7 @@ from .distribution_space import * from .binding import * from .configuration import * -from .features_space import * +from .feature_space import * from .features import * from .objective_space import * from .evaluation_binding import * diff --git a/bindings/python/cconfigspace/base.py b/bindings/python/cconfigspace/base.py index 6617ae3c..79eb9f62 100644 --- a/bindings/python/cconfigspace/base.py +++ b/bindings/python/cconfigspace/base.py @@ -31,7 +31,7 @@ def __str__(self): ccs_configuration_space = ccs_object ccs_binding = ccs_object ccs_configuration = ccs_object -ccs_features_space = ccs_object +ccs_feature_space = ccs_object ccs_features = ccs_object ccs_objective_space = ccs_object ccs_evaluation_binding = ccs_object @@ -146,7 +146,7 @@ class ObjectType(CEnumeration): 'OBJECTIVE_SPACE', 'EVALUATION', 'TUNER', - 'FEATURES_SPACE', + 'FEATURE_SPACE', 'FEATURES', 'FEATURES_EVALUATION', 'FEATURES_TUNER', @@ -754,7 +754,7 @@ def _ccs_get_id(): from .configuration_space import ConfigurationSpace from .distribution_space import DistributionSpace from .configuration import Configuration -from .features_space import FeaturesSpace +from .feature_space import FeatureSpace from .features import Features from .objective_space import ObjectiveSpace from .evaluation import Evaluation @@ -776,7 +776,7 @@ def _ccs_get_id(): ObjectType.EXPRESSION: Expression, ObjectType.CONFIGURATION_SPACE: ConfigurationSpace, ObjectType.CONFIGURATION: Configuration, - ObjectType.FEATURES_SPACE: ConfigurationSpace, + ObjectType.FEATURE_SPACE: FeatureSpace, ObjectType.FEATURES: Features, ObjectType.OBJECTIVE_SPACE: ObjectiveSpace, ObjectType.EVALUATION: Evaluation, diff --git a/bindings/python/cconfigspace/features_space.py b/bindings/python/cconfigspace/feature_space.py similarity index 57% rename from bindings/python/cconfigspace/features_space.py rename to bindings/python/cconfigspace/feature_space.py index c835c742..4b91d14f 100644 --- a/bindings/python/cconfigspace/features_space.py +++ b/bindings/python/cconfigspace/feature_space.py @@ -1,19 +1,19 @@ import ctypes as ct -from .base import Object, Error, CEnumeration, Result, _ccs_get_function, ccs_context, ccs_parameter, ccs_features_space, ccs_features, Datum, ccs_bool +from .base import Object, Error, CEnumeration, Result, _ccs_get_function, ccs_context, ccs_parameter, ccs_feature_space, ccs_features, Datum, ccs_bool from .context import Context from .parameter import Parameter -ccs_create_features_space = _ccs_get_function("ccs_create_features_space", [ct.c_char_p, ct.c_size_t, ct.POINTER(ccs_parameter), ct.POINTER(ccs_features_space)]) -ccs_features_space_check_features = _ccs_get_function("ccs_features_space_check_features", [ccs_features_space, ccs_features, ct.POINTER(ccs_bool)]) +ccs_create_feature_space = _ccs_get_function("ccs_create_feature_space", [ct.c_char_p, ct.c_size_t, ct.POINTER(ccs_parameter), ct.POINTER(ccs_feature_space)]) +ccs_feature_space_check_features = _ccs_get_function("ccs_feature_space_check_features", [ccs_feature_space, ccs_features, ct.POINTER(ccs_bool)]) -class FeaturesSpace(Context): +class FeatureSpace(Context): def __init__(self, handle = None, retain = False, auto_release = True, name = "", parameters = None): if handle is None: count = len(parameters) parameters = (ccs_parameter * count)(*[x.handle.value for x in parameters]) - handle = ccs_features_space() - res = ccs_create_features_space(str.encode(name), count, parameters, ct.byref(handle)) + handle = ccs_feature_space() + res = ccs_create_feature_space(str.encode(name), count, parameters, ct.byref(handle)) Error.check(res) super().__init__(handle = handle, retain = False) else: @@ -25,7 +25,7 @@ def from_handle(cls, handle, retain = True, auto_release = True): def check(self, features): valid = ccs_bool() - res = ccs_features_space_check_features(self.handle, features.handle, ct.byref(valid)) + res = ccs_feature_space_check_features(self.handle, features.handle, ct.byref(valid)) Error.check(res) return False if valid.value == 0 else True diff --git a/bindings/python/cconfigspace/features.py b/bindings/python/cconfigspace/features.py index 0d951bd5..d12e2fb7 100644 --- a/bindings/python/cconfigspace/features.py +++ b/bindings/python/cconfigspace/features.py @@ -1,17 +1,17 @@ import ctypes as ct -from .base import Object, Error, Result, _ccs_get_function, ccs_context, ccs_parameter, ccs_features_space, ccs_features, Datum, ccs_hash, ccs_int, ccs_bool +from .base import Object, Error, Result, _ccs_get_function, ccs_context, ccs_parameter, ccs_feature_space, ccs_features, Datum, ccs_hash, ccs_int, ccs_bool from .context import Context from .parameter import Parameter -from .features_space import FeaturesSpace +from .feature_space import FeatureSpace from .binding import Binding -ccs_create_features = _ccs_get_function("ccs_create_features", [ccs_features_space, ct.c_size_t, ct.POINTER(Datum), ct.POINTER(ccs_features)]) -ccs_features_get_features_space = _ccs_get_function("ccs_features_get_features_space", [ccs_features, ct.POINTER(ccs_features_space)]) +ccs_create_features = _ccs_get_function("ccs_create_features", [ccs_feature_space, ct.c_size_t, ct.POINTER(Datum), ct.POINTER(ccs_features)]) +ccs_features_get_feature_space = _ccs_get_function("ccs_features_get_feature_space", [ccs_features, ct.POINTER(ccs_feature_space)]) ccs_features_check = _ccs_get_function("ccs_features_check", [ccs_features, ct.POINTER(ccs_bool)]) class Features(Binding): def __init__(self, handle = None, retain = False, auto_release = True, - features_space = None, values = None): + feature_space = None, values = None): if handle is None: count = 0 if values: @@ -23,7 +23,7 @@ def __init__(self, handle = None, retain = False, auto_release = True, else: vals = None handle = ccs_features() - res = ccs_create_features(features_space.handle, count, vals, ct.byref(handle)) + res = ccs_create_features(feature_space.handle, count, vals, ct.byref(handle)) Error.check(res) super().__init__(handle = handle, retain = False) else: @@ -34,14 +34,14 @@ def from_handle(cls, handle, retain = True, auto_release = True): return cls(handle = handle, retain = retain, auto_release = auto_release) @property - def features_space(self): - if hasattr(self, "_features_space"): - return self._features_space - v = ccs_features_space() - res = ccs_features_get_features_space(self.handle, ct.byref(v)) + def feature_space(self): + if hasattr(self, "_feature_space"): + return self._feature_space + v = ccs_feature_space() + res = ccs_features_get_feature_space(self.handle, ct.byref(v)) Error.check(res) - self._features_space = ConfigurationSpace.from_handle(v) - return self._features_space + self._feature_space = FeatureSpace.from_handle(v) + return self._feature_space def check(self): valid = ccs_bool() diff --git a/bindings/python/cconfigspace/features_tuner.py b/bindings/python/cconfigspace/features_tuner.py index 73fe211a..c5e8108a 100644 --- a/bindings/python/cconfigspace/features_tuner.py +++ b/bindings/python/cconfigspace/features_tuner.py @@ -1,10 +1,10 @@ import ctypes as ct -from .base import Object, Error, CEnumeration, Result, _ccs_get_function, ccs_context, ccs_parameter, ccs_configuration_space, ccs_configuration, ccs_features_space, ccs_features, Datum, ccs_objective_space, ccs_features_evaluation, ccs_features_tuner, ccs_retain_object, _register_vector, _unregister_vector +from .base import Object, Error, CEnumeration, Result, _ccs_get_function, ccs_context, ccs_parameter, ccs_configuration_space, ccs_configuration, ccs_feature_space, ccs_features, Datum, ccs_objective_space, ccs_features_evaluation, ccs_features_tuner, ccs_retain_object, _register_vector, _unregister_vector from .context import Context from .parameter import Parameter from .configuration_space import ConfigurationSpace from .configuration import Configuration -from .features_space import FeaturesSpace +from .feature_space import FeatureSpace from .features import Features from .objective_space import ObjectiveSpace from .features_evaluation import FeaturesEvaluation @@ -18,7 +18,7 @@ class FeaturesTunerType(CEnumeration): ccs_features_tuner_get_name = _ccs_get_function("ccs_features_tuner_get_name", [ccs_features_tuner, ct.POINTER(ct.c_char_p)]) ccs_features_tuner_get_configuration_space = _ccs_get_function("ccs_features_tuner_get_configuration_space", [ccs_features_tuner, ct.POINTER(ccs_configuration_space)]) ccs_features_tuner_get_objective_space = _ccs_get_function("ccs_features_tuner_get_objective_space", [ccs_features_tuner, ct.POINTER(ccs_objective_space)]) -ccs_features_tuner_get_features_space = _ccs_get_function("ccs_features_tuner_get_features_space", [ccs_features_tuner, ct.POINTER(ccs_features_space)]) +ccs_features_tuner_get_feature_space = _ccs_get_function("ccs_features_tuner_get_feature_space", [ccs_features_tuner, ct.POINTER(ccs_feature_space)]) ccs_features_tuner_ask = _ccs_get_function("ccs_features_tuner_ask", [ccs_features_tuner, ccs_features, ct.c_size_t, ct.POINTER(ccs_configuration), ct.POINTER(ct.c_size_t)]) ccs_features_tuner_tell = _ccs_get_function("ccs_features_tuner_tell", [ccs_features_tuner, ct.c_size_t, ct.POINTER(ccs_features_evaluation)]) ccs_features_tuner_get_optima = _ccs_get_function("ccs_features_tuner_get_optima", [ccs_features_tuner, ccs_features, ct.c_size_t, ct.POINTER(ccs_features_evaluation), ct.POINTER(ct.c_size_t)]) @@ -70,14 +70,14 @@ def objective_space(self): return self._objective_space @property - def features_space(self): - if hasattr(self, "_features_space"): - return self._features_space - v = ccs_features_space() - res = ccs_features_tuner_get_features_space(self.handle, ct.byref(v)) + def feature_space(self): + if hasattr(self, "_feature_space"): + return self._feature_space + v = ccs_feature_space() + res = ccs_features_tuner_get_feature_space(self.handle, ct.byref(v)) Error.check(res) - self._features_space = FeaturesSpace.from_handle(v) - return self._features_space + self._feature_space = FeatureSpace.from_handle(v) + return self._feature_space @property def configuration_space(self): @@ -143,14 +143,14 @@ def suggest(self, features): Error.check(res) return Configuration(handle = config, retain = False) -ccs_create_random_features_tuner = _ccs_get_function("ccs_create_random_features_tuner", [ct.c_char_p, ccs_configuration_space, ccs_features_space, ccs_objective_space, ct.POINTER(ccs_features_tuner)]) +ccs_create_random_features_tuner = _ccs_get_function("ccs_create_random_features_tuner", [ct.c_char_p, ccs_configuration_space, ccs_feature_space, ccs_objective_space, ct.POINTER(ccs_features_tuner)]) class RandomFeaturesTuner(FeaturesTuner): def __init__(self, handle = None, retain = False, auto_release = True, - name = "", configuration_space = None, features_space = None, objective_space = None): + name = "", configuration_space = None, feature_space = None, objective_space = None): if handle is None: handle = ccs_features_tuner() - res = ccs_create_random_features_tuner(str.encode(name), configuration_space.handle, features_space.handle, objective_space.handle, ct.byref(handle)) + res = ccs_create_random_features_tuner(str.encode(name), configuration_space.handle, feature_space.handle, objective_space.handle, ct.byref(handle)) Error.check(res) super().__init__(handle = handle, retain = False) else: @@ -178,7 +178,7 @@ class UserDefinedFeaturesTunerVector(ct.Structure): ('serialize', ccs_user_defined_features_tuner_serialize_type), ('deserialize', ccs_user_defined_features_tuner_deserialize_type) ] -ccs_create_user_defined_features_tuner = _ccs_get_function("ccs_create_user_defined_features_tuner", [ct.c_char_p, ccs_configuration_space, ccs_features_space, ccs_objective_space, ct.POINTER(UserDefinedFeaturesTunerVector), ct.py_object, ct.POINTER(ccs_features_tuner)]) +ccs_create_user_defined_features_tuner = _ccs_get_function("ccs_create_user_defined_features_tuner", [ct.c_char_p, ccs_configuration_space, ccs_feature_space, ccs_objective_space, ct.POINTER(UserDefinedFeaturesTunerVector), ct.py_object, ct.POINTER(ccs_features_tuner)]) ccs_user_defined_features_tuner_get_tuner_data = _ccs_get_function("ccs_user_defined_features_tuner_get_tuner_data", [ccs_features_tuner, ct.POINTER(ct.c_void_p)]) def _wrap_user_defined_features_tuner_callbacks(delete, ask, tell, get_optima, get_history, suggest, serialize, deserialize): @@ -346,7 +346,7 @@ def deserialize_wrapper(tun, size_history, p_history, num_optima, p_optima, stat class UserDefinedFeaturesTuner(FeaturesTuner): def __init__(self, handle = None, retain = False, auto_release = True, - name = "", configuration_space = None, features_space = None, objective_space = None, delete = None, ask = None, tell = None, get_optima = None, get_history = None, suggest = None, serialize = None, deserialize = None, tuner_data = None ): + name = "", configuration_space = None, feature_space = None, objective_space = None, delete = None, ask = None, tell = None, get_optima = None, get_history = None, suggest = None, serialize = None, deserialize = None, tuner_data = None ): if handle is None: if ask is None or tell is None or get_optima is None or get_history is None: raise Error(Result(Result.ERROR_INVALID_VALUE)) @@ -381,7 +381,7 @@ def __init__(self, handle = None, retain = False, auto_release = True, c_tuner_data = ct.py_object(tuner_data) else: c_tuner_data = None - res = ccs_create_user_defined_features_tuner(str.encode(name), configuration_space.handle, features_space.handle, objective_space.handle, ct.byref(vec), c_tuner_data, ct.byref(handle)) + res = ccs_create_user_defined_features_tuner(str.encode(name), configuration_space.handle, feature_space.handle, objective_space.handle, ct.byref(vec), c_tuner_data, ct.byref(handle)) Error.check(res) super().__init__(handle = handle, retain = False) _register_vector(handle, [delete_wrapper, ask_wrapper, tell_wrapper, get_optima_wrapper, get_history_wrapper, suggest_wrapper, serialize_wrapper, deserialize_wrapper, delete_wrapper_func, ask_wrapper_func, tell_wrapper_func, get_optima_wrapper_func, get_history_wrapper_func, suggest_wrapper_func, serialize_wrapper_func, deserialize_wrapper_func, tuner_data]) diff --git a/bindings/python/test/test_features_space.py b/bindings/python/test/test_feature_space.py similarity index 79% rename from bindings/python/test/test_features_space.py rename to bindings/python/test/test_feature_space.py index 05e359b1..eb7b3424 100644 --- a/bindings/python/test/test_features_space.py +++ b/bindings/python/test/test_feature_space.py @@ -5,14 +5,14 @@ sys.path.insert(1, '..') import cconfigspace as ccs -class TestFeaturesSpace(unittest.TestCase): +class TestFeatureSpace(unittest.TestCase): def test_create(self): h1 = ccs.NumericalParameter.Float(lower = 0.0, upper = 1.0) h2 = ccs.NumericalParameter.Float(lower = 0.0, upper = 1.0) h3 = ccs.NumericalParameter.Float(lower = 0.0, upper = 1.0) - cs = ccs.FeaturesSpace(name = "space", parameters = [h1, h2, h3]) - self.assertEqual( ccs.ObjectType.FEATURES_SPACE, cs.object_type ) + cs = ccs.FeatureSpace(name = "space", parameters = [h1, h2, h3]) + self.assertEqual( ccs.ObjectType.FEATURE_SPACE, cs.object_type ) self.assertEqual( "space", cs.name ) self.assertEqual( 3, cs.num_parameters ) self.assertEqual( h1, cs.parameter(0) ) diff --git a/bindings/python/test/test_features_tuner.py b/bindings/python/test/test_features_tuner.py index e5024d13..a11db5e0 100644 --- a/bindings/python/test/test_features_tuner.py +++ b/bindings/python/test/test_features_tuner.py @@ -18,18 +18,18 @@ def create_tuning_problem(self): e2 = ccs.Expression.Variable(parameter = v2) os = ccs.ObjectiveSpace(name = "ospace", parameters = [v1, v2], objectives = [e1, e2]) f1 = ccs.CategoricalParameter(values = [True, False]) - fs = ccs.FeaturesSpace(name = "fspace", parameters = [f1]) + fs = ccs.FeatureSpace(name = "fspace", parameters = [f1]) return (cs, fs, os) def test_create_random(self): (cs, fs, os) = self.create_tuning_problem() - t = ccs.RandomFeaturesTuner(name = "tuner", configuration_space = cs, features_space = fs, objective_space = os) + t = ccs.RandomFeaturesTuner(name = "tuner", configuration_space = cs, feature_space = fs, objective_space = os) t2 = ccs.Object.from_handle(t.handle) self.assertEqual("tuner", t.name) self.assertEqual(ccs.FeaturesTunerType.RANDOM, t.type) func = lambda x, y, z: [(x-2)*(x-2), sin(z+y)] - features_on = ccs.Features(features_space = fs, values = [True]) - features_off = ccs.Features(features_space = fs, values = [False]) + features_on = ccs.Features(feature_space = fs, values = [True]) + features_off = ccs.Features(feature_space = fs, values = [False]) evals = [ccs.FeaturesEvaluation(objective_space = os, configuration = c, features = features_on, values = func(*(c.values))) for c in t.ask(features_on, 50)] t.tell(evals) evals = [ccs.FeaturesEvaluation(objective_space = os, configuration = c, features = features_off, values = func(*(c.values))) for c in t.ask(features_off, 50)] @@ -119,16 +119,16 @@ def suggest(tuner, features): return choice(optis).configuration (cs, fs, os) = self.create_tuning_problem() - t = ccs.UserDefinedFeaturesTuner(name = "tuner", configuration_space = cs, features_space = fs, objective_space = os, delete = delete, ask = ask, tell = tell, get_optima = get_optima, get_history = get_history, suggest = suggest, tuner_data = TunerData()) + t = ccs.UserDefinedFeaturesTuner(name = "tuner", configuration_space = cs, feature_space = fs, objective_space = os, delete = delete, ask = ask, tell = tell, get_optima = get_optima, get_history = get_history, suggest = suggest, tuner_data = TunerData()) t2 = ccs.Object.from_handle(t.handle) self.assertEqual("tuner", t.name) self.assertEqual(ccs.FeaturesTunerType.USER_DEFINED, t.type) self.assertEqual(cs.handle.value, t.configuration_space.handle.value) - self.assertEqual(fs.handle.value, t.features_space.handle.value) + self.assertEqual(fs.handle.value, t.feature_space.handle.value) self.assertEqual(os.handle.value, t.objective_space.handle.value) func = lambda x, y, z: [(x-2)*(x-2), sin(z+y)] - features_on = ccs.Features(features_space = fs, values = [True]) - features_off = ccs.Features(features_space = fs, values = [False]) + features_on = ccs.Features(feature_space = fs, values = [True]) + features_off = ccs.Features(feature_space = fs, values = [False]) evals = [ccs.FeaturesEvaluation(objective_space = os, configuration = c, features = features_on, values = func(*(c.values))) for c in t.ask(features_on, 50)] t.tell(evals) evals = [ccs.FeaturesEvaluation(objective_space = os, configuration = c, features = features_off, values = func(*(c.values))) for c in t.ask(features_off, 50)] diff --git a/bindings/ruby/Makefile.am b/bindings/ruby/Makefile.am index 6040056b..6e257334 100644 --- a/bindings/ruby/Makefile.am +++ b/bindings/ruby/Makefile.am @@ -10,7 +10,7 @@ EXTRA_DIST = \ lib/cconfigspace/tree_tuner.rb \ lib/cconfigspace/binding.rb \ lib/cconfigspace/tree_space.rb \ - lib/cconfigspace/features_space.rb \ + lib/cconfigspace/feature_space.rb \ lib/cconfigspace/base.rb \ lib/cconfigspace/configuration_space.rb \ lib/cconfigspace/distribution_space.rb \ @@ -28,7 +28,7 @@ EXTRA_DIST = \ lib/cconfigspace/error_stack.rb \ lib/cconfigspace/tree_configuration.rb \ lib/cconfigspace/context.rb \ - test/test_features_space.rb \ + test/test_feature_space.rb \ test/test_expression.rb \ test/test_tree_evaluation.rb \ test/test_interval.rb \ diff --git a/bindings/ruby/lib/cconfigspace.rb b/bindings/ruby/lib/cconfigspace.rb index 93b1610f..dc4be285 100644 --- a/bindings/ruby/lib/cconfigspace.rb +++ b/bindings/ruby/lib/cconfigspace.rb @@ -15,7 +15,7 @@ require_relative 'cconfigspace/distribution_space' require_relative 'cconfigspace/binding' require_relative 'cconfigspace/configuration' -require_relative 'cconfigspace/features_space' +require_relative 'cconfigspace/feature_space' require_relative 'cconfigspace/features' require_relative 'cconfigspace/objective_space' require_relative 'cconfigspace/evaluation_binding' diff --git a/bindings/ruby/lib/cconfigspace/base.rb b/bindings/ruby/lib/cconfigspace/base.rb index 3ccb32b0..ca333e57 100644 --- a/bindings/ruby/lib/cconfigspace/base.rb +++ b/bindings/ruby/lib/cconfigspace/base.rb @@ -100,7 +100,7 @@ class Version < FFI::Struct typedef :ccs_object_t, :ccs_configuration_space_t typedef :ccs_object_t, :ccs_binding_t typedef :ccs_object_t, :ccs_configuration_t - typedef :ccs_object_t, :ccs_features_space_t + typedef :ccs_object_t, :ccs_feature_space_t typedef :ccs_object_t, :ccs_features_t typedef :ccs_object_t, :ccs_objective_space_t typedef :ccs_object_t, :ccs_evaluation_binding_t @@ -126,7 +126,7 @@ class MemoryPointer alias read_ccs_configuration_space_t read_ccs_object_t alias read_ccs_binding_t read_ccs_object_t alias read_ccs_configuration_t read_ccs_object_t - alias read_ccs_features_space_t read_ccs_object_t + alias read_ccs_feature_space_t read_ccs_object_t alias read_ccs_features_t read_ccs_object_t alias read_ccs_objective_space_t read_ccs_object_t alias read_ccs_evaluation_binding_t read_ccs_object_t @@ -153,7 +153,7 @@ class MemoryPointer :CCS_OBJECT_TYPE_OBJECTIVE_SPACE, :CCS_OBJECT_TYPE_EVALUATION, :CCS_OBJECT_TYPE_TUNER, - :CCS_OBJECT_TYPE_FEATURES_SPACE, + :CCS_OBJECT_TYPE_FEATURE_SPACE, :CCS_OBJECT_TYPE_FEATURES, :CCS_OBJECT_TYPE_FEATURES_EVALUATION, :CCS_OBJECT_TYPE_FEATURES_TUNER, @@ -580,7 +580,7 @@ def self.class_map CCS_OBJECT_TYPE_EXPRESSION: CCS::Expression, CCS_OBJECT_TYPE_CONFIGURATION_SPACE: CCS::ConfigurationSpace, CCS_OBJECT_TYPE_CONFIGURATION: CCS::Configuration, - CCS_OBJECT_TYPE_FEATURES_SPACE: CCS::FeaturesSpace, + CCS_OBJECT_TYPE_FEATURE_SPACE: CCS::FeatureSpace, CCS_OBJECT_TYPE_FEATURES: CCS::Features, CCS_OBJECT_TYPE_OBJECTIVE_SPACE: CCS::ObjectiveSpace, CCS_OBJECT_TYPE_EVALUATION: CCS::Evaluation, diff --git a/bindings/ruby/lib/cconfigspace/features_space.rb b/bindings/ruby/lib/cconfigspace/feature_space.rb similarity index 56% rename from bindings/ruby/lib/cconfigspace/features_space.rb rename to bindings/ruby/lib/cconfigspace/feature_space.rb index 360598ec..dcb02941 100644 --- a/bindings/ruby/lib/cconfigspace/features_space.rb +++ b/bindings/ruby/lib/cconfigspace/feature_space.rb @@ -1,8 +1,8 @@ module CCS - attach_function :ccs_create_features_space, [:string, :size_t, :pointer, :pointer], :ccs_result_t - attach_function :ccs_features_space_check_features, [:ccs_features_space_t, :ccs_features_t, :pointer], :ccs_result_t + attach_function :ccs_create_feature_space, [:string, :size_t, :pointer, :pointer], :ccs_result_t + attach_function :ccs_feature_space_check_features, [:ccs_feature_space_t, :ccs_features_t, :pointer], :ccs_result_t - class FeaturesSpace < Context + class FeatureSpace < Context def initialize(handle = nil, retain: false, auto_release: true, name: "", parameters: nil) if handle @@ -11,9 +11,9 @@ def initialize(handle = nil, retain: false, auto_release: true, count = parameters.size p_parameters = MemoryPointer::new(:ccs_parameter_t, count) p_parameters.write_array_of_pointer(parameters.collect(&:handle)) - ptr = MemoryPointer::new(:ccs_features_space_t) - CCS.error_check CCS.ccs_create_features_space(name, count, p_parameters, ptr) - super(ptr.read_ccs_features_space_t, retain: false) + ptr = MemoryPointer::new(:ccs_feature_space_t) + CCS.error_check CCS.ccs_create_feature_space(name, count, p_parameters, ptr) + super(ptr.read_ccs_feature_space_t, retain: false) end end @@ -23,7 +23,7 @@ def self.from_handle(handle, retain: true, auto_release: true) def check(features) ptr = MemoryPointer::new(:ccs_bool_t) - CCS.error_check CCS.ccs_features_space_check_features(@handle, features, ptr) + CCS.error_check CCS.ccs_feature_space_check_features(@handle, features, ptr) return ptr.read_ccs_bool_t == CCS::FALSE ? false : true end diff --git a/bindings/ruby/lib/cconfigspace/features.rb b/bindings/ruby/lib/cconfigspace/features.rb index 0982f0db..509773f4 100644 --- a/bindings/ruby/lib/cconfigspace/features.rb +++ b/bindings/ruby/lib/cconfigspace/features.rb @@ -1,14 +1,14 @@ module CCS - attach_function :ccs_create_features, [:ccs_features_space_t, :size_t, :pointer, :pointer], :ccs_result_t + attach_function :ccs_create_features, [:ccs_feature_space_t, :size_t, :pointer, :pointer], :ccs_result_t attach_function :ccs_features_check, [:ccs_features_t, :pointer], :ccs_result_t class Features < Binding - alias features_space context + alias feature_space context include Comparable def initialize(handle = nil, retain: false, auto_release: true, - features_space: nil, values: nil) + feature_space: nil, values: nil) if handle super(handle, retain: retain, auto_release: auto_release) else @@ -23,7 +23,7 @@ def initialize(handle = nil, retain: false, auto_release: true, count = 0 end ptr = MemoryPointer::new(:ccs_features_t) - CCS.error_check CCS.ccs_create_features(features_space, count, values, ptr) + CCS.error_check CCS.ccs_create_features(feature_space, count, values, ptr) super(ptr.read_ccs_features_t, retain: false) end end diff --git a/bindings/ruby/lib/cconfigspace/features_tuner.rb b/bindings/ruby/lib/cconfigspace/features_tuner.rb index 3bf63581..6030cef1 100644 --- a/bindings/ruby/lib/cconfigspace/features_tuner.rb +++ b/bindings/ruby/lib/cconfigspace/features_tuner.rb @@ -14,18 +14,18 @@ def read_ccs_features_tuner_type_t attach_function :ccs_features_tuner_get_name, [:ccs_features_tuner_t, :pointer], :ccs_result_t attach_function :ccs_features_tuner_get_configuration_space, [:ccs_features_tuner_t, :pointer], :ccs_result_t attach_function :ccs_features_tuner_get_objective_space, [:ccs_features_tuner_t, :pointer], :ccs_result_t - attach_function :ccs_features_tuner_get_features_space, [:ccs_features_tuner_t, :pointer], :ccs_result_t + attach_function :ccs_features_tuner_get_feature_space, [:ccs_features_tuner_t, :pointer], :ccs_result_t attach_function :ccs_features_tuner_ask, [:ccs_features_tuner_t, :ccs_features_t, :size_t, :pointer, :pointer], :ccs_result_t attach_function :ccs_features_tuner_tell, [:ccs_features_tuner_t, :size_t, :pointer], :ccs_result_t attach_function :ccs_features_tuner_get_optima, [:ccs_features_tuner_t, :ccs_features_t, :size_t, :pointer, :pointer], :ccs_result_t attach_function :ccs_features_tuner_get_history, [:ccs_features_tuner_t, :ccs_features_t, :size_t, :pointer, :pointer], :ccs_result_t attach_function :ccs_features_tuner_suggest, [:ccs_features_tuner_t, :ccs_features_t, :pointer], :ccs_result_t - attach_function :ccs_create_random_features_tuner, [:string, :ccs_configuration_space_t, :ccs_features_space_t, :ccs_objective_space_t, :pointer], :ccs_result_t + attach_function :ccs_create_random_features_tuner, [:string, :ccs_configuration_space_t, :ccs_feature_space_t, :ccs_objective_space_t, :pointer], :ccs_result_t class FeaturesTuner < Object add_property :type, :ccs_features_tuner_type_t, :ccs_features_tuner_get_type, memoize: true add_handle_property :configuration_space, :ccs_configuration_space_t, :ccs_features_tuner_get_configuration_space, memoize: true - add_handle_property :features_space, :ccs_features_space_t, :ccs_features_tuner_get_features_space, memoize: true + add_handle_property :feature_space, :ccs_feature_space_t, :ccs_features_tuner_get_feature_space, memoize: true add_handle_property :objective_space, :ccs_objective_space_t, :ccs_features_tuner_get_objective_space, memoize: true def self.from_handle(handle, retain: true, auto_release: true) @@ -101,12 +101,12 @@ def suggest(features) class RandomFeaturesTuner < FeaturesTuner def initialize(handle = nil, retain: false, auto_release: true, - name: "", configuration_space: nil, features_space: nil, objective_space: nil) + name: "", configuration_space: nil, feature_space: nil, objective_space: nil) if handle super(handle, retain: retain, auto_release: auto_release) else ptr = MemoryPointer::new(:ccs_features_tuner_t) - CCS.error_check CCS.ccs_create_random_features_tuner(name, configuration_space, features_space, objective_space, ptr) + CCS.error_check CCS.ccs_create_random_features_tuner(name, configuration_space, feature_space, objective_space, ptr) super(ptr.read_ccs_features_tuner_t, retain: false) end end @@ -257,13 +257,13 @@ def self.wrap_user_defined_features_tuner_callbacks(del, ask, tell, get_optima, return [delwrapper, askwrapper, tellwrapper, get_optimawrapper, get_historywrapper, suggestwrapper, serializewrapper, deserializewrapper] end - attach_function :ccs_create_user_defined_features_tuner, [:string, :ccs_configuration_space_t, :ccs_features_space_t, :ccs_objective_space_t, UserDefinedFeaturesTunerVector.by_ref, :value, :pointer], :ccs_result_t + attach_function :ccs_create_user_defined_features_tuner, [:string, :ccs_configuration_space_t, :ccs_feature_space_t, :ccs_objective_space_t, UserDefinedFeaturesTunerVector.by_ref, :value, :pointer], :ccs_result_t attach_function :ccs_user_defined_features_tuner_get_tuner_data, [:ccs_features_tuner_t, :pointer], :ccs_result_t class UserDefinedFeaturesTuner < FeaturesTuner add_property :tuner_data, :value, :ccs_user_defined_features_tuner_get_tuner_data, memoize: true def initialize(handle = nil, retain: false, auto_release: true, - name: "", configuration_space: nil, features_space: nil, objective_space: nil, + name: "", configuration_space: nil, feature_space: nil, objective_space: nil, del: nil, ask: nil, tell: nil, get_optima: nil, get_history: nil, suggest: nil, serialize: nil, deserialize: nil, tuner_data: nil) if handle super(handle, retain: retain, auto_release: auto_release) @@ -281,7 +281,7 @@ def initialize(handle = nil, retain: false, auto_release: true, vector[:serialize] = serializewrapper vector[:deserialize] = deserializewrapper ptr = MemoryPointer::new(:ccs_features_tuner_t) - CCS.error_check CCS.ccs_create_user_defined_features_tuner(name, configuration_space, features_space, objective_space, vector, tuner_data, ptr) + CCS.error_check CCS.ccs_create_user_defined_features_tuner(name, configuration_space, feature_space, objective_space, vector, tuner_data, ptr) handle = ptr.read_ccs_features_tuner_t super(handle, retain: false) CCS.register_vector(handle, [delwrapper, askwrapper, tellwrapper, get_optimawrapper, get_historywrapper, suggestwrapper, serializewrapper, deserializewrapper, tuner_data]) diff --git a/bindings/ruby/test/test_features_space.rb b/bindings/ruby/test/test_feature_space.rb similarity index 74% rename from bindings/ruby/test/test_features_space.rb rename to bindings/ruby/test/test_feature_space.rb index e31e4905..a575896c 100644 --- a/bindings/ruby/test/test_features_space.rb +++ b/bindings/ruby/test/test_feature_space.rb @@ -1,7 +1,7 @@ require 'minitest/autorun' require_relative '../lib/cconfigspace' -class CConfigSpaceTestFeaturesSpace < Minitest::Test +class CConfigSpaceTestFeatureSpace < Minitest::Test def setup CCS.init end @@ -10,8 +10,8 @@ def test_create h1 = CCS::NumericalParameter::Float.new h2 = CCS::NumericalParameter::Float.new h3 = CCS::NumericalParameter::Float.new - cs = CCS::FeaturesSpace::new(name: "space", parameters: [h1, h2, h3]) - assert_equal( :CCS_OBJECT_TYPE_FEATURES_SPACE, cs.object_type ) + cs = CCS::FeatureSpace::new(name: "space", parameters: [h1, h2, h3]) + assert_equal( :CCS_OBJECT_TYPE_FEATURE_SPACE, cs.object_type ) assert_equal( "space", cs.name ) assert_equal( 3, cs.num_parameters ) assert_equal( h1, cs.parameter(0) ) diff --git a/bindings/ruby/test/test_features_tuner.rb b/bindings/ruby/test/test_features_tuner.rb index ebe48527..100e3866 100644 --- a/bindings/ruby/test/test_features_tuner.rb +++ b/bindings/ruby/test/test_features_tuner.rb @@ -18,13 +18,13 @@ def create_tuning_problem os = CCS::ObjectiveSpace::new(name: "ospace", parameters: [v1, v2], objectives: [e1, e2]) f1 = CCS::CategoricalParameter::new(values: [true, false]) - fs = CCS::FeaturesSpace::new(name: "fspace", parameters: [f1]) + fs = CCS::FeatureSpace::new(name: "fspace", parameters: [f1]) [cs, fs, os] end def test_create_random cs, fs, os = create_tuning_problem - t = CCS::RandomFeaturesTuner::new(name: "tuner", configuration_space: cs, features_space: fs, objective_space: os) + t = CCS::RandomFeaturesTuner::new(name: "tuner", configuration_space: cs, feature_space: fs, objective_space: os) t2 = CCS::Object::from_handle(t) assert_equal( t.class, t2.class) assert_equal( "tuner", t.name ) @@ -32,8 +32,8 @@ def test_create_random func = lambda { |(x, y, z)| [(x-2)**2, Math.sin(z+y)] } - features_on = CCS::Features.new(features_space: fs, values: [true]) - features_off = CCS::Features.new(features_space: fs, values: [false]) + features_on = CCS::Features.new(feature_space: fs, values: [true]) + features_off = CCS::Features.new(feature_space: fs, values: [false]) evals = t.ask(features_on, 50).collect { |c| CCS::FeaturesEvaluation::new(objective_space: os, configuration: c, features: features_on, values: func[c.values]) } @@ -127,7 +127,7 @@ def test_user_defined end } cs, fs, os = create_tuning_problem - t = CCS::UserDefinedFeaturesTuner::new(name: "tuner", configuration_space: cs, features_space: fs, objective_space: os, del: del, ask: ask, tell: tell, get_optima: get_optima, get_history: get_history, suggest: suggest, tuner_data: TunerData.new) + t = CCS::UserDefinedFeaturesTuner::new(name: "tuner", configuration_space: cs, feature_space: fs, objective_space: os, del: del, ask: ask, tell: tell, get_optima: get_optima, get_history: get_history, suggest: suggest, tuner_data: TunerData.new) t2 = CCS::Object::from_handle(t) assert_equal( t.class, t2.class) assert_equal( "tuner", t.name ) @@ -135,8 +135,8 @@ def test_user_defined func = lambda { |(x, y, z)| [(x-2)**2, Math.sin(z+y)] } - features_on = CCS::Features.new(features_space: fs, values: [true]) - features_off = CCS::Features.new(features_space: fs, values: [false]) + features_on = CCS::Features.new(feature_space: fs, values: [true]) + features_off = CCS::Features.new(feature_space: fs, values: [false]) evals = t.ask(features_on, 50).collect { |c| CCS::FeaturesEvaluation::new(objective_space: os, configuration: c, features: features_on, values: func[c.values]) } diff --git a/connectors/kokkos/ccs-kokkos-connector.cpp b/connectors/kokkos/ccs-kokkos-connector.cpp index abd97f6c..49e82854 100644 --- a/connectors/kokkos/ccs-kokkos-connector.cpp +++ b/connectors/kokkos/ccs-kokkos-connector.cpp @@ -479,7 +479,7 @@ kokkosp_request_values( std::set regionId; ccs_features_tuner_t tuner; ccs_features_t feat; - ccs_features_space_t features_space; + ccs_feature_space_t feature_space; ccs_configuration_t configuration; ccs_configuration_space_t configuration_space; struct timespec start; @@ -503,7 +503,7 @@ kokkosp_request_values( if (tun == tuners.end()) { ccs_parameter_t *cs_parameters; ccs_configuration_space_t cs; - ccs_features_space_t fs; + ccs_feature_space_t fs; ccs_objective_space_t os; ccs_parameter_t htime; ccs_expression_t expression; @@ -529,7 +529,7 @@ kokkosp_request_values( for (size_t i = 0; i < numContextVariables; i++) cs_parameters[i] = parameters[contextValues[i].type_id]; - CCS_CHECK(ccs_create_features_space( + CCS_CHECK(ccs_create_feature_space( ("fs (region: " + std::to_string(regionCounter) + ")").c_str(), numContextVariables, cs_parameters, &fs)); delete[] cs_parameters; @@ -579,18 +579,18 @@ kokkosp_request_values( else // else propagate unconverged status convergence_stack.push(false); - CCS_CHECK(ccs_features_tuner_get_features_space(tuner, &features_space)); + CCS_CHECK(ccs_features_tuner_get_feature_space(tuner, &feature_space)); { ccs_datum_t *values = new ccs_datum_t[numContextVariables]; for (size_t i = 0; i < numContextVariables; i++) { size_t indx; CCS_CHECK(ccs_context_get_parameter_index( - (ccs_context_t)features_space, + (ccs_context_t)feature_space, features[contextValues[i].type_id], NULL, &indx)); extract_value(contextValues + i, values + indx); } CCS_CHECK(ccs_create_features( - features_space, numContextVariables, values, &feat)); + feature_space, numContextVariables, values, &feat)); delete[] values; } diff --git a/include/Makefile.am b/include/Makefile.am index 0c199a5a..3dd4ab9f 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -10,7 +10,7 @@ include_ccs_HEADERS = \ cconfigspace/context.h \ cconfigspace/configuration_space.h \ cconfigspace/distribution_space.h \ - cconfigspace/features_space.h \ + cconfigspace/feature_space.h \ cconfigspace/parameter.h \ cconfigspace/expression.h \ cconfigspace/binding.h \ diff --git a/include/cconfigspace.h b/include/cconfigspace.h index e08a50ed..e97c92d0 100644 --- a/include/cconfigspace.h +++ b/include/cconfigspace.h @@ -16,7 +16,7 @@ #include "cconfigspace/configuration_space.h" #include "cconfigspace/distribution_space.h" #include "cconfigspace/configuration.h" -#include "cconfigspace/features_space.h" +#include "cconfigspace/feature_space.h" #include "cconfigspace/features.h" #include "cconfigspace/objective_space.h" #include "cconfigspace/evaluation.h" diff --git a/include/cconfigspace/base.h b/include/cconfigspace/base.h index f3e05606..7722c1e0 100644 --- a/include/cconfigspace/base.h +++ b/include/cconfigspace/base.h @@ -118,9 +118,9 @@ typedef struct _ccs_binding_s *ccs_binding_t; */ typedef struct _ccs_configuration_s *ccs_configuration_t; /** - * An opaque type defining a CCS features space. + * An opaque type defining a CCS feature space. */ -typedef struct _ccs_features_space_s *ccs_features_space_t; +typedef struct _ccs_feature_space_s *ccs_feature_space_t; /** * An opaque type defining a CCS features. */ @@ -289,8 +289,8 @@ enum ccs_object_type_e { CCS_OBJECT_TYPE_EVALUATION, /** A tuner */ CCS_OBJECT_TYPE_TUNER, - /** A features space */ - CCS_OBJECT_TYPE_FEATURES_SPACE, + /** A feature space */ + CCS_OBJECT_TYPE_FEATURE_SPACE, /** A set of features */ CCS_OBJECT_TYPE_FEATURES, /** An evaluation of a configuration given specific features */ diff --git a/include/cconfigspace/features_space.h b/include/cconfigspace/feature_space.h similarity index 53% rename from include/cconfigspace/features_space.h rename to include/cconfigspace/feature_space.h index 8921fcfc..32cf9fce 100644 --- a/include/cconfigspace/features_space.h +++ b/include/cconfigspace/feature_space.h @@ -1,44 +1,44 @@ -#ifndef _CCS_FEATURES_SPACE -#define _CCS_FEATURES_SPACE +#ifndef _CCS_FEATURE_SPACE +#define _CCS_FEATURE_SPACE #ifdef __cplusplus extern "C" { #endif /** - * @file features_space.h - * A features space is a context (see context.h) defining a set of - * parameters. + * @file feature_space.h + * A feature space is a context (see context.h) defining a set of + * features represented using CCS parameters (see parameter.h). */ /** - * Create a new features space. + * Create a new feature space. * @param[in] name pointer to a string that will be copied internally - * @param[out] features_space_ret a pointer to the variable that will hold - * the newly created features space + * @param[out] feature_space_ret a pointer to the variable that will hold + * the newly created feature space * @return #CCS_RESULT_SUCCESS on success * @return #CCS_RESULT_ERROR_INVALID_VALUE if \p name is NULL; or if \p - * features_space_ret is NULL; or if \p parameters is NULL; or if \p + * feature_space_ret is NULL; or if \p parameters is NULL; or if \p * num_parameters is NULL * @return #CCS_RESULT_ERROR_INVALID_OBJECT if a parameter is not a valid CCS * parameter * @return #CCS_RESULT_ERROR_INVALID_PARAMETER if a parameter appears more than * once in \p parameters; or if two or more parameters share the same name * @return #CCS_RESULT_ERROR_OUT_OF_MEMORY if there was a lack of memory to - * allocate the new features space + * allocate the new feature space * @remarks * This function is thread-safe */ extern ccs_result_t -ccs_create_features_space( - const char *name, - size_t num_parameters, - ccs_parameter_t *parameters, - ccs_features_space_t *features_space_ret); +ccs_create_feature_space( + const char *name, + size_t num_parameters, + ccs_parameter_t *parameters, + ccs_feature_space_t *feature_space_ret); /** - * Check that a features is a valid in a features space. - * @param[in] features_space + * Check that a features is a valid in a feature space. + * @param[in] feature_space * @param[in] features * @param[out] is_valid_ret a pointer to a variable that will hold the result * of the check. Result will be #CCS_TRUE if the @@ -46,22 +46,22 @@ ccs_create_features_space( * an parameter value is not a valid value * for this parameter; * @return #CCS_RESULT_SUCCESS on success - * @return #CCS_RESULT_ERROR_INVALID_OBJECT if \p features_space is not a valid - * CCS features space; or if \p features is not a valid CCS features + * @return #CCS_RESULT_ERROR_INVALID_OBJECT if \p feature_space is not a valid + * CCS feature space; or if \p features is not a valid CCS features * @return #CCS_RESULT_ERROR_INVALID_FEATURES if \p features is not associated - * to the features space; or if the number of values contained in \p features is - * not equal to the number of parameters in the features space + * to the feature space; or if the number of values contained in \p features is + * not equal to the number of parameters in the feature space * @remarks * This function is thread-safe */ extern ccs_result_t -ccs_features_space_check_features( - ccs_features_space_t features_space, - ccs_features_t features, - ccs_bool_t *is_valid_ret); +ccs_feature_space_check_features( + ccs_feature_space_t feature_space, + ccs_features_t features, + ccs_bool_t *is_valid_ret); #ifdef __cplusplus } #endif -#endif //_CCS_FEATURES_SPACE +#endif //_CCS_FEATURE_SPACE diff --git a/include/cconfigspace/features.h b/include/cconfigspace/features.h index 6c01dcd7..9f8e6533 100644 --- a/include/cconfigspace/features.h +++ b/include/cconfigspace/features.h @@ -7,14 +7,14 @@ extern "C" { /** * @file features.h - * A features is a binding (see binding.h) over a features space (see - * features_space.h). + * A features is a binding (see binding.h) over a feature space (see + * feature_space.h). */ /** - * Create a new instance of a features on a given features space. If no values + * Create a new instance of a features on a given feature space. If no values * are provided the values will be initialized to #CCS_DATA_TYPE_NONE. - * @param[in] features_space + * @param[in] feature_space * @param[in] num_values the number of provided values to initialize the * features instance * @param[in] values an optional array of values to initialize the features @@ -22,10 +22,10 @@ extern "C" { * created features * @return #CCS_RESULT_SUCCESS on success * @return #CCS_RESULT_ERROR_INVALID_OBJECT if \p features is not a valid CCS - * features space + * feature space * @return #CCS_RESULT_ERROR_INVALID_VALUE if \p features_ret is NULL; or if \p * values is NULL and \p num_values is greater than 0; or if the number of - * values provided is not to the number of parameters in the features space + * values provided is not to the number of parameters in the feature space * @return #CCS_RESULT_ERROR_OUT_OF_MEMORY if there was a lack of memory to * allocate the new features * @remarks @@ -33,30 +33,30 @@ extern "C" { */ extern ccs_result_t ccs_create_features( - ccs_features_space_t features_space, - size_t num_values, - ccs_datum_t *values, - ccs_features_t *features_ret); + ccs_feature_space_t feature_space, + size_t num_values, + ccs_datum_t *values, + ccs_features_t *features_ret); /** - * Get the associated features space. + * Get the associated feature space. * @param[in] features - * @param[out] features_space_ret a pointer to the variable that will - * contain the features space + * @param[out] feature_space_ret a pointer to the variable that will + * contain the feature space * @return #CCS_RESULT_SUCCESS on success * @return #CCS_RESULT_ERROR_INVALID_OBJECT if \p features is not a valid CCS * features - * @return #CCS_RESULT_ERROR_INVALID_VALUE if \p features_space_ret is NULL + * @return #CCS_RESULT_ERROR_INVALID_VALUE if \p feature_space_ret is NULL * @remarks * This function is thread-safe */ extern ccs_result_t -ccs_features_get_features_space( - ccs_features_t features, - ccs_features_space_t *features_space_ret); +ccs_features_get_feature_space( + ccs_features_t features, + ccs_feature_space_t *feature_space_ret); /** - * Check that the features is a valid features for the features space. + * Check that the features is a valid features for the feature space. * @param[in] features * @param[out] is_valid_ret a pointer to a variable that will hold the result * of the check. Result will be #CCS_TRUE if the diff --git a/include/cconfigspace/features_tuner.h b/include/cconfigspace/features_tuner.h index 9dbea43a..71273573 100644 --- a/include/cconfigspace/features_tuner.h +++ b/include/cconfigspace/features_tuner.h @@ -9,7 +9,7 @@ extern "C" { * @file features_tuner.h * A CCS features tuner defines an ask and tell interface to optimize an * objective space (see objective_space.h) given a configuration spaces (see - * configuration_space.h) and a features space (see features_space.h). The tuner + * configuration_space.h) and a feature space (see feature_space.h). The tuner * will propose configurations (see configuration.h) and the user will return * features evaluations (see features_evaluation.h). */ @@ -102,21 +102,21 @@ ccs_features_tuner_get_objective_space( ccs_objective_space_t *objective_space_ret); /** - * Get the associated features space. + * Get the associated feature space. * @param[in] features_tuner - * @param[out] features_space_ret a pointer to the variable that will - * contain the features space + * @param[out] feature_space_ret a pointer to the variable that will + * contain the feature space * @return #CCS_RESULT_SUCCESS on success * @return #CCS_RESULT_ERROR_INVALID_OBJECT if \p features_tuner is not a valid * CCS features tuner - * @return #CCS_RESULT_ERROR_INVALID_VALUE if \p features_space_ret is NULL + * @return #CCS_RESULT_ERROR_INVALID_VALUE if \p feature_space_ret is NULL * @remarks * This function is thread-safe */ extern ccs_result_t -ccs_features_tuner_get_features_space( - ccs_features_tuner_t features_tuner, - ccs_features_space_t *features_space_ret); +ccs_features_tuner_get_feature_space( + ccs_features_tuner_t features_tuner, + ccs_feature_space_t *feature_space_ret); /** * Ask a features tuner for a set of configurations to evaluate given some @@ -139,7 +139,7 @@ ccs_features_tuner_get_features_space( * @return #CCS_RESULT_ERROR_INVALID_OBJECT if \p features_tuner is not a valid * CCS features tuner; or if \p features is not a valid CCS features * @return #CCS_RESULT_ERROR_INVALID_FEATURES if \p features is not a valid CCS - * features for the tuner features space + * features for the tuner feature space * @return #CCS_RESULT_ERROR_INVALID_VALUE if \p configurations is NULL and \p * num_configurations is greater than 0; or if \p configurations and \p * num_configurations_ret are both NULL @@ -195,7 +195,7 @@ ccs_features_tuner_tell( * @return #CCS_RESULT_ERROR_INVALID_OBJECT if \p features_tuner is not a valid * CCS features tuner; or if \p features is not a valid CCS features * @return #CCS_RESULT_ERROR_INVALID_FEATURES if \p features is not a valid CCS - * features for the tuner features space + * features for the tuner feature space * @return #CCS_RESULT_ERROR_INVALID_VALUE if \p configuration is NULL * @return #CCS_RESULT_ERROR_UNSUPPORTED_OPERATION if the features tuner does * not support the suggest interface @@ -228,7 +228,7 @@ ccs_features_tuner_suggest( * CCS features tuner; or if \p features is not NULL and \p features is not a * valid CCS features * @return #CCS_RESULT_ERROR_INVALID_FEATURES if \p features is not a valid CCS - * features for the features tuner features space + * features for the features tuner feature space * @return #CCS_RESULT_ERROR_INVALID_VALUE if \p evaluations is NULL and * num_evaluations is greater than 0; or if \p evaluations is NULL and \p * num_evaluations_ret is NULL @@ -260,7 +260,7 @@ ccs_features_tuner_get_optima( * CCS features tuner or if \p features is not NULL and \p features is not a * valid CCS features * @return #CCS_RESULT_ERROR_INVALID_FEATURES if \p features is not a valid CCS - * features for the features tuner features space + * features for the features tuner feature space * @return #CCS_RESULT_ERROR_INVALID_VALUE if \p evaluations is NULL and * num_evaluations is greater than 0; or if \p evaluations is NULL and \p * num_evaluations_ret is NULL @@ -281,14 +281,14 @@ ccs_features_tuner_get_history( * developing interfaces. * @param[in] name the name of the features tuner * @param[in] configuration_space the configuration space to explore - * @param[in] features_space the features space + * @param[in] feature_space the feature space * @param[in] objective_space the objective space to potimize * @param[out] features_tuner_ret a pointer to the variable that will contain * the newly created features tuner * @return #CCS_RESULT_SUCCESS on success * @return #CCS_RESULT_ERROR_INVALID_OBJECT if \p configuration_space is not a * valid CCS configuration space; or if \p objective_space is not a valid CCS - * objective space; or if \p features_space is not a valid CCS features space + * objective space; or if \p feature_space is not a valid CCS feature space * @return #CCS_RESULT_ERROR_INVALID_VALUE if \p name is NULL; or if \p features * tuner_ret is NULL * @return #CCS_RESULT_ERROR_OUT_OF_MEMORY if there was not enough memory to @@ -300,7 +300,7 @@ extern ccs_result_t ccs_create_random_features_tuner( const char *name, ccs_configuration_space_t configuration_space, - ccs_features_space_t features_space, + ccs_feature_space_t feature_space, ccs_objective_space_t objective_space, ccs_features_tuner_t *features_tuner_ret); @@ -393,7 +393,7 @@ typedef struct ccs_user_defined_features_tuner_vector_s * Create a new user defined features tuner. * @param[in] name the name of the features tuner * @param[in] configuration_space the configuration space to explore - * @param[in] features_space the features space + * @param[in] feature_space the feature space * @param[in] objective_space the objective space to optimize * @param[in] vector the vector of callbacks implementing the features tuner * interface @@ -404,7 +404,7 @@ typedef struct ccs_user_defined_features_tuner_vector_s * @return #CCS_RESULT_SUCCESS on success * @return #CCS_RESULT_ERROR_INVALID_OBJECT if \p configuration_space is not a * valid CCS configuration space; or if \p objective_space is not a valid CCS - * objective space; or if \p features_space is not a valid CCS features space + * objective space; or if \p feature_space is not a valid CCS feature space * @return #CCS_RESULT_ERROR_INVALID_VALUE if \p name is NULL; or if \p * features_tuner_ret is NULL; or if \p vector is NULL; or if any interface * pointer except suggest is NULL @@ -417,7 +417,7 @@ extern ccs_result_t ccs_create_user_defined_features_tuner( const char *name, ccs_configuration_space_t configuration_space, - ccs_features_space_t features_space, + ccs_feature_space_t feature_space, ccs_objective_space_t objective_space, ccs_user_defined_features_tuner_vector_t *vector, void *tuner_data, diff --git a/src/Makefile.am b/src/Makefile.am index 9cd2b778..c3c66260 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -86,9 +86,9 @@ libcconfigspace_la_SOURCES = \ tuner_deserialize.h \ tuner_random.c \ tuner_user_defined.c \ - features_space.c \ - features_space_internal.h \ - features_space_deserialize.h \ + feature_space.c \ + feature_space_internal.h \ + feature_space_deserialize.h \ features.c \ features_internal.h \ features_deserialize.h \ diff --git a/src/cconfigspace.c b/src/cconfigspace.c index 2808684a..5509cc53 100644 --- a/src/cconfigspace.c +++ b/src/cconfigspace.c @@ -565,7 +565,7 @@ ccs_object_serialize( #include "distribution_deserialize.h" #include "parameter_deserialize.h" #include "expression_deserialize.h" -#include "features_space_deserialize.h" +#include "feature_space_deserialize.h" #include "configuration_space_deserialize.h" #include "distribution_space_deserialize.h" #include "objective_space_deserialize.h" @@ -665,9 +665,9 @@ _ccs_object_deserialize_with_opts( (ccs_expression_t *)object_ret, format, version, buffer_size, buffer, opts)); break; - case CCS_OBJECT_TYPE_FEATURES_SPACE: - CCS_VALIDATE(_ccs_features_space_deserialize( - (ccs_features_space_t *)object_ret, format, + case CCS_OBJECT_TYPE_FEATURE_SPACE: + CCS_VALIDATE(_ccs_feature_space_deserialize( + (ccs_feature_space_t *)object_ret, format, version, buffer_size, buffer, opts)); break; case CCS_OBJECT_TYPE_CONFIGURATION_SPACE: diff --git a/src/cconfigspace_internal.h b/src/cconfigspace_internal.h index ace49e0d..d1c0c746 100644 --- a/src/cconfigspace_internal.h +++ b/src/cconfigspace_internal.h @@ -243,7 +243,7 @@ _ccs_do_nothing(void) ((_ccs_object_template_t *)(c))->obj.type != \ CCS_OBJECT_TYPE_OBJECTIVE_SPACE && \ ((_ccs_object_template_t *)(c))->obj.type != \ - CCS_OBJECT_TYPE_FEATURES_SPACE), \ + CCS_OBJECT_TYPE_FEATURE_SPACE), \ CCS_RESULT_ERROR_INVALID_OBJECT, \ "Invalid CCS context '%s' == %p supplied", #c, c) diff --git a/src/features_space.c b/src/feature_space.c similarity index 60% rename from src/features_space.c rename to src/feature_space.c index 0eb695cd..11f30726 100644 --- a/src/features_space.c +++ b/src/feature_space.c @@ -1,26 +1,26 @@ #include "cconfigspace_internal.h" -#include "features_space_internal.h" +#include "feature_space_internal.h" #include "features_internal.h" #include "utlist.h" static ccs_result_t -_ccs_features_space_del(ccs_object_t object) +_ccs_feature_space_del(ccs_object_t object) { - ccs_features_space_t features_space = (ccs_features_space_t)object; - size_t num_parameters = features_space->data->num_parameters; - ccs_parameter_t *parameters = features_space->data->parameters; + ccs_feature_space_t feature_space = (ccs_feature_space_t)object; + size_t num_parameters = feature_space->data->num_parameters; + ccs_parameter_t *parameters = feature_space->data->parameters; for (size_t i = 0; i < num_parameters; i++) if (parameters[i]) ccs_release_object(parameters[i]); - HASH_CLEAR(hh_name, features_space->data->name_hash); - HASH_CLEAR(hh_handle, features_space->data->handle_hash); + HASH_CLEAR(hh_name, feature_space->data->name_hash); + HASH_CLEAR(hh_handle, feature_space->data->handle_hash); return CCS_RESULT_SUCCESS; } static ccs_result_t -_ccs_features_space_serialize_size( +_ccs_feature_space_serialize_size( ccs_object_t object, ccs_serialize_format_t format, size_t *cum_size, @@ -42,7 +42,7 @@ _ccs_features_space_serialize_size( } static ccs_result_t -_ccs_features_space_serialize( +_ccs_feature_space_serialize( ccs_object_t object, ccs_serialize_format_t format, size_t *buffer_size, @@ -64,53 +64,53 @@ _ccs_features_space_serialize( return CCS_RESULT_SUCCESS; } -static _ccs_features_space_ops_t _features_space_ops = { - {{&_ccs_features_space_del, &_ccs_features_space_serialize_size, - &_ccs_features_space_serialize}}}; +static _ccs_feature_space_ops_t _feature_space_ops = { + {{&_ccs_feature_space_del, &_ccs_feature_space_serialize_size, + &_ccs_feature_space_serialize}}}; static ccs_result_t -_ccs_features_space_add_parameters( - ccs_features_space_t features_space, - size_t num_parameters, - ccs_parameter_t *parameters) +_ccs_feature_space_add_parameters( + ccs_feature_space_t feature_space, + size_t num_parameters, + ccs_parameter_t *parameters) { for (size_t i = 0; i < num_parameters; i++) CCS_VALIDATE(_ccs_context_add_parameter( - (ccs_context_t)features_space, parameters[i], i)); + (ccs_context_t)feature_space, parameters[i], i)); return CCS_RESULT_SUCCESS; } ccs_result_t -ccs_create_features_space( - const char *name, - size_t num_parameters, - ccs_parameter_t *parameters, - ccs_features_space_t *features_space_ret) +ccs_create_feature_space( + const char *name, + size_t num_parameters, + ccs_parameter_t *parameters, + ccs_feature_space_t *feature_space_ret) { ccs_result_t err; CCS_CHECK_PTR(name); - CCS_CHECK_PTR(features_space_ret); + CCS_CHECK_PTR(feature_space_ret); CCS_CHECK_ARY(num_parameters, parameters); for (size_t i = 0; i < num_parameters; i++) CCS_CHECK_OBJ(parameters[i], CCS_OBJECT_TYPE_PARAMETER); uintptr_t mem = (uintptr_t)calloc( 1, - sizeof(struct _ccs_features_space_s) + - sizeof(struct _ccs_features_space_data_s) + + sizeof(struct _ccs_feature_space_s) + + sizeof(struct _ccs_feature_space_data_s) + sizeof(ccs_parameter_t) * num_parameters + sizeof(_ccs_parameter_index_hash_t) * num_parameters + strlen(name) + 1); CCS_REFUTE(!mem, CCS_RESULT_ERROR_OUT_OF_MEMORY); - uintptr_t mem_orig = mem; + uintptr_t mem_orig = mem; - ccs_features_space_t feat_space = (ccs_features_space_t)mem; - mem += sizeof(struct _ccs_features_space_s); + ccs_feature_space_t feat_space = (ccs_feature_space_t)mem; + mem += sizeof(struct _ccs_feature_space_s); _ccs_object_init( - &(feat_space->obj), CCS_OBJECT_TYPE_FEATURES_SPACE, - (_ccs_object_ops_t *)&_features_space_ops); - feat_space->data = (struct _ccs_features_space_data_s *)mem; - mem += sizeof(struct _ccs_features_space_data_s); + &(feat_space->obj), CCS_OBJECT_TYPE_FEATURE_SPACE, + (_ccs_object_ops_t *)&_feature_space_ops); + feat_space->data = (struct _ccs_feature_space_data_s *)mem; + mem += sizeof(struct _ccs_feature_space_data_s); feat_space->data->parameters = (ccs_parameter_t *)mem; mem += sizeof(ccs_parameter_t) * num_parameters; feat_space->data->hash_elems = (_ccs_parameter_index_hash_t *)mem; @@ -120,13 +120,13 @@ ccs_create_features_space( strcpy((char *)(feat_space->data->name), name); CCS_VALIDATE_ERR_GOTO( err, - _ccs_features_space_add_parameters( + _ccs_feature_space_add_parameters( feat_space, num_parameters, parameters), errparams); - *features_space_ret = feat_space; + *feature_space_ret = feat_space; return CCS_RESULT_SUCCESS; errparams: - _ccs_features_space_del(feat_space); + _ccs_feature_space_del(feat_space); _ccs_object_deinit(&(feat_space->obj)); free((void *)mem_orig); return err; @@ -134,12 +134,12 @@ ccs_create_features_space( static inline ccs_result_t _check_features( - ccs_features_space_t features_space, - ccs_features_t features, - ccs_bool_t *is_valid_ret) + ccs_feature_space_t feature_space, + ccs_features_t features, + ccs_bool_t *is_valid_ret) { - ccs_parameter_t *parameters = features_space->data->parameters; - size_t num_parameters = features_space->data->num_parameters; + ccs_parameter_t *parameters = feature_space->data->parameters; + size_t num_parameters = feature_space->data->num_parameters; ccs_datum_t *values = features->data->values; *is_valid_ret = CCS_TRUE; for (size_t i = 0; i < num_parameters; i++) { @@ -152,16 +152,16 @@ _check_features( } ccs_result_t -ccs_features_space_check_features( - ccs_features_space_t features_space, - ccs_features_t features, - ccs_bool_t *is_valid_ret) +ccs_feature_space_check_features( + ccs_feature_space_t feature_space, + ccs_features_t features, + ccs_bool_t *is_valid_ret) { - CCS_CHECK_OBJ(features_space, CCS_OBJECT_TYPE_FEATURES_SPACE); + CCS_CHECK_OBJ(feature_space, CCS_OBJECT_TYPE_FEATURE_SPACE); CCS_CHECK_OBJ(features, CCS_OBJECT_TYPE_FEATURES); CCS_REFUTE( - features->data->features_space != features_space, + features->data->feature_space != feature_space, CCS_RESULT_ERROR_INVALID_FEATURES); - CCS_VALIDATE(_check_features(features_space, features, is_valid_ret)); + CCS_VALIDATE(_check_features(feature_space, features, is_valid_ret)); return CCS_RESULT_SUCCESS; } diff --git a/src/features_space_deserialize.h b/src/feature_space_deserialize.h similarity index 70% rename from src/features_space_deserialize.h rename to src/feature_space_deserialize.h index 141fed55..dbfb2b0a 100644 --- a/src/features_space_deserialize.h +++ b/src/feature_space_deserialize.h @@ -1,10 +1,10 @@ -#ifndef _FEATURES_SPACE_DESERIALIZE_H -#define _FEATURES_SPACE_DESERIALIZE_H +#ifndef _FEATURE_SPACE_DESERIALIZE_H +#define _FEATURE_SPACE_DESERIALIZE_H #include "context_deserialize.h" static inline ccs_result_t -_ccs_deserialize_bin_features_space( - ccs_features_space_t *features_space_ret, +_ccs_deserialize_bin_feature_space( + ccs_feature_space_t *feature_space_ret, uint32_t version, size_t *buffer_size, const char **buffer, @@ -19,7 +19,7 @@ _ccs_deserialize_bin_features_space( CCS_VALIDATE(_ccs_deserialize_bin_ccs_object_internal( &obj, buffer_size, buffer, &handle)); CCS_REFUTE( - obj.type != CCS_OBJECT_TYPE_FEATURES_SPACE, + obj.type != CCS_OBJECT_TYPE_FEATURE_SPACE, CCS_RESULT_ERROR_INVALID_TYPE); _ccs_context_data_mock_t data; @@ -30,21 +30,21 @@ _ccs_deserialize_bin_features_space( end); CCS_VALIDATE_ERR_GOTO( res, - ccs_create_features_space( + ccs_create_feature_space( data.name, data.num_parameters, data.parameters, - features_space_ret), + feature_space_ret), end); if (opts && opts->map_values && opts->handle_map) CCS_VALIDATE_ERR_GOTO( res, _ccs_object_handle_check_add( opts->handle_map, handle, - (ccs_object_t)*features_space_ret), - err_features_space); + (ccs_object_t)*feature_space_ret), + err_feature_space); goto end; -err_features_space: - ccs_release_object(*features_space_ret); - *features_space_ret = NULL; +err_feature_space: + ccs_release_object(*feature_space_ret); + *feature_space_ret = NULL; end: if (data.parameters) { for (size_t i = 0; i < data.num_parameters; i++) @@ -56,8 +56,8 @@ _ccs_deserialize_bin_features_space( } static ccs_result_t -_ccs_features_space_deserialize( - ccs_features_space_t *features_space_ret, +_ccs_feature_space_deserialize( + ccs_feature_space_t *feature_space_ret, ccs_serialize_format_t format, uint32_t version, size_t *buffer_size, @@ -66,9 +66,8 @@ _ccs_features_space_deserialize( { switch (format) { case CCS_SERIALIZE_FORMAT_BINARY: - CCS_VALIDATE(_ccs_deserialize_bin_features_space( - features_space_ret, version, buffer_size, buffer, - opts)); + CCS_VALIDATE(_ccs_deserialize_bin_feature_space( + feature_space_ret, version, buffer_size, buffer, opts)); break; default: CCS_RAISE( @@ -76,9 +75,9 @@ _ccs_features_space_deserialize( "Unsupported serialization format: %d", format); } CCS_VALIDATE(_ccs_object_deserialize_user_data( - (ccs_object_t)*features_space_ret, format, version, buffer_size, + (ccs_object_t)*feature_space_ret, format, version, buffer_size, buffer, opts)); return CCS_RESULT_SUCCESS; } -#endif //_FEATURES_SPACE_DESERIALIZE_H +#endif //_FEATURE_SPACE_DESERIALIZE_H diff --git a/src/feature_space_internal.h b/src/feature_space_internal.h new file mode 100644 index 00000000..ee99bdd1 --- /dev/null +++ b/src/feature_space_internal.h @@ -0,0 +1,27 @@ +#ifndef _FEATURE_SPACE_INTERNAL_H +#define _FEATURE_SPACE_INTERNAL_H +#include "context_internal.h" + +struct _ccs_feature_space_data_s; +typedef struct _ccs_feature_space_data_s _ccs_feature_space_data_t; + +struct _ccs_feature_space_ops_s { + _ccs_context_ops_t ops; +}; +typedef struct _ccs_feature_space_ops_s _ccs_feature_space_ops_t; + +struct _ccs_feature_space_s { + _ccs_object_internal_t obj; + _ccs_feature_space_data_t *data; +}; + +struct _ccs_feature_space_data_s { + const char *name; + size_t num_parameters; + ccs_parameter_t *parameters; + _ccs_parameter_index_hash_t *hash_elems; + _ccs_parameter_index_hash_t *name_hash; + _ccs_parameter_index_hash_t *handle_hash; +}; + +#endif //_FEATURE_SPACE_INTERNAL_H diff --git a/src/features.c b/src/features.c index 58579477..7cb6e973 100644 --- a/src/features.c +++ b/src/features.c @@ -1,6 +1,6 @@ #include "cconfigspace_internal.h" #include "features_internal.h" -#include "features_space_internal.h" +#include "feature_space_internal.h" #include "datum_hash.h" #include @@ -8,7 +8,7 @@ static ccs_result_t _ccs_features_del(ccs_object_t object) { ccs_features_t features = (ccs_features_t)object; - ccs_release_object(features->data->features_space); + ccs_release_object(features->data->feature_space); return CCS_RESULT_SUCCESS; } @@ -80,16 +80,16 @@ static _ccs_features_ops_t _features_ops = { ccs_result_t ccs_create_features( - ccs_features_space_t features_space, - size_t num_values, - ccs_datum_t *values, - ccs_features_t *features_ret) + ccs_feature_space_t feature_space, + size_t num_values, + ccs_datum_t *values, + ccs_features_t *features_ret) { - CCS_CHECK_OBJ(features_space, CCS_OBJECT_TYPE_FEATURES_SPACE); + CCS_CHECK_OBJ(feature_space, CCS_OBJECT_TYPE_FEATURE_SPACE); CCS_CHECK_PTR(features_ret); CCS_CHECK_ARY(num_values, values); ccs_result_t err; - size_t num_parameters = features_space->data->num_parameters; + size_t num_parameters = feature_space->data->num_parameters; CCS_REFUTE( values && num_parameters != num_values, CCS_RESULT_ERROR_INVALID_VALUE); @@ -98,16 +98,16 @@ ccs_create_features( sizeof(struct _ccs_features_data_s) + num_parameters * sizeof(ccs_datum_t)); CCS_REFUTE(!mem, CCS_RESULT_ERROR_OUT_OF_MEMORY); - CCS_VALIDATE_ERR_GOTO(err, ccs_retain_object(features_space), errmem); + CCS_VALIDATE_ERR_GOTO(err, ccs_retain_object(feature_space), errmem); ccs_features_t feat; feat = (ccs_features_t)mem; _ccs_object_init( &(feat->obj), CCS_OBJECT_TYPE_FEATURES, (_ccs_object_ops_t *)&_features_ops); - feat->data = (struct _ccs_features_data_s + feat->data = (struct _ccs_features_data_s *)(mem + sizeof(struct _ccs_features_s)); - feat->data->num_values = num_parameters; - feat->data->features_space = features_space; + feat->data->num_values = num_parameters; + feat->data->feature_space = feature_space; feat->data->values = (ccs_datum_t *)(mem + sizeof(struct _ccs_features_s) + sizeof(struct _ccs_features_data_s)); @@ -119,8 +119,8 @@ ccs_create_features( CCS_VALIDATE_ERR_GOTO( err, ccs_context_validate_value( - (ccs_context_t)features_space, - i, values[i], + (ccs_context_t)feature_space, i, + values[i], feat->data->values + i), errfs); } @@ -128,20 +128,20 @@ ccs_create_features( return CCS_RESULT_SUCCESS; errfs: _ccs_object_deinit(&(feat->obj)); - ccs_release_object(features_space); + ccs_release_object(feature_space); errmem: free((void *)mem); return err; } ccs_result_t -ccs_features_get_features_space( - ccs_features_t features, - ccs_features_space_t *features_space_ret) +ccs_features_get_feature_space( + ccs_features_t features, + ccs_feature_space_t *feature_space_ret) { CCS_CHECK_OBJ(features, CCS_OBJECT_TYPE_FEATURES); CCS_VALIDATE(_ccs_binding_get_context( - (ccs_binding_t)features, (ccs_context_t *)features_space_ret)); + (ccs_binding_t)features, (ccs_context_t *)feature_space_ret)); return CCS_RESULT_SUCCESS; } @@ -149,7 +149,7 @@ ccs_result_t ccs_features_check(ccs_features_t features, ccs_bool_t *is_valid_ret) { CCS_CHECK_OBJ(features, CCS_OBJECT_TYPE_FEATURES); - CCS_VALIDATE(ccs_features_space_check_features( - features->data->features_space, features, is_valid_ret)); + CCS_VALIDATE(ccs_feature_space_check_features( + features->data->feature_space, features, is_valid_ret)); return CCS_RESULT_SUCCESS; } diff --git a/src/features_deserialize.h b/src/features_deserialize.h index 5066f06f..271334fe 100644 --- a/src/features_deserialize.h +++ b/src/features_deserialize.h @@ -15,7 +15,7 @@ _ccs_deserialize_bin_features( _ccs_object_internal_t obj; ccs_object_t handle; ccs_datum_t d; - ccs_features_space_t cs; + ccs_feature_space_t cs; ccs_result_t res = CCS_RESULT_SUCCESS; CCS_VALIDATE(_ccs_deserialize_bin_ccs_object_internal( &obj, buffer_size, buffer, &handle)); @@ -37,7 +37,7 @@ _ccs_deserialize_bin_features( CCS_REFUTE_ERR_GOTO( res, d.type != CCS_DATA_TYPE_OBJECT, CCS_RESULT_ERROR_INVALID_HANDLE, end); - cs = (ccs_features_space_t)(d.value.o); + cs = (ccs_feature_space_t)(d.value.o); CCS_VALIDATE_ERR_GOTO( res, diff --git a/src/features_internal.h b/src/features_internal.h index 1ea73122..d37ddda2 100644 --- a/src/features_internal.h +++ b/src/features_internal.h @@ -23,9 +23,9 @@ struct _ccs_features_s { }; struct _ccs_features_data_s { - ccs_features_space_t features_space; - size_t num_values; - ccs_datum_t *values; + ccs_feature_space_t feature_space; + size_t num_values; + ccs_datum_t *values; }; #endif //_FEATURES_INTERNAL_H diff --git a/src/features_space_internal.h b/src/features_space_internal.h deleted file mode 100644 index c723e2d8..00000000 --- a/src/features_space_internal.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _FEATURES_SPACE_INTERNAL_H -#define _FEATURES_SPACE_INTERNAL_H -#include "context_internal.h" - -struct _ccs_features_space_data_s; -typedef struct _ccs_features_space_data_s _ccs_features_space_data_t; - -struct _ccs_features_space_ops_s { - _ccs_context_ops_t ops; -}; -typedef struct _ccs_features_space_ops_s _ccs_features_space_ops_t; - -struct _ccs_features_space_s { - _ccs_object_internal_t obj; - _ccs_features_space_data_t *data; -}; - -struct _ccs_features_space_data_s { - const char *name; - size_t num_parameters; - ccs_parameter_t *parameters; - _ccs_parameter_index_hash_t *hash_elems; - _ccs_parameter_index_hash_t *name_hash; - _ccs_parameter_index_hash_t *handle_hash; -}; - -#endif //_FEATURES_SPACE_INTERNAL_H diff --git a/src/features_tuner.c b/src/features_tuner.c index 0d82d9b1..6a0db096 100644 --- a/src/features_tuner.c +++ b/src/features_tuner.c @@ -58,15 +58,15 @@ ccs_features_tuner_get_objective_space( } ccs_result_t -ccs_features_tuner_get_features_space( - ccs_features_tuner_t tuner, - ccs_features_space_t *features_space_ret) +ccs_features_tuner_get_feature_space( + ccs_features_tuner_t tuner, + ccs_feature_space_t *feature_space_ret) { CCS_CHECK_OBJ(tuner, CCS_OBJECT_TYPE_FEATURES_TUNER); - CCS_CHECK_PTR(features_space_ret); + CCS_CHECK_PTR(feature_space_ret); _ccs_features_tuner_common_data_t *d = (_ccs_features_tuner_common_data_t *)tuner->data; - *features_space_ret = d->features_space; + *feature_space_ret = d->feature_space; return CCS_RESULT_SUCCESS; } @@ -87,8 +87,8 @@ ccs_features_tuner_ask( _ccs_features_tuner_common_data_t *d = (_ccs_features_tuner_common_data_t *)tuner->data; ccs_bool_t valid; - CCS_VALIDATE(ccs_features_space_check_features( - d->features_space, features, &valid)); + CCS_VALIDATE(ccs_feature_space_check_features( + d->feature_space, features, &valid)); CCS_REFUTE(!valid, CCS_RESULT_ERROR_INVALID_FEATURES); ccs_result_t err = CCS_RESULT_SUCCESS; _ccs_features_tuner_ops_t *ops = ccs_features_tuner_get_ops(tuner); @@ -195,8 +195,8 @@ ccs_features_tuner_suggest( _ccs_features_tuner_common_data_t *d = (_ccs_features_tuner_common_data_t *)tuner->data; ccs_bool_t valid; - CCS_VALIDATE(ccs_features_space_check_features( - d->features_space, features, &valid)); + CCS_VALIDATE(ccs_feature_space_check_features( + d->feature_space, features, &valid)); CCS_REFUTE(!valid, CCS_RESULT_ERROR_INVALID_FEATURES); ccs_result_t err = CCS_RESULT_SUCCESS; CCS_OBJ_RDLOCK(tuner); diff --git a/src/features_tuner_deserialize.h b/src/features_tuner_deserialize.h index b98a86ae..ac9e40dd 100644 --- a/src/features_tuner_deserialize.h +++ b/src/features_tuner_deserialize.h @@ -3,7 +3,7 @@ #include "features_tuner_internal.h" #include "configuration_space_deserialize.h" #include "objective_space_deserialize.h" -#include "features_space_deserialize.h" +#include "feature_space_deserialize.h" #include "features_evaluation_deserialize.h" struct _ccs_random_features_tuner_data_mock_s { @@ -34,8 +34,8 @@ _ccs_deserialize_bin_ccs_features_tuner_common_data( CCS_VALIDATE(_ccs_objective_space_deserialize( &data->objective_space, CCS_SERIALIZE_FORMAT_BINARY, version, buffer_size, buffer, opts)); - CCS_VALIDATE(_ccs_features_space_deserialize( - &data->features_space, CCS_SERIALIZE_FORMAT_BINARY, version, + CCS_VALIDATE(_ccs_feature_space_deserialize( + &data->feature_space, CCS_SERIALIZE_FORMAT_BINARY, version, buffer_size, buffer, opts)); return CCS_RESULT_SUCCESS; } @@ -131,7 +131,7 @@ _ccs_deserialize_bin_random_features_tuner( ccs_create_random_features_tuner( data.common_data.name, data.common_data.configuration_space, - data.common_data.features_space, + data.common_data.feature_space, data.common_data.objective_space, features_tuner_ret), features_evaluations); odata = (_ccs_random_features_tuner_data_clone_t @@ -152,8 +152,8 @@ _ccs_deserialize_bin_random_features_tuner( ccs_release_object(data.common_data.configuration_space); if (data.common_data.objective_space) ccs_release_object(data.common_data.objective_space); - if (data.common_data.features_space) - ccs_release_object(data.common_data.features_space); + if (data.common_data.feature_space) + ccs_release_object(data.common_data.feature_space); if (data.history) free(data.history); return res; @@ -211,7 +211,7 @@ _ccs_deserialize_bin_user_defined_features_tuner( ccs_create_user_defined_features_tuner( data.base_data.common_data.name, data.base_data.common_data.configuration_space, - data.base_data.common_data.features_space, + data.base_data.common_data.feature_space, data.base_data.common_data.objective_space, vector, opts->data, features_tuner_ret), evaluations); @@ -247,8 +247,8 @@ _ccs_deserialize_bin_user_defined_features_tuner( data.base_data.common_data.configuration_space); if (data.base_data.common_data.objective_space) ccs_release_object(data.base_data.common_data.objective_space); - if (data.base_data.common_data.features_space) - ccs_release_object(data.base_data.common_data.features_space); + if (data.base_data.common_data.feature_space) + ccs_release_object(data.base_data.common_data.feature_space); if (data.base_data.history) free(data.base_data.history); return res; diff --git a/src/features_tuner_internal.h b/src/features_tuner_internal.h index 580d9109..74326887 100644 --- a/src/features_tuner_internal.h +++ b/src/features_tuner_internal.h @@ -3,7 +3,7 @@ #include "cconfigspace_internal.h" #include "configuration_space_internal.h" #include "objective_space_internal.h" -#include "features_space_internal.h" +#include "feature_space_internal.h" struct _ccs_features_tuner_data_s; typedef struct _ccs_features_tuner_data_s _ccs_features_tuner_data_t; @@ -54,7 +54,7 @@ struct _ccs_features_tuner_common_data_s { const char *name; ccs_configuration_space_t configuration_space; ccs_objective_space_t objective_space; - ccs_features_space_t features_space; + ccs_feature_space_t feature_space; }; typedef struct _ccs_features_tuner_common_data_s _ccs_features_tuner_common_data_t; @@ -74,8 +74,8 @@ _ccs_serialize_bin_size_ccs_features_tuner_common_data( CCS_VALIDATE(data->objective_space->obj.ops->serialize_size( data->objective_space, CCS_SERIALIZE_FORMAT_BINARY, cum_size, opts)); - CCS_VALIDATE(data->features_space->obj.ops->serialize_size( - data->features_space, CCS_SERIALIZE_FORMAT_BINARY, cum_size, + CCS_VALIDATE(data->feature_space->obj.ops->serialize_size( + data->feature_space, CCS_SERIALIZE_FORMAT_BINARY, cum_size, opts)); return CCS_RESULT_SUCCESS; } @@ -97,8 +97,8 @@ _ccs_serialize_bin_ccs_features_tuner_common_data( CCS_VALIDATE(data->objective_space->obj.ops->serialize( data->objective_space, CCS_SERIALIZE_FORMAT_BINARY, buffer_size, buffer, opts)); - CCS_VALIDATE(data->features_space->obj.ops->serialize( - data->features_space, CCS_SERIALIZE_FORMAT_BINARY, buffer_size, + CCS_VALIDATE(data->feature_space->obj.ops->serialize( + data->feature_space, CCS_SERIALIZE_FORMAT_BINARY, buffer_size, buffer, opts)); return CCS_RESULT_SUCCESS; } diff --git a/src/features_tuner_random.c b/src/features_tuner_random.c index faa7dff7..475ebc93 100644 --- a/src/features_tuner_random.c +++ b/src/features_tuner_random.c @@ -21,7 +21,7 @@ _ccs_features_tuner_random_del(ccs_object_t o) ->data; ccs_release_object(d->common_data.configuration_space); ccs_release_object(d->common_data.objective_space); - ccs_release_object(d->common_data.features_space); + ccs_release_object(d->common_data.feature_space); ccs_features_evaluation_t *e = NULL; while ((e = (ccs_features_evaluation_t *)utarray_next(d->history, e))) { ccs_release_object(*e); @@ -465,13 +465,13 @@ ccs_result_t ccs_create_random_features_tuner( const char *name, ccs_configuration_space_t configuration_space, - ccs_features_space_t features_space, + ccs_feature_space_t feature_space, ccs_objective_space_t objective_space, ccs_features_tuner_t *tuner_ret) { CCS_CHECK_PTR(name); CCS_CHECK_OBJ(configuration_space, CCS_OBJECT_TYPE_CONFIGURATION_SPACE); - CCS_CHECK_OBJ(features_space, CCS_OBJECT_TYPE_FEATURES_SPACE); + CCS_CHECK_OBJ(feature_space, CCS_OBJECT_TYPE_FEATURE_SPACE); CCS_CHECK_OBJ(objective_space, CCS_OBJECT_TYPE_OBJECTIVE_SPACE); CCS_CHECK_PTR(tuner_ret); @@ -487,7 +487,7 @@ ccs_create_random_features_tuner( CCS_VALIDATE_ERR_GOTO( err, ccs_retain_object(configuration_space), errmem); CCS_VALIDATE_ERR_GOTO(err, ccs_retain_object(objective_space), errcs); - CCS_VALIDATE_ERR_GOTO(err, ccs_retain_object(features_space), erros); + CCS_VALIDATE_ERR_GOTO(err, ccs_retain_object(feature_space), erros); tun = (ccs_features_tuner_t)mem; _ccs_object_init( @@ -502,7 +502,7 @@ ccs_create_random_features_tuner( *)(mem + sizeof(struct _ccs_features_tuner_s) + sizeof(struct _ccs_random_features_tuner_data_s)); data->common_data.configuration_space = configuration_space; data->common_data.objective_space = objective_space; - data->common_data.features_space = features_space; + data->common_data.feature_space = feature_space; utarray_new(data->history, &_evaluation_icd); utarray_new(data->optima, &_evaluation_icd); utarray_new(data->old_optima, &_evaluation_icd); @@ -518,7 +518,7 @@ ccs_create_random_features_tuner( if (data->old_optima) utarray_free(data->old_optima); _ccs_object_deinit(&(tun->obj)); - ccs_release_object(features_space); + ccs_release_object(feature_space); erros: ccs_release_object(objective_space); errcs: diff --git a/src/features_tuner_user_defined.c b/src/features_tuner_user_defined.c index 09ac8449..7d260043 100644 --- a/src/features_tuner_user_defined.c +++ b/src/features_tuner_user_defined.c @@ -22,7 +22,7 @@ _ccs_features_tuner_user_defined_del(ccs_object_t o) err = d->vector.del((ccs_features_tuner_t)o); ccs_release_object(d->common_data.configuration_space); ccs_release_object(d->common_data.objective_space); - ccs_release_object(d->common_data.features_space); + ccs_release_object(d->common_data.feature_space); return err; } @@ -324,7 +324,7 @@ ccs_result_t ccs_create_user_defined_features_tuner( const char *name, ccs_configuration_space_t configuration_space, - ccs_features_space_t features_space, + ccs_feature_space_t feature_space, ccs_objective_space_t objective_space, ccs_user_defined_features_tuner_vector_t *vector, void *tuner_data, @@ -332,7 +332,7 @@ ccs_create_user_defined_features_tuner( { CCS_CHECK_PTR(name); CCS_CHECK_OBJ(configuration_space, CCS_OBJECT_TYPE_CONFIGURATION_SPACE); - CCS_CHECK_OBJ(features_space, CCS_OBJECT_TYPE_FEATURES_SPACE); + CCS_CHECK_OBJ(feature_space, CCS_OBJECT_TYPE_FEATURE_SPACE); CCS_CHECK_OBJ(objective_space, CCS_OBJECT_TYPE_OBJECTIVE_SPACE); CCS_CHECK_PTR(tuner_ret); CCS_CHECK_PTR(vector); @@ -355,7 +355,7 @@ ccs_create_user_defined_features_tuner( CCS_VALIDATE_ERR_GOTO( err, ccs_retain_object(configuration_space), errmem); CCS_VALIDATE_ERR_GOTO(err, ccs_retain_object(objective_space), errcs); - CCS_VALIDATE_ERR_GOTO(err, ccs_retain_object(features_space), erros); + CCS_VALIDATE_ERR_GOTO(err, ccs_retain_object(feature_space), erros); tun = (ccs_features_tuner_t)mem; _ccs_object_init( @@ -370,7 +370,7 @@ ccs_create_user_defined_features_tuner( *)(mem + sizeof(struct _ccs_features_tuner_s) + sizeof(struct _ccs_user_defined_features_tuner_data_s)); data->common_data.configuration_space = configuration_space; data->common_data.objective_space = objective_space; - data->common_data.features_space = features_space; + data->common_data.feature_space = feature_space; data->vector = *vector; data->tuner_data = tuner_data; strcpy((char *)data->common_data.name, name); diff --git a/tests/Makefile.am b/tests/Makefile.am index 63735b9d..655c1328 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -28,7 +28,7 @@ CCONFIGSPACE_TESTS = \ test_forbidden \ test_random_tuner \ test_user_defined_tuner \ - test_features_space \ + test_feature_space \ test_random_features_tuner \ test_user_defined_features_tuner \ test_map \ diff --git a/tests/test_features_space.c b/tests/test_feature_space.c similarity index 69% rename from tests/test_features_space.c rename to tests/test_feature_space.c index 5cfb121a..e541e4a3 100644 --- a/tests/test_features_space.c +++ b/tests/test_feature_space.c @@ -22,9 +22,9 @@ create_dummy_parameter(const char *name) void check_features( - ccs_features_space_t features_space, - size_t sz, - ccs_parameter_t *parameters) + ccs_feature_space_t feature_space, + size_t sz, + ccs_parameter_t *parameters) { ccs_parameter_t parameter; ccs_result_t err; @@ -35,22 +35,22 @@ check_features( const char *name; err = ccs_context_get_num_parameters( - (ccs_context_t)features_space, &sz_ret); + (ccs_context_t)feature_space, &sz_ret); assert(err == CCS_RESULT_SUCCESS); assert(sz_ret == sz); for (size_t i = 0; i < sz; i++) { err = ccs_context_get_parameter( - (ccs_context_t)features_space, i, ¶meter); + (ccs_context_t)feature_space, i, ¶meter); assert(err == CCS_RESULT_SUCCESS); assert(parameter == parameters[i]); err = ccs_context_get_parameter_index( - (ccs_context_t)features_space, parameter, NULL, &index); + (ccs_context_t)feature_space, parameter, NULL, &index); assert(err == CCS_RESULT_SUCCESS); assert(index == i); } err = ccs_context_get_parameters( - (ccs_context_t)features_space, sz + 1, parameters_ret, &sz_ret); + (ccs_context_t)feature_space, sz + 1, parameters_ret, &sz_ret); assert(err == CCS_RESULT_SUCCESS); assert(sz_ret == sz); for (size_t i = 0; i < sz; i++) @@ -61,7 +61,7 @@ check_features( err = ccs_parameter_get_name(parameters[i], &name); assert(err == CCS_RESULT_SUCCESS); err = ccs_context_get_parameter_by_name( - (ccs_context_t)features_space, name, ¶meter); + (ccs_context_t)feature_space, name, ¶meter); assert(err == CCS_RESULT_SUCCESS); assert(parameter == parameters[i]); } @@ -72,56 +72,56 @@ check_features( void test_create(void) { - ccs_parameter_t parameters[3]; - ccs_parameter_t parameter3; - ccs_features_space_t features_space; - ccs_result_t err; - ccs_object_type_t type; - const char *name; + ccs_parameter_t parameters[3]; + ccs_parameter_t parameter3; + ccs_feature_space_t feature_space; + ccs_result_t err; + ccs_object_type_t type; + const char *name; parameters[0] = create_dummy_parameter("param1"); parameters[1] = create_dummy_parameter("param2"); parameter3 = create_dummy_parameter("param3"); parameters[2] = parameters[0]; - err = ccs_create_features_space( - "my_features_space", 3, NULL, &features_space); + err = ccs_create_feature_space( + "my_feature_space", 3, NULL, &feature_space); assert(err == CCS_RESULT_ERROR_INVALID_VALUE); - err = ccs_create_features_space( - "my_features_space", 3, parameters, &features_space); + err = ccs_create_feature_space( + "my_feature_space", 3, parameters, &feature_space); assert(err == CCS_RESULT_ERROR_INVALID_PARAMETER); parameters[2] = parameter3; - err = ccs_create_features_space( - "my_features_space", 3, parameters, &features_space); + err = ccs_create_feature_space( + "my_feature_space", 3, parameters, &feature_space); assert(err == CCS_RESULT_SUCCESS); - err = ccs_object_get_type(features_space, &type); + err = ccs_object_get_type(feature_space, &type); assert(err == CCS_RESULT_SUCCESS); - assert(type == CCS_OBJECT_TYPE_FEATURES_SPACE); + assert(type == CCS_OBJECT_TYPE_FEATURE_SPACE); - err = ccs_context_get_name((ccs_context_t)features_space, &name); + err = ccs_context_get_name((ccs_context_t)feature_space, &name); assert(err == CCS_RESULT_SUCCESS); - assert(strcmp(name, "my_features_space") == 0); + assert(strcmp(name, "my_feature_space") == 0); - check_features(features_space, 3, parameters); + check_features(feature_space, 3, parameters); for (size_t i = 0; i < 3; i++) { err = ccs_release_object(parameters[i]); assert(err == CCS_RESULT_SUCCESS); } - err = ccs_release_object(features_space); + err = ccs_release_object(feature_space); assert(err == CCS_RESULT_SUCCESS); } void test_features(void) { - ccs_parameter_t parameters[3]; - ccs_features_space_t features_space, features_space_ret; - ccs_datum_t values[3] = { + ccs_parameter_t parameters[3]; + ccs_feature_space_t feature_space, feature_space_ret; + ccs_datum_t values[3] = { ccs_float(-1.0), ccs_float(0.0), ccs_float(1.0)}; ccs_datum_t values_ret[3]; ccs_features_t features1, features2; @@ -135,16 +135,16 @@ test_features(void) parameters[1] = create_dummy_parameter("param2"); parameters[2] = create_dummy_parameter("param3"); - err = ccs_create_features_space( - "my_feature_space", 3, parameters, &features_space); + err = ccs_create_feature_space( + "my_feature_space", 3, parameters, &feature_space); assert(err == CCS_RESULT_SUCCESS); - err = ccs_create_features(features_space, 3, values, &features1); + err = ccs_create_features(feature_space, 3, values, &features1); assert(err == CCS_RESULT_SUCCESS); - err = ccs_features_get_features_space(features1, &features_space_ret); + err = ccs_features_get_feature_space(features1, &feature_space_ret); assert(err == CCS_RESULT_SUCCESS); - assert(features_space == features_space_ret); + assert(feature_space == feature_space_ret); for (size_t i = 0; i < 3; i++) { err = ccs_binding_get_value( @@ -173,12 +173,12 @@ test_features(void) assert(err == CCS_RESULT_SUCCESS); assert(check); - err = ccs_features_space_check_features( - features_space, features1, &check); + err = ccs_feature_space_check_features( + feature_space, features1, &check); assert(err == CCS_RESULT_SUCCESS); assert(check); - err = ccs_create_features(features_space, 3, values, &features2); + err = ccs_create_features(feature_space, 3, values, &features2); assert(err == CCS_RESULT_SUCCESS); err = ccs_binding_cmp( @@ -189,7 +189,7 @@ test_features(void) assert(err == CCS_RESULT_SUCCESS); values[1] = ccs_float(0.5); - err = ccs_create_features(features_space, 3, values, &features2); + err = ccs_create_features(feature_space, 3, values, &features2); assert(err == CCS_RESULT_SUCCESS); err = ccs_binding_cmp( @@ -200,15 +200,15 @@ test_features(void) assert(err == CCS_RESULT_SUCCESS); values[1] = ccs_float(10.0); - err = ccs_create_features(features_space, 3, values, &features2); + err = ccs_create_features(feature_space, 3, values, &features2); assert(err == CCS_RESULT_SUCCESS); err = ccs_features_check(features2, &check); assert(err == CCS_RESULT_SUCCESS); assert(!check); - err = ccs_features_space_check_features( - features_space, features2, &check); + err = ccs_feature_space_check_features( + feature_space, features2, &check); assert(err == CCS_RESULT_SUCCESS); assert(!check); @@ -216,7 +216,7 @@ test_features(void) err = ccs_release_object(parameters[i]); assert(err == CCS_RESULT_SUCCESS); } - err = ccs_release_object(features_space); + err = ccs_release_object(feature_space); assert(err == CCS_RESULT_SUCCESS); err = ccs_release_object(features1); assert(err == CCS_RESULT_SUCCESS); @@ -227,26 +227,26 @@ test_features(void) void test_deserialize(void) { - ccs_parameter_t parameters[3], parameters_new[3]; - ccs_features_space_t features_space, features_space_ref; - ccs_map_t map; - ccs_result_t err; - char *buff; - size_t buff_size; - ccs_datum_t d; + ccs_parameter_t parameters[3], parameters_new[3]; + ccs_feature_space_t feature_space, feature_space_ref; + ccs_map_t map; + ccs_result_t err; + char *buff; + size_t buff_size; + ccs_datum_t d; parameters[0] = create_dummy_parameter("param1"); parameters[1] = create_dummy_parameter("param2"); parameters[2] = create_dummy_parameter("param3"); - err = ccs_create_features_space( - "my_config_space", 3, parameters, &features_space); + err = ccs_create_feature_space( + "my_config_space", 3, parameters, &feature_space); assert(err == CCS_RESULT_SUCCESS); - check_features(features_space, 3, parameters); + check_features(feature_space, 3, parameters); err = ccs_object_serialize( - features_space, CCS_SERIALIZE_FORMAT_BINARY, + feature_space, CCS_SERIALIZE_FORMAT_BINARY, CCS_SERIALIZE_OPERATION_SIZE, &buff_size, CCS_SERIALIZE_OPTION_END); assert(err == CCS_RESULT_SUCCESS); @@ -255,7 +255,7 @@ test_deserialize(void) assert(buff); err = ccs_object_serialize( - features_space, CCS_SERIALIZE_FORMAT_BINARY, + feature_space, CCS_SERIALIZE_FORMAT_BINARY, CCS_SERIALIZE_OPERATION_MEMORY, buff_size, buff, CCS_SERIALIZE_OPTION_END); assert(err == CCS_RESULT_SUCCESS); @@ -264,56 +264,56 @@ test_deserialize(void) err = ccs_release_object(parameters[i]); assert(err == CCS_RESULT_SUCCESS); } - features_space_ref = features_space; - err = ccs_release_object(features_space); + feature_space_ref = feature_space; + err = ccs_release_object(feature_space); assert(err == CCS_RESULT_SUCCESS); err = ccs_object_deserialize( - (ccs_object_t *)&features_space, CCS_SERIALIZE_FORMAT_BINARY, + (ccs_object_t *)&feature_space, CCS_SERIALIZE_FORMAT_BINARY, CCS_SERIALIZE_OPERATION_MEMORY, buff_size, buff, CCS_DESERIALIZE_OPTION_END); assert(err == CCS_RESULT_SUCCESS); err = ccs_context_get_parameter_by_name( - (ccs_context_t)features_space, "param1", ¶meters_new[0]); + (ccs_context_t)feature_space, "param1", ¶meters_new[0]); assert(err == CCS_RESULT_SUCCESS); err = ccs_context_get_parameter_by_name( - (ccs_context_t)features_space, "param2", ¶meters_new[1]); + (ccs_context_t)feature_space, "param2", ¶meters_new[1]); assert(err == CCS_RESULT_SUCCESS); err = ccs_context_get_parameter_by_name( - (ccs_context_t)features_space, "param3", ¶meters_new[2]); + (ccs_context_t)feature_space, "param3", ¶meters_new[2]); assert(err == CCS_RESULT_SUCCESS); - err = ccs_release_object(features_space); + err = ccs_release_object(feature_space); assert(err == CCS_RESULT_SUCCESS); err = ccs_create_map(&map); assert(err == CCS_RESULT_SUCCESS); err = ccs_object_deserialize( - (ccs_object_t *)&features_space, CCS_SERIALIZE_FORMAT_BINARY, + (ccs_object_t *)&feature_space, CCS_SERIALIZE_FORMAT_BINARY, CCS_SERIALIZE_OPERATION_MEMORY, buff_size, buff, CCS_DESERIALIZE_OPTION_HANDLE_MAP, map, CCS_DESERIALIZE_OPTION_END); assert(err == CCS_RESULT_SUCCESS); err = ccs_context_get_parameter_by_name( - (ccs_context_t)features_space, "param1", ¶meters_new[0]); + (ccs_context_t)feature_space, "param1", ¶meters_new[0]); assert(err == CCS_RESULT_SUCCESS); err = ccs_context_get_parameter_by_name( - (ccs_context_t)features_space, "param2", ¶meters_new[1]); + (ccs_context_t)feature_space, "param2", ¶meters_new[1]); assert(err == CCS_RESULT_SUCCESS); err = ccs_context_get_parameter_by_name( - (ccs_context_t)features_space, "param3", ¶meters_new[2]); + (ccs_context_t)feature_space, "param3", ¶meters_new[2]); assert(err == CCS_RESULT_SUCCESS); - err = ccs_map_get(map, ccs_object(features_space_ref), &d); + err = ccs_map_get(map, ccs_object(feature_space_ref), &d); assert(err == CCS_RESULT_SUCCESS); assert(d.type == CCS_DATA_TYPE_OBJECT); - assert(d.value.o == features_space); + assert(d.value.o == feature_space); err = ccs_release_object(map); assert(err == CCS_RESULT_SUCCESS); - err = ccs_release_object(features_space); + err = ccs_release_object(feature_space); assert(err == CCS_RESULT_SUCCESS); free(buff); } @@ -321,10 +321,10 @@ test_deserialize(void) void test_features_deserialize(void) { - ccs_parameter_t parameters[3]; - ccs_features_space_t features_space; - ccs_features_t features, features_ref; - ccs_datum_t values[3] = { + ccs_parameter_t parameters[3]; + ccs_feature_space_t feature_space; + ccs_features_t features, features_ref; + ccs_datum_t values[3] = { ccs_float(-1.0), ccs_float(0.0), ccs_float(1.0)}; char *buff; size_t buff_size; @@ -337,11 +337,11 @@ test_features_deserialize(void) parameters[1] = create_dummy_parameter("param2"); parameters[2] = create_dummy_parameter("param3"); - err = ccs_create_features_space( - "my_config_space", 3, parameters, &features_space); + err = ccs_create_feature_space( + "my_config_space", 3, parameters, &feature_space); assert(err == CCS_RESULT_SUCCESS); - err = ccs_create_features(features_space, 3, values, &features_ref); + err = ccs_create_features(feature_space, 3, values, &features_ref); assert(err == CCS_RESULT_SUCCESS); err = ccs_create_map(&map); @@ -367,9 +367,9 @@ test_features_deserialize(void) CCS_DESERIALIZE_OPTION_END); assert(err == CCS_RESULT_ERROR_INVALID_HANDLE); - d = ccs_object(features_space); + d = ccs_object(feature_space); d.flags |= CCS_DATUM_FLAG_ID; - err = ccs_map_set(map, d, ccs_object(features_space)); + err = ccs_map_set(map, d, ccs_object(feature_space)); assert(err == CCS_RESULT_SUCCESS); err = ccs_object_deserialize( @@ -385,7 +385,7 @@ test_features_deserialize(void) assert(!cmp); free(buff); - err = ccs_release_object(features_space); + err = ccs_release_object(feature_space); assert(err == CCS_RESULT_SUCCESS); err = ccs_release_object(features_ref); assert(err == CCS_RESULT_SUCCESS); diff --git a/tests/test_random_features_tuner.c b/tests/test_random_features_tuner.c index fab216a9..216ec37c 100644 --- a/tests/test_random_features_tuner.c +++ b/tests/test_random_features_tuner.c @@ -23,7 +23,7 @@ test(void) ccs_parameter_t parameter3; ccs_parameter_t feature; ccs_configuration_space_t cspace; - ccs_features_space_t fspace; + ccs_feature_space_t fspace; ccs_objective_space_t ospace; ccs_expression_t expression; ccs_objective_type_t otype; @@ -56,7 +56,7 @@ test(void) "red knob", 2, knobs_values, 0, &feature); assert(err == CCS_RESULT_SUCCESS); - err = ccs_create_features_space("knobs", 1, &feature, &fspace); + err = ccs_create_feature_space("knobs", 1, &feature, &fspace); assert(err == CCS_RESULT_SUCCESS); err = ccs_create_features(fspace, 1, knobs_values, &features_on); assert(err == CCS_RESULT_SUCCESS); @@ -247,7 +247,7 @@ test_evaluation_deserialize(void) ccs_parameter_t parameter3; ccs_parameter_t feature; ccs_configuration_space_t cspace; - ccs_features_space_t fspace; + ccs_feature_space_t fspace; ccs_objective_space_t ospace; ccs_expression_t expression; ccs_objective_type_t otype; @@ -281,7 +281,7 @@ test_evaluation_deserialize(void) "red knob", 2, knobs_values, 0, &feature); assert(err == CCS_RESULT_SUCCESS); - err = ccs_create_features_space("knobs", 1, &feature, &fspace); + err = ccs_create_feature_space("knobs", 1, &feature, &fspace); assert(err == CCS_RESULT_SUCCESS); err = ccs_create_features(fspace, 1, knobs_values, &features_on); err = ccs_create_objective_space( diff --git a/tests/test_user_defined_features_tuner.c b/tests/test_user_defined_features_tuner.c index 451b7ea7..31b0fd3d 100644 --- a/tests/test_user_defined_features_tuner.c +++ b/tests/test_user_defined_features_tuner.c @@ -166,7 +166,7 @@ test(void) ccs_parameter_t parameter3; ccs_parameter_t feature; ccs_configuration_space_t cspace; - ccs_features_space_t fspace; + ccs_feature_space_t fspace; ccs_objective_space_t ospace; ccs_expression_t expression; ccs_objective_type_t otype; @@ -200,7 +200,7 @@ test(void) "red knob", 2, knobs_values, 0, &feature); assert(err == CCS_RESULT_SUCCESS); - err = ccs_create_features_space("knobs", 1, &feature, &fspace); + err = ccs_create_feature_space("knobs", 1, &feature, &fspace); assert(err == CCS_RESULT_SUCCESS); err = ccs_create_features(fspace, 1, knobs_values, &features_on); assert(err == CCS_RESULT_SUCCESS);