简体   繁体   English

避开八度缺少地图数据结构

[英]getting around octave's lack of map data structure

i am using octave for my project as i cant afford a matlab license, however i have run into a significant roadblock and that is the lack of associative array data structures. 我无法使用Matlab许可证,因此正在为我的项目使用octave,但是我遇到了一个重大障碍,那就是缺少关联数组数据结构。

my problem is this: 我的问题是这样的:

i have some data in the form of cell arrays containing matrices with each cell array representing a potential solution to a problem. 我有一些包含矩阵的单元格形式的数据,每个单元格代表一个问题的潜在解决方案。 i also have a floating point number that represents the evaluated performance of that solution which i want to put into a map-like data structure with the floating point score as the key, in order to sort the solutions by their performance. 我还具有一个浮点数,该浮点数表示该解决方案的评估性能,我希望将其放入以浮点得分为键的类似地图的数据结构中,以便按其性能对解决方案进行排序。

can anyone suggest a simple solution to this problem? 谁能建议一个简单的解决方案来解决这个问题?

what i have thought about doing so far is making each element part of a two element cell array, with the evaluation score as the first element and the data as the second, and then put those arrays into another cell array, which i then apply some sorting algorithm to, sorting by array{i}{1}.. but this seems like a pretty clunky solution. 到目前为止,我一直在考虑将两个元素单元格数组的每个元素作为一部分,将评估分数作为第一个元素,将数据作为第二个元素,然后将这些数组放入另一个单元格数组中,然后再应用一些排序算法,按数组{i} {1}进行排序。但这似乎是一个笨拙的解决方案。

does octave have any functionality in this respect that i am just unaware of? 在这个方面,八度音阶有没有我不知道的功能? or is my clunky solution the only way to achieve this? 还是我笨拙的解决方案是实现这一目标的唯一方法?

any help would be greatly appreciated thanks 任何帮助将不胜感激谢谢

How about keeping the cell array as it is, but create a matrix where the columns are the evaluation score and the index into the cell array. 如何保持单元格数组原样,但创建一个矩阵,其中的列是评估得分和单元格数组的索引。 Then you can easily use sortrows on the evaluation score column and use the index to pull the solution from the cell array. 然后,您可以轻松地使用评估得分列上的排序行,并使用索引从单元格数组中提取解决方案。 I think this should be a simple solution that has the benefit of not rearranging your potentially large set of data. 我认为这应该是一个简单的解决方案,它的好处是不会重新排列可能的大量数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM