小编Bha*_*thi的帖子

如何基于决策变量(一个用于行,一个用于列)从矩阵(python 中的列表列表)中选择一个元素 | 或工具,Python

我是约束编程和 OR-Tools 的新手。关于问题的简要说明。有 8 个位置,对于每个位置,我需要决定应选择哪种类型 A (move_A) 的移动和类型 B (move_B) 的移动,以便从 2 个移动的组合(在每个位置)获得的值是最大化。(虽然这只是更大问题的一部分)。我想用AddElement方法来做子设置。

请看下面的尝试

from ortools.sat.python import cp_model
model = cp_model.CpModel()

# value achieved from combination of different moves of type A
# (moves_A (rows)) and different moves of type B (moves_B (columns))
# for e.g. 2nd move of type A and 3rd move of type B will give value = 2
value = [
            [ -1,  5,  3,  2,  2],
            [  2,  4,  2, -1,  1], 
            [ …
Run Code Online (Sandbox Code Playgroud)

constraint-programming or-tools

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

标签 统计

constraint-programming ×1

or-tools ×1