Knapsack problem/Continuous: Difference between revisions

m
changed a comment
m (changed a comment)
Line 379:
We might as well leave this one to the experts by setting it up as a
[http://en.wikipedia.org/wiki/Linear_programming linear programming] problem and handing it off to an external library (which will be either [http://sourceforge.net/projects/lpsolve lpsolve] or
[http://www.gnu.org/software/glpk/glpk.html gkpkglpk] depending on the run-time system configuration).
 
<lang Ursala>#import std
Line 403:
lower_bounds: *nS ~&\0., # all zeros because we can't steal less than zero
upper_bounds: ~&nmlPXS, # can't steal more than what's in the shop
costs: * ^|/~& negative+ vid, # valuesprices divided by weights, negated so as to maximize
equations: ~&iNC\15.+ 1.-*@nS] # 1 equation constraining the total weight to 15
 
Anonymous user