Shopping at LEGO or Amazon?
Please use our links: LEGO.comAmazon
As an Amazon Associate we earn from qualifying purchases.

Automated BrickLink cost minimization program available

13567

Comments

  • Erinlyn80Erinlyn80 Member Posts: 29
    Im a little confused. When I want to buy a lot of wishlist things from 1 seller there's a search you can run "my wanted list by shop" and then I just look at the ones with the most hits. Granted this is indeed time consuming. I'm not sure I understand all the logistics but it sounds like you're on to something.
  • atxdadatxdad Member Posts: 68
    @dustinmroberts Yes, there is a way to blacklist/whitelist specific vendors, but it is an advanced feature not enabled by default. At the top of the script merge_price_guide_data.m, change the value of variable 'usevendorpruninglogic' from 0 to 1. During execution, you will be presented with the option to forcibly include/exclude vendors from the search space.
  • maquesmaques Member Posts: 96
    Now... Manually mapped the missing ~80 pieces, mainly the minifig heads/torsos/legs, so I can say we have a final version of pablist-us.bsx. Or at least final-beta-preview - codename Cafe Corner :-) - version...

    http://maques.hu/lego/auto-pab/pablist-us.bsx

    All item matched to a BrickLink item, hopefully to the same item, but miracles can happen anytime...

    BrickStore loads the file without error, but I had to change the ID of the otherwise proper BrickLink item "Tire 21mm D. x 6mm City Motorcycle" from ID 50861 to its former ID x1436 (changed May 27 this year)- as BrickStore was complaining about it. Now with x1436 it loads, but no pic there. So reported to BrickStore, might expect an update.

    Any suggestions, comments, etc. welcomed, here or pm.
  • atxdadatxdad Member Posts: 68
    To those following development, I have prepared another distribution package with most changes related to supporting Lego Pick-A-Brick as a candidate vendor. The efforts of @maques in creating a PAB part/price database for us now makes it very easy to shop PAB in the US, and with his permission I have included that database in the latest distribution. Thanks for the continued feedback and suggestions.
  • maybertsmayberts Member Posts: 68
    ^ Will this work for PAB UK?
  • maquesmaques Member Posts: 96
    edited July 2012
    PAB store seem to sell the same parts in all country.
    The only difference is the price, but they are pretty balanced (biggest difference is 24% compared to the cheapest country/currency).
    The PAB-bsx list is in USD but you can pretty much calculate with those prices on the cross rate. If it would be useful, I can make a GBP bsx too, though I don't know how the script calculates.
  • atxdadatxdad Member Posts: 68
    @mayberts The script that reads the PAB inventory assumes prices are saved in the same currency as will be imported from BrickLink. If PAB prices are only available in US$, you could open the PAB .bsx in BrickStore and do a global Edit/Price/Increase/by% to scale everything by the current dollars/pounds exchange ratio.
  • dustinmrobertsdustinmroberts Member Posts: 35
    I've mentioned this to @atxdad, but I figured I'd mention it here as well just in case anybody wants to take a shot at it.

    This program would gain much more usability (for me at least) if there was an option to use it for minifigures. I'm primarily a figure collector, so to have a program that would take the hassle out of trying to find lowest costs across BrickLink would be invaluable.

    Just thought I'd throw that out in case someone wants to try and implement this feature.
  • DadsAFOLDadsAFOL Member Posts: 617
    @dustinmroberts are you trying to build minifigs from pieces, or just purchase a bunch of minifigs?
  • dustinmrobertsdustinmroberts Member Posts: 35
    @DadsAFOL I mostly buy figures complete, but I have been known to buy them by parts and build them that way (and I know the program will do the figure parts just like any other piece, it's the full figures that I'm looking to get support for)
  • LegoFanTexasLegoFanTexas Member Posts: 8,404
    Has any further work been done towards a standalone program to do this?
  • RikTheVeggieRikTheVeggie Member Posts: 356
    @LegoFanTexas - I'm hoping to take a look at this soon but personal commitments and the myBrickset app are taking all my time atm.
  • LegoFanTexasLegoFanTexas Member Posts: 8,404
    ^ What would it cost to develop such a program? I'm curious if there is a business model here. Would people pay $5/month or $50/year for a program like this?

    Another issue is that if too many people are using this, it may well drive up prices as more people Bricklink sets and buy up all the inventory for specific in-demand sets.
  • DadsAFOLDadsAFOL Member Posts: 617
    ^ LFT, as you know I've got a "superstore" on BL. I've been emailing with Chris a little bit with some ideas. His program is great for small wanted lists and small sets of stores with availability. The problem is that as any of the variables grow, even with the "pruning" algorithms he has in place, the run time gets unmanageable. I've got an 11-item list running right now, all common pieces. I got a 1-vendor solution instantly (Lego PaB) for $25, a 2-vendor solution nearly instantly for $12.90, a 3-vendor solution in 20 minutes for $10.84. But the 4-vendor solution has been running over 24 hours working through 170,000,000 possible combinations. If I ran the 5-vendor, which I won't, it might take weeks. I realize there are ways to more aggressively prune this, use whitelists, etc., but the exponential principle is the same. I'm running this on a new 8-core processor machine. In order to make this a viable business model, you would need a huge number of parallel processors in order to support cuncurrent "customers" and return a solution in a reasonable timeframe. All to save people a few dollars on a purchase. I'm not giving up on it, but at this point it's not viable to use in the day-to-day business of restocking my store.
  • LegoFanTexasLegoFanTexas Member Posts: 8,404
    ^ Thanks for the information...

    I would love to sit down and look at the algorithms it is running, it makes no sense to me why it should take this much time to run. 170 million possible combinations is not actually very many, modern CPUs can do hundreds of billions of floating point operations per second, which of course isn't the same as running combinations that fast, but it shouldn't take 24 hours to run either.

    380K bricklink stores, times all the inventory, clearly getting a quick result is all in how the algorithm is designed to run, what it prunes first, etc.

    Do you know how much work has gone into making it smarter, rather than just brute forcing it? (which I would agree would take a long time)
  • DadsAFOLDadsAFOL Member Posts: 617
    ^ Quite a bit but I'll defer to Chris to answer that one. I asked him a similar question offline.
  • fy222fy222 Member Posts: 202
    It is more than 170mil. (380k C 4) times 4 to the power of 22...
  • LegoFanTexasLegoFanTexas Member Posts: 8,404
    Hmm...

    My first thoughts would be to sort the bricklink inventory by best price per part, after all that is what we care about most, right?

    So you would have a long list of parts in a database, with the lowest price listed first, rather than sort by seller.

    Lets just say you want to bricklink UCS Falcon... Picking used, Bricklink gives us a part out value of $1,001.49 including 5,172 items in 267 lots.

    So how do we run a search for that?

    Some of those parts have over 100 in the set, others have just 1, with lots in between. Clearly some are common as dirt, others are very rare.

    If you run the search using lowest price first, you'd probably get 50 different sellers, which of course isn't very useful. Then you need to prune that list, take the seller with the most in stock first, look in their inventory for everything else they sell that is in the wanted list, anything that is within say 10% (user adjustable of course) of the lowest price, add it to the buy and remove from the cheapest seller. Then repeat with the next largest seller in the list.

    Will that get it down to 3 or 4 sellers? Maybe, maybe not, but for UCS Falcon, buying it all from 3 sellers is probably not going to happen anyway, so perhaps 5 to 10 sellers is reasonable for that.

    This sort would work very well if you did multiple sets at one time, say UCS Falcon, UCS ISD, and UCS Death Star II. With all the overlap between those sets, you'd get more orders worth doing.

    Of course, I'm thinking of big orders, even if you had 30 different orders, if you were donig the parts for all three sets, that is 10,000 parts, those orders are big enough to be interesting.

    I honestly haven't considered smaller lots, say 10 lots of 100 parts, but I'd think that is small enough to do manually, or the math on it would be so simple, you could brute force it, but I honestly haven't thought about it that much.
  • LegoFanTexasLegoFanTexas Member Posts: 8,404
    Wow, just looked at the gray boat rigging cost for UCS Falcon, those things are EXPENSIVE...

    I just looked at the Black Pearl which my wife built, same part, but a whole lot less money.

    I wonder if you could spray paint the black part to gray and just use that?

    Doesn't someone already make custom Lego compatible parts? I see that Brickforge makes minifig accessories, but not bricks. I am wondering how hard it would be to make a replica of the gray boat rigging?

    If they could be made for a dollar or two each and sold for $10 each, would there be a market for that if they were close enough?
  • fy222fy222 Member Posts: 202
    ^there might be a market for the SDCC exclusives... Better margin!
  • CombeeCombee Member Posts: 19
    I've had some good experience using this with 3 vendor searches, but when I went up to a 4 vendor search (for a ~30 lot list) it ended up taking about 45 hours (on a dual-core computer) and I couldn't use the computer for anything else because everything was bogged down. Great program though and I'm looking forward to updates!
  • LegoFanTexasLegoFanTexas Member Posts: 8,404
    I looked back at the start of the thread, I must have missed it, where do you download this program?
  • Bosstone100Bosstone100 Member Posts: 1,431
    From my perspective, if you are going to use this program to restock your bricklink store, you should have to pay Chris for its use. He has put a ton of work into it and it would sadden me to see such useful utility for collectors/builders turn into commercial software... unless of course Chris gets paid for it.

    In fact, this can only be bad for the collectors/builders because then the part prices will go up. I can't see a reseller buying parts and then selling them for the same price or taking a loss.
  • maquesmaques Member Posts: 96
    Let me add my experience and "advices", mostly to @LegoFanTexas 's brainstorming.
    I BL-ed some dozen of 3300003 recently, without using the $subject, just by using my scripts (to get prices from BL [best 100x lot world, best 1x world, best 1x europe, best 1x local country]), excel and brain.

    So some [I believe] useful thoughts for any future manual or automatic algorithm:
    - If there are no X (10, 25...) shops/sellers for a part, then it can be considered rare
    - If there is no X (100...) pcs lot available at any shop, then part can be considered rare
    - Consider getting rares from LEGO "replacement order" (if possible)
    - You must NOT look up for the most expensive part, but for the most expensive lots, eg. 100x of something "not-so-expensive" should be prioritized over 1-2 pcs of some "mildly expensive" part
    - Start with the "expensive lots" and once the rest lots' prices are lower than a shipping cost, then add those to any existing order (by best price)

    I was thinking about making such a program, ended up that it should be an online application for the GUI, then run the queries - to get prices from BrickLink - and the calculation on the server where GUI is running, - likely in the background -, and get back the result online [+downloadable/mail, etc].
    Then ended up with the thinking, that the best would be if this was programmed on Bricklink :-]
  • TyoSoloTyoSolo Member Posts: 539
    edited July 2012
    @atxdad Have you considered a kickstarter or indiegogo (if you want paypal) for this to give it a proper executable or cloud based release with the backing of this community? I know I'd donate to have a polished programme with automatic updates.

    Consider that your first $20 pledge if you did it.

    Regards

    Rich
  • LegoFanTexasLegoFanTexas Member Posts: 8,404
    ^ ditto, I would give money to that as well, but if Chris wanted to do a professional program, I would consider funding the whole thing if there was enough interest and I saw a business model.

    The only condition is that we would need bricklink's approval and a commitment that they would not copy it. In return, we would provide part of the revenue to them to help them make money as well.
  • atxdadatxdad Member Posts: 68
    The program was developed by a fan for fans. It is my gift to the LEGO community, and I have declined donations up to now because I do this as a hobby.

    However, I recognize that converting the code into an executable would make it available to a larger audience and let it run much faster, but that is beyond my skill set. Matlab has the ability to insert C++ code into its scripts, and converting just a few key functions into compiled code would immediately improve run times. I was hoping some programmers in the community might be able to help in that regard, and donations for their efforts would be appropriate.

    That said, trying to monetize this at the expense of buyers in what is already an expensive hobby is not my intent. Current web tools give sellers the advantage; this program tries to balance that by giving buyers information not available anywhere else.


    Regarding run times, I think the mathematics involved demand some respect. The heart of the search is an N CHOOSE K problem. When searching a list of common parts, the number of vendors selling those parts (the 'N' in NCHOOSEK) can easily be several hundred. As an example, if you have 300 vendors from which to find the best 4-vendor solution, one must check 330,791,175 combinations. Now for EACH of those millions of combinations, one must sum the quantities for all desired parts over all vendors and compare to desired quantities. Lastly, all combinations that meet quantity thresholds must be product-summed to calculate a cost.

    In efforts to limit run times, I have used Matlab's profiler to optimize and have rewritten key parts of the code several ways to see what's fastest. However, the most significant gains are made by reducing the vendor search space 'N'. Therefore, I included tools for intelligently pruning the vendor list to any size (and run time) desired. However, note that ANY method of pruning, sorting, etc. that does not brute-force check all the combinations cannot guarantee with mathematical certainty to find the lowest price. But maybe it's close enough. :)
  • TitusTitus Member Posts: 79
    I want to say thanks to atxdad for putting together this awesome script. I haven't yet bought anything using it, but it is a great tool.

    The only thing I was wondering was if there could be an option to show store results that have most, but not ALL the parts on your list. I have the feeling that one or two of the items on my list are holding me back from getting any results.

    I can remove items here and there and re-run the program, but it starts to feel like trial and error which was the original difficulty in manually BrickLinking in the first place. My other option seems to be increasing the number of stores to search to 5 or more, which should take care of a single piece which is holding me back, but once I get to that many stores, the processing time goes through the roof.

    Thanks again atxdad. Very cool scripts!
  • atxdadatxdad Member Posts: 68
    @Titus Fortunately, BrickLink already provides us with a way to show which store has the most parts on your wanted list. Just go to the Wanted/By Shop tab and you should see stores sorted by the number of parts available.

    My script also has a feature that will help you identify any rare parts on your list that may be preventing a solution. Set the 'usevendorpruninglogic' flag in merge_price_guide_data.m, and the diagnostics will include a list of how many vendors are selling your rarest parts.
  • LegoFanTexasLegoFanTexas Member Posts: 8,404
    atxdad said:

    The program was developed by a fan for fans. It is my gift to the LEGO community, and I have declined donations up to now because I do this as a hobby.

    However, I recognize that converting the code into an executable would make it available to a larger audience and let it run much faster, but that is beyond my skill set. Matlab has the ability to insert C++ code into its scripts, and converting just a few key functions into compiled code would immediately improve run times. I was hoping some programmers in the community might be able to help in that regard, and donations for their efforts would be appropriate.

    Thank you for the effort you have put forward... I completely understand what you're saying about fan designed for the fans of Lego, I think that is great.

    My comments about spending money on development simply have to do with producing an easy to use program that can be run by anyone, that has compute times that are reasonable.

    Of course that costs money, so someone has to pay for it. :)
    atxdad said:

    Regarding run times, I think the mathematics involved demand some respect. The heart of the search is an N CHOOSE K problem. When searching a list of common parts, the number of vendors selling those parts (the 'N' in NCHOOSEK) can easily be several hundred. As an example, if you have 300 vendors from which to find the best 4-vendor solution, one must check 330,791,175 combinations. Now for EACH of those millions of combinations, one must sum the quantities for all desired parts over all vendors and compare to desired quantities. Lastly, all combinations that meet quantity thresholds must be product-summed to calculate a cost.

    I agree with you completely, but 330 Million combinations should not take hours to search, modern CPUs are able to do that kind of math in very little time. Of course running those combinations takes more than doing a floating point math problem, but a modern Intel CPU can exceed 100 Billion FLOPS (floating point operations per second), clearly there is some slow code in there somewhere.

    Not your fault, this needs to be rewritten in at least C++, or perhaps something newer such as C#. Assembly Language is of course best, but that takes time and skill, and costs money.
  • TitusTitus Member Posts: 79
    atxdad said:

    My script also has a feature that will help you identify any rare parts on your list that may be preventing a solution. Set the 'usevendorpruninglogic' flag in merge_price_guide_data.m, and the diagnostics will include a list of how many vendors are selling your rarest parts.

    I'll check that out. Thanks!
  • atxdadatxdad Member Posts: 68
    edited July 2012
    For those following this development, know that I've assembled another package for distribution. So what's new in this version?

    1) MINIFIGURES and SETS - The search can now find those item types in addition to parts. Sticker sheets are now a viable search option too.

    2) Faster run times - I found a way to reduce the vendor search space WITHOUT risk of missing the best solution by doing a pre-comparison of all possible vendor pairs before starting the final search. Speed improvements are anywhere from 5% to 90%(!) dependent upon what's in your wanted list.

    ..plus some other diagnostic and usability features per user feedback. Thanks, all, for your continued interest.
  • caperberrycaperberry Member Posts: 2,226
    Been many weeks since I read this thread and it's so great to see the encouragement for Chris rolling in and his multiple improvements.

    I've nothing new to add. Just wanted to share the love! I predict big things for this script.
  • dustinmrobertsdustinmroberts Member Posts: 35
    This just got more dangerous (for me and my wallet!) Thanks @atxdad!
  • td8981td8981 Member Posts: 6
    I'd like to add my own (very late) thanks to Chris for making such a spectacular little tool. The regular updates emailed right to everyone are just above and beyond on his part.

    Over the past few weeks I've bricklinked up 90% of a MF, for about $600 (with a few small color changes to the superstructure). When Brickstore gives average cost as being over $1k, that's an amazing savings. Similarly, tonight I spent maybe 2 or 3 hours running the parts list for the Eiffel Tower, and I've got a 5 seller solution for $270, excluding only the 250 fence pieces (which I'll get from LEGO Direct). If I remember correctly, that's actually less than the original retail price on the set.

    For people new to using this, I've found it most efficient to do some prep on your wanted lists before you begin. My strategy has been to first separate known rare and expensive parts into their own list. I split the remainder of the wanted list into smaller sub-lists of maybe 75 lots. I save vendors in each sub-list's solution, and finally run the total list with the known vendors included, and some extreme pruning of the master vendor list (I aim for around 50-60 vendors).

    Occasionally while running through sub-lists, you'll come across parts with very few vendors, or that you need very high quantities of (say, over 200). I've been moving them to the rare parts wanted list, and handling the items on a case by case basis. Sometimes a vendor you're using will have them, sometimes it's easier to find the cheapest available.

    The Eiffel Tower was an interesting case of high part counts affecting the price: a 5 vendor solution of the first half of the model came to about $500. With all parts I needed over 100 of (maybe 15 lots or so) moved to their own wanted list, I was able to get the cost on that half of the model down to about $190. What I'm assuming happened is that there was no way to source all of the parts in the first case without using high priced bulk vendors, because of limited slots in the solution (Of course, that's just my guess; there very well may be some other interaction there I'm completely missing).
  • LegoFanTexasLegoFanTexas Member Posts: 8,404
    The dark bley fences are indeed the problem with Eiffel Tower, the only vendors on Bricklink with those in bulk want crazy prices for them.

    So you either have to get them from Lego, or find something else that works, or pay that crazy price.

    So the question becomes, is that part one that TLG still makes? Will it continue to be available for sale from them?

    BTW, original retail for Eiffel Tower was $199, or about the same price per part as Tower Bridge is today.

    Given that Tower Bridge is made up of so many cheap parts, I expect we'll see it do about as well as Eiffel Tower and Taj Majal on retirement, and be just as cheap to bricklink if you're so inclined.
  • td8981td8981 Member Posts: 6
    LEGO Direct does still have the fences currently, the part is in the Medieval Market Village, along with both Cargo Trains. The girl on the phone sounded a little surprised at the amount of them I wanted, but (fingers crossed) I haven't heard of any problems yet.

    I wasn't sure if it was $200 or $300 originally. Still, I won't argue with paying as much as I am, a used complete set is 5-6.
  • dustinmrobertsdustinmroberts Member Posts: 35
    @atxdad I was playing around with the new minifigure function, and I noticed that if you save wanted lists for sellers in a given solution, it labels everything as a Part instead of a Minifigure - this throws off BrickLink when trying to do a mass upload, and the only way to fix it is to open each sellers list and manually change each "P" to a "M"

    Just though you'd like to know. I haven't tested this with Sets, but I would assume it does the same. Other than that, everything seems to be working great (and faster!)
  • atxdadatxdad Member Posts: 68
    @dustinmroberts Ah, you're right. I know where that is in script makewantedlist.m and it's an easy fix. I'll send out an update soon that also includes a more recent Lego PAB inventory database as prepared by @maques.
  • justmichaeljustmichael Member Posts: 12
    My apologies if this is such a basic question ... but is there a way to export Bricklink wanted lists into Brickstore in order to create the .bsx files for this script?

    I swear I've tried to find a method for doing so but haven't been successful.
  • atxdadatxdad Member Posts: 68
    @justmichael I don't think so, and I assume that you too have checked all the options under BrickStore's File/Import menu. If your wanted list resembles a set you are trying to part-in, importing a 'set inventory' and modifying it might save you some time.
  • justmichaeljustmichael Member Posts: 12
    Thanks for the comment, @atxdad (and the awesome script).

    I'm Bricklinking my first project (Green Grocer) and trying to get the workflow down. I've discovered creating wanted list in Bricklink, searching Bricklink vendors for the wanted parts, and removing items from the wanted list after receiving them. The missing link I have is between the Bricklink wanted list and the Brickstore program (which allows me to create files to feed into this script).

    It sounds like I'll have to keep the two lists (Bricklink wanted list and the Brickstore list) in sync manually.
  • TitusTitus Member Posts: 79
    I think I have a similar question/issue as justmichael. I was looking at a set on rebrickable.com and seeing what parts I needed. Rebrickable will come up with XML text to be input into Bricklink, but what I'd like to do is get the rebrickable info into BrickStore or the Matlab scripts.

    Is there any way to do that? Any way to convert the XML text from Rebrickable into something that Brickstore or these scripts can read?
  • Bosstone100Bosstone100 Member Posts: 1,431
    @justmichael - I think it'd be easier to use Brickstore to keep your inventory instead of messing with the wantlist on bricklink. Once you update your Brickstore file, just copy and paste it to replace the older wanlist. Worked for me quite well when doing Cafe Corner.
  • dustinmrobertsdustinmroberts Member Posts: 35
    @Titus - BrickStore will let you import BrickLink XML files (which is what you're downloading from rebrickable). From there, you just need to save the BrickStore file as a .bsx and you can use it in the Matlab script
  • TitusTitus Member Posts: 79

    @Titus - BrickStore will let you import BrickLink XML files

    I thought it should, but I haven't been able to figure that out. None of the "import" options seem to do that and I tried saving the Rebrickable info into a txt file, renaming it as various file types and opening it with Brickstore, but that didn't work either. I must be missing something somewhere. Can you tell me how to do that?

    Thanks
  • dustinmrobertsdustinmroberts Member Posts: 35
    On my copy of BrickStore, there's an option for it.

    File>Import>BrickLink XML
  • TitusTitus Member Posts: 79
    I'm using v1.1.16 on a windows machine, but I don't have that option. Hmmm...
  • TitusTitus Member Posts: 79
    Ahhhh, are you using the "Commercial use" version? I am using the free "private use" version. Maybe that's the difference.
  • dustinmrobertsdustinmroberts Member Posts: 35
    I am using the commercial version, which probably is the difference.
Sign In or Register to comment.

Shopping at LEGO.com or Amazon?

Please use our links: LEGO.com Amazon

Recent discussions Categories Privacy Policy Brickset.com

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Brickset.com is a participant in the Amazon Services LLC Associates Program, the Amazon.com.ca, Inc. Associates Program and the Amazon EU Associates Programme, which are affiliate advertising programs designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.

As an Amazon Associate we earn from qualifying purchases.