Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CCS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Brice Videau
CCS
Commits
bf594744
Commit
bf594744
authored
Jun 18, 2020
by
Brice Videau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added check that forbidden_clauses doesn't make default configuration illegal.
parent
c0e62311
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
39 deletions
+56
-39
include/cconfigspace/context.h
include/cconfigspace/context.h
+3
-4
src/configuration_space.c
src/configuration_space.c
+53
-35
No files found.
include/cconfigspace/context.h
View file @
bf594744
...
...
@@ -6,10 +6,9 @@ extern "C" {
#endif
extern
ccs_result_t
ccs_context_get_hyperparameter_index
(
ccs_context_t
context
,
ccs_hyperparameter_t
hyperparameter
,
size_t
*
index_ret
);
ccs_context_get_hyperparameter_index
(
ccs_context_t
context
,
ccs_hyperparameter_t
hyperparameter
,
size_t
*
index_ret
);
#ifdef __cplusplus
}
...
...
src/configuration_space.c
View file @
bf594744
...
...
@@ -263,6 +263,7 @@ ccs_configuration_space_add_hyperparameter(ccs_configuration_space_t configurati
(
_ccs_hyperparameter_wrapper_t
*
)
utarray_eltptr
(
hyperparameters
,
index
);
HASH_ADD_KEYPTR
(
hh_name
,
configuration_space
->
data
->
name_hash
,
name
,
sz_name
,
p_hyper_wrapper
);
//WARNING: from this point on error handling is flunky....
HASH_ADD
(
hh_handle
,
configuration_space
->
data
->
handle_hash
,
hyperparameter
,
sizeof
(
ccs_hyperparameter_t
),
p_hyper_wrapper
);
DL_APPEND
(
configuration_space
->
data
->
distribution_list
,
distrib_wrapper
);
...
...
@@ -448,33 +449,6 @@ ccs_configuration_space_get_hyperparameters(
return
CCS_SUCCESS
;
}
ccs_result_t
ccs_configuration_space_get_default_configuration
(
ccs_configuration_space_t
configuration_space
,
ccs_configuration_t
*
configuration_ret
)
{
if
(
!
configuration_space
||
!
configuration_space
->
data
)
return
-
CCS_INVALID_OBJECT
;
if
(
!
configuration_ret
)
return
-
CCS_INVALID_VALUE
;
ccs_result_t
err
;
ccs_configuration_t
config
;
err
=
ccs_create_configuration
(
configuration_space
,
0
,
NULL
,
NULL
,
&
config
);
if
(
err
)
return
err
;
UT_array
*
array
=
configuration_space
->
data
->
hyperparameters
;
_ccs_hyperparameter_wrapper_t
*
wrapper
=
NULL
;
ccs_datum_t
*
values
=
config
->
data
->
values
;
while
(
(
wrapper
=
(
_ccs_hyperparameter_wrapper_t
*
)
utarray_next
(
array
,
wrapper
))
)
{
err
=
ccs_hyperparameter_get_default_value
(
wrapper
->
hyperparameter
,
values
++
);
if
(
unlikely
(
err
))
{
ccs_release_object
(
config
);
return
err
;
}
}
*
configuration_ret
=
config
;
return
CCS_SUCCESS
;
}
static
ccs_result_t
_set_actives
(
ccs_configuration_space_t
configuration_space
,
ccs_configuration_t
configuration
)
{
...
...
@@ -511,6 +485,38 @@ _set_actives(ccs_configuration_space_t configuration_space,
return
CCS_SUCCESS
;
}
ccs_result_t
ccs_configuration_space_get_default_configuration
(
ccs_configuration_space_t
configuration_space
,
ccs_configuration_t
*
configuration_ret
)
{
if
(
!
configuration_space
||
!
configuration_space
->
data
)
return
-
CCS_INVALID_OBJECT
;
if
(
!
configuration_ret
)
return
-
CCS_INVALID_VALUE
;
ccs_result_t
err
;
ccs_configuration_t
config
;
err
=
ccs_create_configuration
(
configuration_space
,
0
,
NULL
,
NULL
,
&
config
);
if
(
err
)
return
err
;
UT_array
*
array
=
configuration_space
->
data
->
hyperparameters
;
_ccs_hyperparameter_wrapper_t
*
wrapper
=
NULL
;
ccs_datum_t
*
values
=
config
->
data
->
values
;
while
(
(
wrapper
=
(
_ccs_hyperparameter_wrapper_t
*
)
utarray_next
(
array
,
wrapper
))
)
{
err
=
ccs_hyperparameter_get_default_value
(
wrapper
->
hyperparameter
,
values
++
);
if
(
unlikely
(
err
))
{
ccs_release_object
(
config
);
return
err
;
}
}
err
=
_set_actives
(
configuration_space
,
config
);
if
(
err
)
{
ccs_release_object
(
config
);
return
err
;
}
*
configuration_ret
=
config
;
return
CCS_SUCCESS
;
}
static
ccs_result_t
_test_forbidden
(
ccs_configuration_space_t
configuration_space
,
ccs_datum_t
*
values
,
...
...
@@ -1026,12 +1032,30 @@ ccs_configuration_space_add_forbidden_clause(ccs_configuration_space_t configura
(
ccs_context_t
)
configuration_space
);
if
(
err
)
return
err
;
ccs_datum_t
d
;
ccs_configuration_t
config
;
err
=
ccs_configuration_space_get_default_configuration
(
configuration_space
,
&
config
);
if
(
err
)
return
err
;
err
=
ccs_expression_eval
(
expression
,
(
ccs_context_t
)
configuration_space
,
config
->
data
->
values
,
&
d
);
ccs_release_object
(
config
);
if
(
err
&&
err
!=
-
CCS_INACTIVE_HYPERPARAMETER
)
{
return
err
;
}
if
(
!
err
&&
d
.
type
==
CCS_BOOLEAN
&&
d
.
value
.
i
==
CCS_TRUE
)
return
-
CCS_INVALID_CONFIGURATION
;
err
=
ccs_retain_object
(
expression
);
if
(
err
)
return
err
;
utarray_push_back
(
configuration_space
->
data
->
forbidden_clauses
,
&
expression
);
return
CCS_SUCCESS
;
}
#undef utarray_oom
#define utarray_oom() exit(-1)
ccs_result_t
ccs_configuration_space_add_forbidden_clauses
(
ccs_configuration_space_t
configuration_space
,
...
...
@@ -1043,19 +1067,13 @@ ccs_configuration_space_add_forbidden_clauses(ccs_configuration_space_t configu
return
-
CCS_INVALID_VALUE
;
for
(
size_t
i
=
0
;
i
<
num_expressions
;
i
++
)
{
ccs_result_t
err
;
err
=
ccs_
expression_check_context
(
expressions
[
i
]
,
(
ccs_context_t
)
configuration_space
);
err
=
ccs_
configuration_space_add_forbidden_clause
(
configuration_space
,
expressions
[
i
]
);
if
(
err
)
return
err
;
err
=
ccs_retain_object
(
expressions
[
i
]);
if
(
err
)
return
err
;
utarray_push_back
(
configuration_space
->
data
->
forbidden_clauses
,
expressions
+
i
);
}
return
CCS_SUCCESS
;
}
#undef utarray_oom
#define utarray_oom() exit(-1)
ccs_result_t
ccs_configuration_space_get_forbidden_clause
(
ccs_configuration_space_t
configuration_space
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment