小编Ale*_*lex的帖子

计算分支和绑定背包中包含的项目

使用分支定界算法,我已经评估了给定项目集的最佳利润,但现在我想知道哪个项目包含在这个最优解决方案中.我正在评估最佳背包的利润值如下(从这里改编):

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)

5
推荐指数
1
解决办法
5551
查看次数

刷新 Spring Data Repository 中的 Oracle 物化视图

在查询 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在调用此方法时遇到了问题,尽管它在直接在数据库上运行时工作正常。我在这里做错了什么?有没有其他方法可以强制物化视图刷新?

oracle hibernate spring-data-jpa kotlin spring-boot

1
推荐指数
1
解决办法
5539
查看次数

标签 统计

hibernate ×1

kotlin ×1

oracle ×1

spring-boot ×1

spring-data-jpa ×1