Esempio n. 1
0
func score(strategy algorithm.Strategy, state *algorithm.State, ni, no uint) []float64 {
	nn := uint(len(state.Indices)) / ni
	scores := make([]float64, nn)
	for i := uint(0); i < nn; i++ {
		scores[i] = strategy.Score(&algorithm.Element{
			Index:   state.Indices[i*ni : (i+1)*ni],
			Node:    state.Nodes[i*ni : (i+1)*ni],
			Volume:  state.Volumes[i],
			Value:   state.Values[i*no : (i+1)*no],
			Surplus: state.Surpluses[i*no : (i+1)*no],
		})
	}
	return scores
}
Esempio n. 2
0
func score(strategy algorithm.Strategy, state *algorithm.State, ni, no uint) []float64 {
	nn := uint(len(state.Counts))
	scores := []float64(nil)
	for i, j := uint(0), uint(0); i < nn; i++ {
		for m := j + state.Counts[i]; j < m; j++ {
			scores = append(scores, strategy.Score(&algorithm.Element{
				Index:   state.Indices[j*ni : (j+1)*ni],
				Node:    state.Nodes[j*ni : (j+1)*ni],
				Volume:  state.Volumes[j],
				Value:   state.Values[j*no : (j+1)*no],
				Surplus: state.Surpluses[j*no : (j+1)*no],
			}))
		}
	}
	return scores
}