我是约束编程和 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)