The following C example demonstrates the core workflow: define parameters, create a configuration space and an objective space, then use a random tuner with the ask/tell pattern to minimize a simple function.
#include <assert.h>
#include <math.h>
int main() {
"2dplane", 2, parameters, NULL, 0, NULL,
NULL, NULL, &cspace);
obj_param = NULL;
1, &obj_expr, &obj_type, &ospace);
for (int i = 0; i < 100; i++) {
result =
ccs_float((x - 1) * (x - 1) + (y - 2) * (y - 2));
}
return 0;
}
ccs_result_t ccs_release_object(ccs_object_t object)
Release a CCS object, decrementing the internal reference counting.
#define CCS_INFINITY
A macro defining the (positive) infinity value of a ccs_float_t.
Definition base.h:82
struct _ccs_expression_s * ccs_expression_t
An opaque type defining a CCS expression.
Definition base.h:99
struct _ccs_binding_s * ccs_binding_t
An opaque type defining a CCS binding.
Definition base.h:119
#define CCSF(v)
A macro casting a value to a CCS floating point numeric.
Definition base.h:435
struct _ccs_search_configuration_s * ccs_search_configuration_t
An opaque type defining a CCS search space configuration.
Definition base.h:123
struct _ccs_parameter_s * ccs_parameter_t
An opaque type defining a CCS parameter.
Definition base.h:95
struct _ccs_objective_space_s * ccs_objective_space_t
An opaque type defining a CCS objective space.
Definition base.h:139
@ CCS_RESULT_SUCCESS
Success.
Definition base.h:179
struct _ccs_search_space_s * ccs_search_space_t
An opaque type defining a CCS search space.
Definition base.h:111
struct _ccs_tuner_s * ccs_tuner_t
An opaque type defining a CCS tuner.
Definition base.h:147
struct _ccs_evaluation_s * ccs_evaluation_t
An opaque type defining a CCS evaluation.
Definition base.h:143
static ccs_datum_t ccs_float(ccs_float_t v)
A helper function to construct a datum containing a floating point value.
Definition base.h:529
struct _ccs_configuration_space_s * ccs_configuration_space_t
An opaque type defining a CCS configuration space.
Definition base.h:115
enum ccs_result_e ccs_result_t
A commodity type to represent CCS errors and returned by most functions.
Definition base.h:247
@ CCS_NUMERIC_TYPE_FLOAT
A ccs_float_t.
Definition base.h:374
ccs_result_t ccs_binding_get_values(ccs_binding_t binding, size_t num_values, ccs_datum_t *values, size_t *num_values_ret)
Get all the values in the binding.
The C configuration Space and Tuning library (CCS) provides an interface to define tuning problems an...
ccs_result_t ccs_create_configuration_space(const char *name, size_t num_parameters, ccs_parameter_t *parameters, ccs_expression_t *conditions, size_t num_forbidden_clauses, ccs_expression_t *forbidden_clauses, ccs_feature_space_t feature_space, ccs_rng_t rng, ccs_configuration_space_t *configuration_space_ret)
Create a new configuration space.
ccs_result_t ccs_evaluation_get_objective_value(ccs_evaluation_t evaluation, size_t index, ccs_datum_t *value_ret)
Get the value of an objective for a valid evaluation in the context of its objective space.
ccs_result_t ccs_create_evaluation(ccs_objective_space_t objective_space, ccs_search_configuration_t configuration, ccs_evaluation_result_t result, size_t num_values, ccs_datum_t *values, ccs_evaluation_t *evaluation_ret)
Create a new instance of an evaluation on a given objective_space for a given configuration.
ccs_result_t ccs_create_variable(ccs_parameter_t parameter, ccs_expression_t *expression_ret)
Create a new variable expression.
enum ccs_objective_type_e ccs_objective_type_t
A commodity type to represent objective types.
Definition objective_space.h:33
ccs_result_t ccs_create_objective_space(const char *name, ccs_search_space_t search_space, size_t num_parameters, ccs_parameter_t *parameters, size_t num_objectives, ccs_expression_t *objectives, ccs_objective_type_t *types, ccs_objective_space_t *objective_space_ret)
Create a new objective space.
@ CCS_OBJECTIVE_TYPE_MINIMIZE
Objective should be minimized.
Definition objective_space.h:21
ccs_result_t ccs_create_numerical_parameter(const char *name, ccs_numeric_type_t data_type, ccs_numeric_t lower, ccs_numeric_t upper, ccs_numeric_t quantization, ccs_numeric_t default_value, ccs_parameter_t *parameter_ret)
Create a new numerical parameter of the specified data_type.
A Structure containing a CCS datum.
Definition base.h:494
ccs_value_t value
The value of the datum.
Definition base.h:496
ccs_result_t ccs_create_random_tuner(const char *name, ccs_objective_space_t objective_space, ccs_tuner_t *tuner_ret)
Create a new random tuner.
ccs_result_t ccs_tuner_ask(ccs_tuner_t tuner, ccs_features_t features, size_t num_configurations, ccs_search_configuration_t *configurations, size_t *num_configurations_ret)
Ask a tuner for a set of configurations to evaluate.
ccs_result_t ccs_tuner_tell(ccs_tuner_t tuner, size_t num_evaluations, ccs_evaluation_t *evaluations)
Give a list of results to a tuner through evaluations.
ccs_result_t ccs_tuner_get_optima(ccs_tuner_t tuner, ccs_features_t features, size_t num_evaluations, ccs_evaluation_t *evaluations, size_t *num_evaluations_ret)
Ask a tuner for the discovered Pareto front.
ccs_float_t f
The floating point value of the union.
Definition base.h:447
Copyright (c) 2020, UChicago Argonne, LLC.