使用转换工具转换GUI项目后,在哪里放置CodenameOne StateMachine代码(Where to put CodenameOne StateMachine Codes after converting GUI project with conversion tool)
我使用转换工具转换了我的codenameOne GUI项目,但不知道将我的代码放在StateMachine类中的哪个位置。
转换后出现一些错误:
private static final java.util.HashMap<String, Class> formNameToClassHashMap = new java.util.HashMap<String, Class>();
以上代码来自StateMachineBase和NetBeans提示显示
-source 1.2不支持泛型(使用-source 5或更高版本来启用泛型)
super.initListModelFileList(list);
此代码来自StateMachine类,错误消息是“找不到符号”。
请问我该怎么办?
提前致谢。
I converted my codenameOne GUI project using conversion tool but did not know where to put my codes in StateMachine class.
And am getting some errors after conversion:
private static final java.util.HashMap<String, Class> formNameToClassHashMap = new java.util.HashMap<String, Class>();
The above code is from StateMachineBase and NetBeans hint shows
generics are not supported in -source 1.2 (use -source 5 or higher to enable generics)
super.initListModelFileList(list);
This code is from StateMachine class and the error message is that "cannot find symbol".
Please what should I do?
Thanks in advance.
原文:https://stackoverflow.com/questions/35099488
最满意答案
实际上,我原来的配方并不是很好。 这作为套装更好。
import pulp # Input data A = [ [2, 1, 0, 0], [2, 0, 0, 0], [2, 1, 2, 2], [1, 2, 2, 2], [2, 1, 1, 0] ] # Preprocess the data a bit. # Bikj = 1 if Aij != Akj, 0 otherwise B = [] for i in range(len(A)): Bi = [] for k in range(len(A)): Bik = [int(A[i][j] != A[k][j]) for j in range(len(A[i]))] Bi.append(Bik) B.append(Bi) model = pulp.LpProblem('Tim', pulp.LpMinimize) # Variables turn on and off columns. x = [pulp.LpVariable('x_%d' % j, cat=pulp.LpBinary) for j in range(len(A[0]))] # The sum of elementwise absolute difference per element and row. for i in range(len(A)): for k in range(i + 1, len(A)): model += sum(B[i][k][j] * x[j] for j in range(len(A[i]))) >= 1 model.setObjective(pulp.lpSum(x)) assert model.solve() == pulp.LpStatusOptimal print([xi.value() for xi in x])
Actually, my original formulation wasn't very good. This is better as a set cover.
import pulp # Input data A = [ [2, 1, 0, 0], [2, 0, 0, 0], [2, 1, 2, 2], [1, 2, 2, 2], [2, 1, 1, 0] ] # Preprocess the data a bit. # Bikj = 1 if Aij != Akj, 0 otherwise B = [] for i in range(len(A)): Bi = [] for k in range(len(A)): Bik = [int(A[i][j] != A[k][j]) for j in range(len(A[i]))] Bi.append(Bik) B.append(Bi) model = pulp.LpProblem('Tim', pulp.LpMinimize) # Variables turn on and off columns. x = [pulp.LpVariable('x_%d' % j, cat=pulp.LpBinary) for j in range(len(A[0]))] # The sum of elementwise absolute difference per element and row. for i in range(len(A)): for k in range(i + 1, len(A)): model += sum(B[i][k][j] * x[j] for j in range(len(A[i]))) >= 1 model.setObjective(pulp.lpSum(x)) assert model.solve() == pulp.LpStatusOptimal print([xi.value() for xi in x])
相关问答
更多-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
为什么````比`子集`好?(Why is `[` better than `subset`?)[2023-07-22]
这个问题在@James的评论中得到了很好的回答,指出了Hadley Wickham对子subset (和类似功能)的危害的一个很好的解释。 去读吧! 这是一个长时间的阅读,所以在这里记录Hadley使用的例子可能是最有帮助的,这个例子最直接地解决了“可能出了什么问题”的问题: Hadley建议以下示例:假设我们要使用以下函数对数据框进行子集,然后重新排序: scramble <- function(x) x[sample(nrow(x)), ] subscramble <- function(x, con ... -
让我们考虑一维情况:您有一个数组数组,并允许您进行单个操作:从数组的其中一个元素的值中取1并将其添加到其他元素。 目标是通过最少的操作使所有元素均等。 这里的解决方案很简单:你选择随机的“太大的数字”,并添加一个随机的“太小”的数字。 现在让我来描述这与这个问题的关系。 您可以轻松计算每列和每行所需的总和。 这是矩阵中所有元素的总和除以列或行的数量。 从那时起,你可以计算哪些行和列需要减少,哪些增加。 看这里: 1 1 2 2 -2 1 0 1 1 +1 0 0 1 1 +2 1 1 1 2 -1 +1+2 ...
-
希望这可以帮助。 # Create data X <- iris[1:4, ] X # Sepal.Length Sepal.Width Petal.Length Petal.Width Species #1 5.1 3.5 1.4 0.2 setosa #2 4.9 3.0 1.4 0.2 setosa #3 4.7 3.2 ...
-
以下是一些示例数据: lon <- matrix(seq(-10,9.8,by=0.2),ncol=10,byrow=T) lat <- matrix(seq(-10,9.8,by=0.2),ncol=10,byrow=T) lon # which is the same as lat in this example: [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] -10 -9.8 -9.6 -9.4 -9.2 -9 -8 ...
-
MATLAB - 在矩阵的选定行/列中查找最大/最小值(MATLAB - finding max/min in selected rows/columns of a matrix)[2023-01-17]
假设子矩阵A(a,b)是连续的(如在您的示例中): A = [ 0 2 4 0 2 0 5 0 4 5 0 3 0 0 3 0 ] a = [1 2]; b = [3 4]; B = A(a,b) [val,idx] = max(B(:)); [row,col] = ind2sub(size(B),idx); maxrow = row + a(1) - 1; maxcol = col + b(1) - 1; 您可以在子矩阵B中找到相对索引。这相当于子矩阵左上角的附加行和列。 现在假设a和 ... -
使用向量的子集矩阵(Subset Matrix using a vector)[2022-06-20]
这是一个选项: M <- matrix(rnorm(2 * 5), nrow = 5, ncol = 2) n <- c(2, 1, 2) Map(function(i, j) M[(i - j + 1):i, , drop = FALSE], cumsum(n), n) # [[1]] # [,1] [,2] # [1,] -0.2080075 -0.0146956 # [2,] -1.5513436 0.2253790 # # [[2]] # [,1] ... -
实际上,我原来的配方并不是很好。 这作为套装更好。 import pulp # Input data A = [ [2, 1, 0, 0], [2, 0, 0, 0], [2, 1, 2, 2], [1, 2, 2, 2], [2, 1, 1, 0] ] # Preprocess the data a bit. # Bikj = 1 if Aij != Akj, 0 otherwise B = [] for i in range(len(A)): Bi = ...
-
如何从数据表中的列子集中提取唯一行?(How do I extract the unique rows from a subset of columns in a data table?)[2022-09-10]
至少对我来说最直接的是@Justin建议的unique(jk[c4 >= 10, list(c1, c2)])或者unique(jk[c4 >= 10, c("c1", "c2"), with = F]) 。 到目前为止,后者是四个建议中最快的,至少在我的笔记本电脑上: microbenchmark( a=jk[c4 >= 10, list(c1,c2), keyby = list(c1,c2)][,c("c1","c2"),with=F], b=jk[c4 >= 10, unique(.SD), .SDc ... -
相当难读,但它确实有效。 m <- 5 # Matrix dimensions k <- 2 # The index of the the inner square that you want to extract cc[(cc$x %in% LETTERS[c(k,m-k+1)] & !cc$y %in% c(1:(k-1), m:(m-k+2))) | (cc$y %in% c(k, m-k+1) & !cc$x %in% LETTERS[c(1:(k-1), m:(m-k ...