EatDrink.ash: Optimize your daily diet (and see how your old diet stacks up).

Since I am not going to embed a generalized linear program solver in KoLmafia or write one in Ash or extend Ash so that it can access an online solver I will use a "pick the best available item until a constraint is hit" algorithm and favor ease of implementation over mathematical optimality.

BTW, would you be interested in using a LP solver if I managed to write one in ASH? I haven't really given it much thought yet, but I *do* have one implemented in perl (did that several years back to help optimize in some other games). Unless it uses PDL, BigRat(ional) numbers, or some weird array structures, it shouldn't be very hard to rewrite in ASH, maybe. Though I suspect it won't be very fast.
 
BTW, would you be interested in using a LP solver if I managed to write one in ASH? I haven't really given it much thought yet, but I *do* have one implemented in perl (did that several years back to help optimize in some other games). Unless it uses PDL, BigRat(ional) numbers, or some weird array structures, it shouldn't be very hard to rewrite in ASH, maybe. Though I suspect it won't be very fast.

You're crazy. Of course I don't have my notes at hand but my recollection of the problem I wanted to solve was Maximize the expected number of adventures gained subject to the constraint that the consumption fullness did not exceed a threshold and the expected cost did not exceed a budget. I think every value, except expected adventures, will be constrained to be a non negative integer (which makes it an integer program) and the constraints are inequalities thus requiring slack variables. There is a part of me that would be interested in having it look at food, drink and spleen all at once (because of the budget constraint).

But yes, if you port your solver to Ash, I'll try and use it. I agree that speed will probably be an issue. Thanks.
 
Oh right. *Integer* programming. That would be a problem ... you don't want to eat only 2/3 of a 3-fullness food so that you can stuff in another. I will have to look into other algorithms for that ... I remember being taught several ...
 
Oh right. *Integer* programming. That would be a problem ... you don't want to eat only 2/3 of a 3-fullness food so that you can stuff in another. I will have to look into other algorithms for that ... I remember being taught several ...

Talk about a veer. I have a vague recollection that there is no good IP solution - NP hard - but there are some usable algorithms that use an optimal non-integer solution as a starting point, grow a tree of nearby integer constrained solutions and prune the tree until you an optimal solution is found. I only had to code the Simplex Method and that was long enough ago that FORTRAN 66 was the language of choice unless you had access to the Computer Science department and could finagle access to ALGOL W.
 
That's one way of doing it (i.e. ... if non-integer optimal x1 = 1.2865, try solving the problem again (recursively) with the added constraint x1 <= 1, and again with the added constraint x1 >= 2, and compare the two solutions; there are also much more efficient ways of calculating what the added constraint should be).
But I should also have notes on methods that work completely in integral matrices, and look a lot like a normal (dual) simplex algorithm (no branching, no recursion, still guaranteed completion).

The biggest efficiency snag there would probably be the sheer number of consummables, unless you weed out the inferior ones even before constructing the integral program (like: if two consumables are exactly the same (size, adventures, cost) pick only one of them (at random); if one is at least as big as the other and doesn't give more adventures and costs more, consider only the other, ...).
 
I'd love to see the complete problem addressed first. Premature optimization tends not to be a good thing. That said, there are several possible ways to reduce the number of consumables if performance suggests that needs to be done. As I think about the equivalency idea proposed I note that I forgot to include availability as a constraint on the number of items that can be consumed. That probably drives the problem for players that do not have Mall access.
 
I am still getting an infinite loop sometimes from the files in the first post.
I don't mind if it is more optimized or less optimized (As long as it doesn't spend > meatPerAdv*advPerFulDrunk), but the infinite loop error is driving me mad. Are the files in the first post the most uptodate versions?
 
Nope. Either pull the version I posted a few above (post 610), or follow fronobulax's link in post 621 and download there. The first post is horrifically out of date. :)
 
I'd love to see the complete problem addressed first. Premature optimization tends not to be a good thing. That said, there are several possible ways to reduce the number of consumables if performance suggests that needs to be done. As I think about the equivalency idea proposed I note that I forgot to include availability as a constraint on the number of items that can be consumed. That probably drives the problem for players that do not have Mall access.

At least the "get rid of duplicates" part is almost definitely not premature optimalization - even the non-integer LP solver has problems with degenerate matrices.
...
Or you can impose a tiebreaker by putting small (but different) objective function coefficients on the item availability slack variables (constraint: amount_consumed_i + slack_variable_for_amount_consumed_i = amount_available_i).
 
Why do I get this error
> eatdrink.ash

Value expected (zlib.ash, line 98)

> eatdrink_modified.ash

Value expected (zlib.ash, line 98)
 
Probably not using latest zlib and/or mafia. You either need to have both be the version from before a week ago, or both newer.
 
I decided to run this after updating zlib and the eatdrink script to the latest version. I was a HC level 12 saurceror and upon running the script it created milk which it then ate, then it created fettucini inconnu which it then ate and finally it created long pork casserole which it ate.

At that point it went into a loop where it tried eating another long pork casserole (which did not exist). The script then began reporting encountering an error saying no long pork casserole and your not able to shop. It then loops until I stop the script myself.

Is it because I am in HC?
 
Nope, it's because your inventory got screwed up... refresh inv, then run the script again. If it's still confused, try refresh all.

Basically, mafia's inventory awareness gets off sometimes, but the script is working based on what mafia tells it. I had the same issue come up a few weeks back.
 
refresh inv, then run the script again. If it's still confused, try refresh all.
This is voodoo advice. If there is a problem with inventory, "refresh inventory" will fix it. Since "refresh all" does nothing to inventory - and even if it did, it would be exactly the same thing as "refresh inventory" does - it is completely pointless to do it in the superstitious hope that it will magically fix your problem.

Basically, mafia's inventory awareness gets off sometimes, but the script is working based on what mafia tells it. I had the same issue come up a few weeks back.
I have never had a problem with "inventory awareness" since ... well, I can't remember ever having such a problem. If you have such a problem, how about looking in your session log and telling us what you've been doing?
 
Back
Top