使用分支定界算法,我已经评估了给定项目集的最佳利润,但现在我想知道哪个项目包含在这个最优解决方案中.我正在评估最佳背包的利润值如下(从这里改编):
import Queue
class Node:
def __init__(self, level, profit, weight):
self.level = level # The level within the tree (depth)
self.profit = profit # The total profit
self.weight = weight # The total weight
def solveKnapsack(weights, profits, knapsackSize):
numItems = len(weights)
queue = Queue.Queue()
root = Node(-1, 0, 0)
queue.put(root)
maxProfit = 0
bound = 0
while not queue.empty():
v = queue.get() # Get the next item on the queue
uLevel = v.level + 1
u = Node(uLevel, …Run Code Online (Sandbox Code Playgroud) 在查询 Spring Data Repository 之前,我需要刷新 Oracle 数据库中的物化视图。我尝试通过存储库中的函数和本机查询来执行此操作,如下所示。
@Query("BEGIN DBMS_SNAPSHOT.REFRESH('MY_VIEW', 'C'); END;", nativeQuery = true)
fun refreshMaterializedView()
Run Code Online (Sandbox Code Playgroud)
但是,我java.lang.NegativeArraySizeException在调用此方法时遇到了问题,尽管它在直接在数据库上运行时工作正常。我在这里做错了什么?有没有其他方法可以强制物化视图刷新?