Commit 7fe7f610 authored by Brice Videau's avatar Brice Videau
Browse files

Distinguish between error type and result type.

parent 82fa9e3d
......@@ -64,8 +64,9 @@ enum ccs_error_e {
CCS_ERROR_MAX,
CCS_ERROR_FORCE_32BIT = INT_MAX
};
typedef enum ccs_error_e ccs_error_t;
typedef int ccs_error_t;
typedef int ccs_result_t;
enum ccs_object_type_e {
CCS_RNG,
......@@ -201,23 +202,23 @@ extern const ccs_datum_t ccs_inactive;
#define CCS_NONE_VAL {{0}, CCS_NONE}
#define CCS_INACTIVE_VAL {{0}, CCS_INACTIVE}
extern ccs_error_t
extern ccs_result_t
ccs_init();
extern ccs_version_t
ccs_get_version();
extern ccs_error_t
extern ccs_result_t
ccs_retain_object(ccs_object_t object);
extern ccs_error_t
extern ccs_result_t
ccs_release_object(ccs_object_t object);
extern ccs_error_t
extern ccs_result_t
ccs_object_get_type(ccs_object_t object,
ccs_object_type_t *type_ret);
extern ccs_error_t
extern ccs_result_t
ccs_object_get_refcount(ccs_object_t object,
int32_t *refcount_ret);
......
......@@ -8,7 +8,7 @@ extern "C" {
// Configuration Interface
// Creators, Management
extern ccs_error_t
extern ccs_result_t
ccs_create_configuration(ccs_configuration_space_t configuration_space,
size_t num_values,
ccs_datum_t *values,
......@@ -16,43 +16,43 @@ ccs_create_configuration(ccs_configuration_space_t configuration_space,
ccs_configuration_t *configuration_ret);
// Accessors
extern ccs_error_t
extern ccs_result_t
ccs_configuration_get_configuration_space(ccs_configuration_t configuration,
ccs_configuration_space_t *configuration_space_ret);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_get_user_data(ccs_configuration_t configuration,
void **user_data_ret);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_get_value(ccs_configuration_t configuration,
size_t index,
ccs_datum_t *value_ret);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_set_value(ccs_configuration_t configuration,
size_t index,
ccs_datum_t value);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_get_values(ccs_configuration_t configuration,
size_t num_values,
ccs_datum_t *values,
size_t *num_values_ret);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_get_value_by_name(ccs_configuration_t configuration,
const char *name,
ccs_datum_t *value_ret);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_check(ccs_configuration_t configuration);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_hash(ccs_configuration_t configuration,
ccs_hash_t *hash_ret);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_cmp(ccs_configuration_t configuration,
ccs_configuration_t other_configuration,
int *equal_ret);
......
......@@ -8,135 +8,135 @@ extern "C" {
// Configuration Space Interface
// Creators
extern ccs_error_t
extern ccs_result_t
ccs_create_configuration_space(const char *name,
void *user_data,
ccs_configuration_space_t *configuration_space_ret);
// Accessors
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_get_name(ccs_configuration_space_t configuration_space,
const char **name_ret);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_get_user_data(ccs_configuration_space_t configuration_space,
void **user_data_ret);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_set_rng(ccs_configuration_space_t configuration_space,
ccs_rng_t rng);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_get_rng(ccs_configuration_space_t configuration_space,
ccs_rng_t *rng_ret);
// List Accessors
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_add_hyperparameter(ccs_configuration_space_t configuration_space,
ccs_hyperparameter_t hyperparameter,
ccs_distribution_t distribution);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_add_hyperparameters(ccs_configuration_space_t configuration_space,
size_t num_hyperparameters,
ccs_hyperparameter_t *hyperparameters,
ccs_distribution_t *distributions);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_get_num_hyperparameters(ccs_configuration_space_t configuration_space,
size_t *num_hyperparameters_ret);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_get_hyperparameter(ccs_configuration_space_t configuration_space,
size_t index,
ccs_hyperparameter_t *hyperparameter_ret);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_get_hyperparameter_by_name(
ccs_configuration_space_t configuration_space,
const char * name,
ccs_hyperparameter_t *hyperparameter_ret);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_get_hyperparameter_index_by_name(
ccs_configuration_space_t configuration_space,
const char *name,
size_t *index_ret);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_get_hyperparameter_index(
ccs_configuration_space_t configuration_space,
ccs_hyperparameter_t hyperparameter,
size_t *index_ret);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_get_hyperparameter_indexes(
ccs_configuration_space_t configuration_space,
size_t num_hyperparameters,
ccs_hyperparameter_t *hyperparameters,
size_t *indexes);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_get_hyperparameters(ccs_configuration_space_t configuration_space,
size_t num_hyperparameters,
ccs_hyperparameter_t *hyperparameters,
size_t *num_hyperparameters_ret);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_set_condition(ccs_configuration_space_t configuration_space,
size_t hyperparameter_index,
ccs_expression_t expression);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_get_condition(ccs_configuration_space_t configuration_space,
size_t hyperparameter_index,
ccs_expression_t *expression_ret);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_get_conditions(ccs_configuration_space_t configuration_space,
size_t num_expressions,
ccs_expression_t *expressions,
size_t *num_expressions_ret);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_add_forbidden_clause(ccs_configuration_space_t configuration_space,
ccs_expression_t expression);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_add_forbidden_clauses(ccs_configuration_space_t configuration_space,
size_t num_expressions,
ccs_expression_t *expressions);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_get_forbidden_clause(ccs_configuration_space_t configuration_space,
size_t index,
ccs_expression_t *expression_ret);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_get_forbidden_clauses(ccs_configuration_space_t configuration_space,
size_t num_expressions,
ccs_expression_t *expressions,
size_t *num_expressions_ret);
// Configuration related functions
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_check_configuration(ccs_configuration_space_t configuration_space,
ccs_configuration_t configuration);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_check_configuration_values(ccs_configuration_space_t configuration_space,
size_t num_values,
ccs_datum_t *values);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_get_default_configuration(ccs_configuration_space_t configuration_space,
ccs_configuration_t *configuration_ret);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_sample(ccs_configuration_space_t configuration_space,
ccs_configuration_t *configuration_ret);
extern ccs_error_t
extern ccs_result_t
ccs_configuration_space_samples(ccs_configuration_space_t configuration_space,
size_t num_configurations,
ccs_configuration_t *configurations);
......
......@@ -5,7 +5,7 @@
extern "C" {
#endif
extern ccs_error_t
extern ccs_result_t
ccs_context_get_hyperparameter_index(
ccs_context_t context,
ccs_hyperparameter_t hyperparameter,
......
......@@ -25,7 +25,7 @@ enum ccs_scale_type_e {
typedef enum ccs_scale_type_e ccs_scale_type_t;
// Distribution
extern ccs_error_t
extern ccs_result_t
ccs_create_normal_distribution(ccs_numeric_type_t data_type,
ccs_float_t mu,
ccs_float_t sigma,
......@@ -33,21 +33,21 @@ ccs_create_normal_distribution(ccs_numeric_type_t data_type,
ccs_numeric_t quantization,
ccs_distribution_t *distribution_ret);
extern ccs_error_t
extern ccs_result_t
ccs_create_normal_int_distribution(ccs_float_t mu,
ccs_float_t sigma,
ccs_scale_type_t scale,
ccs_int_t quantization,
ccs_distribution_t *distribution_ret);
extern ccs_error_t
extern ccs_result_t
ccs_create_normal_float_distribution(ccs_float_t mu,
ccs_float_t sigma,
ccs_scale_type_t scale,
ccs_float_t quantization,
ccs_distribution_t *distribution_ret);
extern ccs_error_t
extern ccs_result_t
ccs_create_uniform_distribution(ccs_numeric_type_t data_type,
ccs_numeric_t lower,
ccs_numeric_t upper,
......@@ -55,82 +55,82 @@ ccs_create_uniform_distribution(ccs_numeric_type_t data_type,
ccs_numeric_t quantization,
ccs_distribution_t *distribution_ret);
extern ccs_error_t
extern ccs_result_t
ccs_create_uniform_int_distribution(ccs_int_t lower,
ccs_int_t upper,
ccs_scale_type_t scale,
ccs_int_t quantization,
ccs_distribution_t *distribution_ret);
extern ccs_error_t
extern ccs_result_t
ccs_create_uniform_float_distribution(ccs_float_t lower,
ccs_float_t upper,
ccs_scale_type_t scale,
ccs_float_t quantization,
ccs_distribution_t *distribution_ret);
extern ccs_error_t
extern ccs_result_t
ccs_create_roulette_distribution(size_t num_areas,
ccs_float_t *areas,
ccs_distribution_t *distribution_ret);
// Accessors
extern ccs_error_t
extern ccs_result_t
ccs_distribution_get_type(ccs_distribution_t distribution,
ccs_distribution_type_t *type_ret);
extern ccs_error_t
extern ccs_result_t
ccs_distribution_get_data_type(ccs_distribution_t distribution,
ccs_numeric_type_t *data_type_ret);
extern ccs_error_t
extern ccs_result_t
ccs_distribution_get_dimension(ccs_distribution_t distribution,
size_t *dimension);
extern ccs_error_t
extern ccs_result_t
ccs_distribution_get_scale_type(ccs_distribution_t distribution,
ccs_scale_type_t *scale_type_ret);
extern ccs_error_t
extern ccs_result_t
ccs_distribution_get_quantization(ccs_distribution_t distribution,
ccs_numeric_t *quantization);
extern ccs_error_t
extern ccs_result_t
ccs_distribution_get_bounds(ccs_distribution_t distribution,
ccs_interval_t *interval_ret);
extern ccs_error_t
extern ccs_result_t
ccs_distribution_check_oversampling(ccs_distribution_t distribution,
ccs_interval_t *interval,
ccs_bool_t *oversampling_ret);
extern ccs_error_t
extern ccs_result_t
ccs_normal_distribution_get_parameters(ccs_distribution_t distribution,
ccs_float_t *mu_ret,
ccs_float_t *sigma_ret);
extern ccs_error_t
extern ccs_result_t
ccs_uniform_distribution_get_parameters(ccs_distribution_t distribution,
ccs_numeric_t *lower_ret,
ccs_numeric_t *upper_ret);
extern ccs_error_t
extern ccs_result_t
ccs_roulette_distribution_get_num_areas(ccs_distribution_t distribution,
size_t *num_areas_ret);
extern ccs_error_t
extern ccs_result_t
ccs_roulette_distribution_get_areas(ccs_distribution_t distribution,
size_t num_areas,
ccs_float_t *areas,
size_t *num_areas_ret);
// Sampling Interface
extern ccs_error_t
extern ccs_result_t
ccs_distribution_sample(ccs_distribution_t distribution,
ccs_rng_t rng,
ccs_numeric_t *value);
extern ccs_error_t
extern ccs_result_t
ccs_distribution_samples(ccs_distribution_t distribution,
ccs_rng_t rng,
size_t num_values,
......
......@@ -15,68 +15,68 @@ enum ccs_comparison_e {
};
typedef enum ccs_comparison_e ccs_comparison_t;
extern ccs_error_t
extern ccs_result_t
ccs_create_evaluation(ccs_objective_space_t objective_space,
ccs_configuration_t configuration,
ccs_error_t error,
ccs_result_t error,
size_t num_values,
ccs_datum_t *values,
void *user_data,
ccs_evaluation_t *evaluation_ret);
extern ccs_error_t
extern ccs_result_t
ccs_evaluation_get_objective_space(ccs_evaluation_t evaluation,
ccs_objective_space_t *objective_space_ret);
extern ccs_error_t
extern ccs_result_t
ccs_evaluation_get_configuration(ccs_evaluation_t evaluation,
ccs_configuration_t *configuration_ret);
extern ccs_error_t
extern ccs_result_t
ccs_evaluation_get_user_data(ccs_evaluation_t evaluation,
void **user_data_ret);
extern ccs_error_t
extern ccs_result_t
ccs_evaluation_get_error(ccs_evaluation_t evaluation,
ccs_error_t *error_ret);
ccs_result_t *error_ret);
extern ccs_error_t
extern ccs_result_t
ccs_evaluation_set_error(ccs_evaluation_t evaluation,
ccs_error_t error);
ccs_result_t error);
extern ccs_error_t
extern ccs_result_t
ccs_evaluation_get_value(ccs_evaluation_t evaluation,
size_t index,
ccs_datum_t *value_ret);
extern ccs_error_t
extern ccs_result_t
ccs_evaluation_set_value(ccs_evaluation_t evaluation,
size_t index,
ccs_datum_t value);
extern ccs_error_t
extern ccs_result_t
ccs_evaluation_get_values(ccs_evaluation_t evaluation,
size_t num_values,
ccs_datum_t *values,
size_t *num_values_ret);
extern ccs_error_t
extern ccs_result_t
ccs_evaluation_get_value_by_name(ccs_evaluation_t evaluation,
const char *name,
ccs_datum_t *value_ret);
extern ccs_error_t
extern ccs_result_t
ccs_evaluation_get_objective_value(ccs_evaluation_t evaluation,
size_t index,
ccs_datum_t *value_ret);
extern ccs_error_t
extern ccs_result_t
ccs_evaluation_get_objective_values(ccs_evaluation_t evaluation,
size_t num_values,
ccs_datum_t *values,
size_t *num_values_ret);
extern ccs_error_t
extern ccs_result_t
ccs_evaluation_cmp(ccs_evaluation_t evaluation,
ccs_evaluation_t other_evaluation,
ccs_comparison_t *result_ret);
......
......@@ -53,60 +53,60 @@ extern const char *ccs_expression_symbols[];
extern const int ccs_expression_arity[];
// Expressions
extern ccs_error_t
extern ccs_result_t
ccs_create_binary_expression(ccs_expression_type_t type,
ccs_datum_t node_left,
ccs_datum_t node_right,
ccs_expression_t *expression_ret);
extern ccs_error_t
extern ccs_result_t
ccs_create_unary_expression(ccs_expression_type_t type,
ccs_datum_t node,
ccs_expression_t *expression_ret);
extern ccs_error_t
extern ccs_result_t
ccs_create_expression(ccs_expression_type_t type,
size_t num_nodes,
ccs_datum_t *nodes,
ccs_expression_t *expression_ret);
extern ccs_error_t
extern ccs_result_t
ccs_create_literal(ccs_datum_t value,
ccs_expression_t *expression_ret);
extern ccs_error_t
extern ccs_result_t
ccs_create_variable(ccs_hyperparameter_t hyperparameter,
ccs_expression_t *expression_ret);
extern ccs_error_t
extern ccs_result_t
ccs_expression_get_type(ccs_expression_t expression,
ccs_expression_type_t *type_ret);
extern ccs_error_t
extern ccs_result_t
ccs_expression_get_num_nodes(ccs_expression_t expression,
size_t *num_nodes_ret);
extern ccs_error_t
extern ccs_result_t
ccs_expression_get_nodes(ccs_expression_t expression,
size_t num_nodes,
ccs_expression_t *nodes,
size_t *num_nodes_ret);
extern ccs_error_t
extern ccs_result_t
ccs_literal_get_value(ccs_expression_t expression,
ccs_datum_t *value_ret);
extern ccs_error_t
extern ccs_result_t
ccs_variable_get_hyperparameter(ccs_expression_t expression,
ccs_hyperparameter_t *hyperparameter_ret);
extern ccs_error_t
extern ccs_result_t
ccs_expression_eval(ccs_expression_t expression,
ccs_context_t context,
ccs_datum_t *values,
ccs_datum_t *result);
extern ccs_error_t
extern ccs_result_t
ccs_expression_list_eval_node(ccs_expression_t expression,
ccs_context_t context,
ccs_datum_t *values,
......@@ -114,13 +114,13 @@ ccs_expression_list_eval_node(ccs_expression_t expression,
ccs_datum_t *result);
//uniq and sorted list of hyperparameters handle
extern ccs_error_t
extern ccs_result_t
ccs_expression_get_hyperparameters(ccs_expression_t expression,
size_t num_hyperparameters,
ccs_hyperparameter_t *hyperparameters,
size_t *num_hyperparameters_ret);
extern ccs_error_t
extern ccs_result_t
ccs_expression_check_context(ccs_expression_t expression,
ccs_context_t context);
#ifdef __cplusplus
......
......@@ -16,7 +16,7 @@ enum ccs_hyperparameter_type_e {
typedef enum ccs_hyperparameter_type_e ccs_hyperparameter_type_t;
// Hyperparameter Interface
extern ccs_error_t
extern ccs_result_t
ccs_create_numerical_hyperparameter(const char *name,
ccs_numeric_type_t data_type,
ccs_numeric_t lower,
......@@ -26,7 +26,7 @@ ccs_create_numerical_hyperparameter(const char *name,
void *user_data,
ccs_hyperparameter_t *hyperparameter_ret);
extern ccs_error_t
extern ccs_result_t
ccs_create_categorical_hyperparameter(const char *name,
size_t num_possible_values,
ccs_datum_t *possible_values,
......@@ -34,7 +34,7 @@ ccs_create_categorical_hyperparameter(const char *name,
void *user_data,
ccs_hyperparameter_t *hyperparameter_ret);
extern ccs_error_t
extern ccs_result_t
ccs_create_ordinal_hyperparameter(const char *name,
size_t num_possible_values,
ccs_datum_t *possible_values,
......@@ -42,7 +42,7 @@ ccs_create_ordinal_hyperparameter(const char *name,
void *user_data,
ccs_hyperparameter_t *hyperparameter_ret);
extern ccs_error_t
extern ccs_result_t
ccs_ordinal_hyperparameter_compare_values(ccs_hyperparameter_t hyperparameter,
ccs_datum_t value1,
ccs_datum_t value2,
......@@ -50,45 +50,45 @@ ccs_ordinal_hyperparameter_compare_values(ccs_hyperparameter_t hyperparameter,
// Accessors