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 .

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3549e-2bf73.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3549e-2bf73.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?