A traveler gets diverted and has to make an unscheduled stop in what turns out to be Shangri La.   Opting to leave, he is allowed to take as much as he likes of the following items, so long as it will fit in his knapsack, and he can carry it.

He knows that he can carry no more than   25   'weights' in total;   and that the capacity of his knapsack is   0.25   'cubic lengths'.

Looking just above the bar codes on the items he finds their weights and volumes.   He digs out his recent copy of a financial paper and gets the value of each item.

ItemExplanationValue (each)weightVolume (each)panacea
(vials of)Incredible healing properties30000.30.025ichor
(ampules of)Vampires blood18000.20.015gold
(bars)Shiney shiney25002.00.002KnapsackFor the carrying of-<=25<=0.25 



He can only take whole units of any item, but there is much more of any item than he could ever carry



Task

Show how many of each item does he take to maximize the value of items he is carrying away with him.



Note
 
   There are four solutions that maximize the value taken.   Only one need be given.


Related tasks

   Knapsack problem/Bounded
   Knapsack problem/Continuous
   Knapsack problem/0-1


/*REXX program solves the knapsack/unbounded problem: highest value, weight, and volume.*/
 
                           /*   value                   weight                   volume */
maxPanacea= 0              /*  ═══════                  ══════                   ══════ */
maxIchor  = 0;      panacea.$ = 3000  ;      panacea.w =  0.3 ;       panacea.v = 0.025
maxGold   = 0;        ichor.$ = 1800  ;        ichor.w =  0.2 ;         ichor.v = 0.015
max$      = 0;         gold.$ = 2500  ;         gold.w =  2   ;          gold.v = 0.002
now.      = 0;         sack.$ =    0  ;         sack.w = 25   ;          sack.v = 0.25
 
maxPanacea= min(sack.w / panacea.w,     sack.v / panacea.v)
maxIchor  = min(sack.w /   ichor.w,     sack.v /   ichor.v)
maxGold   = min(sack.w /    gold.w,     sack.v /    gold.v)
 
  do     p=0  to maxPanacea
    do   i=0  to maxIchor
      do g=0  to maxGold
      now.$= g * gold.$     +     i * ichor.$     +     p * panacea.$
      now.w= g * gold.w     +     i * ichor.w     +     p * panacea.w
      now.v= g * gold.v     +     i * ichor.v     +     p * panacea.v
      if now.w > sack.w  |  now.v  > sack.v  then iterate
      if now.$ > max$  then do;   maxP= p;          maxI= i;            maxG= g
                                  max$= now.$;      maxW= now.w;        maxV= now.v
                            end
      end  /*g  (gold)   */
    end    /*i  (ichor)  */
  end      /*p  (panacea)*/
 
Ctot = maxP + maxI + maxG;                 L = length(Ctot) + 1
say '    panacea in sack:'     right(maxP, L)
say '     ichors in sack:'     right(maxI, L)
say ' gold items in sack:'     right(maxG, L)
say '════════════════════'     copies("═", L)
say 'carrying a total of:'     right(cTot, L)
                           say left('', 40)     "total  value: "        max$ / 1
                           say left('', 40)     "total weight: "        maxW / 1
                           say left('', 40)     "total volume: "        maxV / 1
                                                 /*stick a fork in it,  we're all done. */