Skip to content

Commit

Permalink
Reverse logic of Less in hyperband v1alpha1 (kubeflow#592)
Browse files Browse the repository at this point in the history
  • Loading branch information
hougangliu authored and k8s-ci-robot committed May 28, 2019
1 parent c3478af commit 86b0721
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions pkg/suggestion/v1alpha1/hyperband_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (b Bracket) Swap(i, j int) {
}

func (b Bracket) Less(i, j int) bool {
return b[i].value > b[j].value
return b[i].value < b[j].value
}

type HyperBandParameters struct {
Expand Down Expand Up @@ -142,9 +142,9 @@ func (h *HyperBandSuggestService) makeChildBracket(ctx context.Context, c api.Ma
child := Bracket{}

if sconf.OptimizationType == api.OptimizationType_MINIMIZE {
child = parent[len(parent)-n:]
} else if sconf.OptimizationType == api.OptimizationType_MAXIMIZE {
child = parent[:n]
} else if sconf.OptimizationType == api.OptimizationType_MAXIMIZE {
child = parent[len(parent)-n:]
}
gtreq := &api.GetTrialsRequest{
StudyId: studyID,
Expand Down
4 changes: 2 additions & 2 deletions pkg/suggestion/v1alpha1/hyperband_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func TestSwap(t *testing.T) {
func TestLess(t *testing.T) {
size := 2
b := getSampleBracket(size)
exp := false
exp := true
rtn := b.Less(0, 1)

if exp != rtn {
Expand Down Expand Up @@ -503,7 +503,7 @@ func TestEvalWorkers(t *testing.T) {

_, rtn_bracket := h.evalWorkers(context.Background(), mockAPI, "studyId", &p)

exp_bracket := []Evals{{"trial3", 19}, {"trial2", 11}, {"trial1", 3}}
exp_bracket := []Evals{{"trial1", 3}, {"trial2", 11}, {"trial3", 19}}

for i, ebkt := range exp_bracket {
if ebkt != rtn_bracket[i] {
Expand Down

0 comments on commit 86b0721

Please sign in to comment.