Skip to content

Commit

Permalink
Merge pull request #199 from hmcalister/Use-Energy-Profile-for-State-…
Browse files Browse the repository at this point in the history
…Uniquness

Track state uniqueness using energy profile rather than state
  • Loading branch information
hmcalister authored May 12, 2023
2 parents 486e814 + b679ddc commit 1e373d4
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions hopfieldnetwork/datacollector/UniqueRelaxedStateHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,10 @@ func NewUniqueRelaxedStateHandler(dataFile string) *dataHandler {
func handleUniqueRelaxedState(writer *writer.ParquetWriter, event interface{}) {
// Note result is coming from relaxation result, so we have to cast to that...
relaxationResult := event.(RelaxationResultData)

var stateHash string
if relaxationResult.FinalState[0] < 0 {
for index := range relaxationResult.FinalState {
relaxationResult.FinalState[index] *= -1.0
}
stateHash = fmt.Sprint(relaxationResult.FinalState)
for index := range relaxationResult.FinalState {
relaxationResult.FinalState[index] *= -1.0
}
} else {
stateHash = fmt.Sprint(relaxationResult.FinalState)
}
energyHash := fmt.Sprint(relaxationResult.EnergyProfile)

// See if state has been seen before
val, ok := uniqueRelaxedStatesMap[stateHash]
val, ok := uniqueRelaxedStatesMap[energyHash]
if !ok {
result := UniqueRelaxedStateData{
StateIndex: relaxationResult.StateIndex,
Expand All @@ -70,7 +58,7 @@ func handleUniqueRelaxedState(writer *writer.ParquetWriter, event interface{}) {
}

uniqueRelaxedStatesArray = append(uniqueRelaxedStatesArray, &result)
uniqueRelaxedStatesMap[stateHash] = &result
uniqueRelaxedStatesMap[energyHash] = &result

return
} else {
Expand Down

0 comments on commit 1e373d4

Please sign in to comment.