Algorithm: similar to N SUM problem solving

topic description

similar to the problem of N SUM, the idea comes from a small task encountered in the work, abstracted out:
has m items, and gives the unit price of each item, P1 br P2, P3 br. Now there are n orders, and the total amount of each order is S1Magi S2, S3 br. SN (P < S)
now requires matching as many product price * quantity combinations as possible for the total Sn of each order. The left and right sides of the equation are as close as possible:
Sn=P1 quantity + p2 quantity +.

solution

solve the problem with python

Mar.28,2022

isn't that the backpack problem


A classic QAP problem can be implemented in many ways, and can be optimized in different ways according to different specific data.
if you implement a general version, you can use linear programming to solve the problem.

Python can be implemented through cvxpy .

Menu