Optimisation/knapsack algorithm with multiple contraints in JavaScript

拟墨画扇 提交于 2019-12-03 21:53:45

Maybe this won't help your code, but it can help to modeling your problem. lets say decision variable is x[i] = binary.

max capacity:

sum{i in Object} weight[i]*x[i] <=capacity;

use exactly 8 objects:

sum{i in Object} x[i] = 8;

use max 3 object type:

sum{i in object} type[i]*x[i] <=3;

use max 3 object color:

sum{i in Object} color[i]*x[i] <=3;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!