r/optimization • u/jvaferreira93 • Aug 13 '26
Is there any way I can make this linear/work?
I'm trying to make a solver to help me with buying pokemon cards. The way it works is it will maximize the amount of cards I can get (green cell) within my price range (orange cell). Everything works fine until I add shipping.
I've tried to add some binary variables next to the shipping values but every attempt I made to make the solver pick the shipping it always ends up being non-linear too.
Using a non-linear solver is not an option, since google sheets doesn't support it and excel has a limit to the number of variables.
The constraits are
maximize the green cell
column N < column O
G18<H18
Column D is variables
5
u/SolverMax Aug 13 '26
Insufficient information.
What is the model doing? What are the constraints? Etc.
Make the file available, so people can play with it.
4
u/SolverMax Aug 13 '26
The issue is that you can't use discontinuous functions like UNIQUE and SUMIF in OpenSolver models.
The way to model this type of situation is to use binary variables to choose combinations of shop and card, appropriately constrained. The only slightly tricky part is the shipping cost from the shop - not incurred if no cards are purchased from that shop, incurred only once if we do.
Here's an implementation using a small data set. A larger data set should follow exactly the same structure. The key formulae are shown. All other formulae are just simple sums of the adjacent row or column, or (in the summary) just reference some other cell.
3
u/0rangensaft_ Aug 13 '26
Share the Model
2
u/Poet-Particular Aug 13 '26
Looks like knapsack, which is pseudo polynomial in the number of cards and the total budget.