Archive for December, 2007

Spirit of X-Mas in America

True story. The following overheard on my way into the Shaw’s on Locust St., where a cop (or rent-a-cop, they all look alike) was hassling what I could only guess was a suspected shoplifter (or generally suspicious mixed-ethnicity youth, etc.): “You walk into the store, you walk out of the store, you don’t buy anything… what is wrong with you?”

Clean Pile / Dirty Pile – laundry management system and method rev2

As mentioned in a recent post, I own a dresser, which has been stocked with clothing* approximately twice in the last 3.5 years. (Eek, Boston, has it really been that long?) I don’t know who came up with dressers, but they probably didn’t have a day job. “So wait, I’m supposed to take all the clothes, sort them, fold them up, put them into the dresser arranged into rows, close the drawer, open the drawer, unrow, unsort, and unfold just to put them back on again?” As I mentioned, the dresser seems to me like a pessimal clothing management system. In my extended bachelory singleness my clothing management strategy underwent gradual stages of simplification, to the Closet/Floor system, the Basket/Floor system, and ultimately the almost-pinnacle-of-perfection, the Clean Pile / Dirty Pile system.

This system operates on the principle of minimum change in entropy, or delta-S, resulting from the removal of mutually inverse intermediate states. Operations that require energy to transition the articles of clothing from a high-entropy state to a lower entropy state knowing that they will soon be returned to the exact same high-entropy state by an inverse operation are reduced out, with the realization that the energy expended to produce the low-entropy state is not recovered in the act of returning to the high entropy state**. Upon shedding clothing flagged as ‘dirty’ due to being worn a full day, said clothing is flung onto a designated Dirty Pile at a known location on the floor. Since the clothing will be loaded into the washer in this state, there’s no reason it should transition to any intermediate state before this time. After being run through the washer and dryer cycle, the clothing emerges in a substantially similar pile form, although now flagged ‘clean’ due to the wash cycle. The pile is transferred in its native, unmodified form to a Clean Pile in a separate known location on the floor. Again, since the next state of interest is “on the body”, superfluous intermediate states (i.e. “in the dresser”) are omitted.

Application of this system results in substantial savings over the Dresser system. Over time, however, several inefficiencies in this new system have become evident. To better explain these inefficiencies, a brief recap of the generalized solution is in order. The complete laundry cycle consists of three required tasks in a specified sequence: Wash, Dry, Wear. The Wash cycle adds complexity since the mixing of certain articles of clothing is discouraged (e.g. whites vs. colors) and a complete Dirty Pile rotation may require multiple non-parallelizable cycle permutations ((machine sturdy | machine delicate | hand) wash (warm | cold) (separately | with like colors)), dictated mainly by the number of clothing articles bought for you by other people, who don’t have to wash them and therefore need not pay attention to cycle compatibility with your existing articles ;-) . The Wear cycle has special requirements too. To complete successfully, this cycle requires nominally at least 5 elements to be simultaneously present (nominally 2x socks, 1x underpants, 1x pants and 1x shirt). Therefore, the total Wear task overhead is dominated by the time required to locate all (ahem, clean) of the required articles.

The noted inefficiencies of the basic Clean Pile / Dirty Pile system can thus be summarized as follows:

  • Application of heterogeneous clothing (light, dark) to a common Dirty Pile necessitates an additional sorting step before the pile contents can be applied to the washer
  • As the number of articles of a given type (as a percentage of the total Clean Pile) decreases, the time required to fetch the next article of that type from the pile increases according to O(N/n), where n is the number of remaining articles of the required type and N is the total number of articles in the pile.
  • A priori knowledge of the number of remaining articles of a given type (socks, pants, etc.) is not available. Since the search for an article terminates as soon as one of the article has been found (regardless of the percentage of the pile actually searched), the situation where n approaches zero can be reached without warning.

A few simple modifications to the system provide substantial improvement: Since the clothes destined for the dirty pile are already semi-sorted (white socks on feet, probably colored everything else except maybe shirt), and they have to be taken off and thrown in some direction anyway, expand the Dirty Pile to three separate piles: White, Colored and Weird. (The Weird pile encompasses the typical minority of hand wash, dryclean, flat dry and similar special-needs garments. It’s estimated that at typical acquisition volumes of Weird clothing by bachelors [i.e. gifts], this pile will take up to a month to fill and require rotation, producing a further optimization by reducing the total number of Weird cycles versus a unified 1-week pile containing one or more Weird articles.) The aim is to reduce the run-time of the sorting task by exploiting naturally-occurring states of partial sortedness in the clothing’s usage cycle, preserving such sortedness as it occurs and preventing the clothing from unnecessarily transitioning to a less-sorted state upon application to the Dirty Pile. Likewise, since the white and color piles are already homogeneous upon completion of a (wash/dry) laundry cycle, there’s no sense lumping them into a single Clean Pile and losing that hard-earned sortedness, so we create two Clean Piles, one for whites and one for colors. This subdivision of piles has most likely reduced the maximum size of a single pile to the level where it can be accommodated by an average bin or laundry basket, so we may now speak of clean/dirty “buckets” instead of piles. This prevents nearby amorphous piles from merging during an extended search as mentioned above, and most importantly, reduces the runtime of all O(n/N) cases by constraining N. The total number of pre-sorted piles/buckets may be dictated by the available space, but any nPiles>1 will yield improvement over the prior system. Finally, a small “reserve” pile, containing one pair of socks, one pair of pants, one pair of boxers, and one shirt, is defined. This pile is small enough to be kept in any convenient location, e.g. under the bed. Upon removal of a white or colored pile from the dryer, the contents of the Reserve pile are polled, and for each component not present, the first of that item dequeued from the dryer is added to the reserve. This is a very efficient process which avoids non-termination of the O(n/N) case where (n/N) is infinity.

* Clothing, n.: Something to satisfy my legal obligation to not be naked in pubic. :-(

** yeah, and parental units never took my argument for not making the bed because it will be unmade within 24 hours as a “clever optimization” rather than “willful act of defiance”, either.

Why Windows asks you for drivers again whenever you plug a USB device into a new port!

I found this today while searching on another USB-developer-related problem: "Why does Windows not recognize my USB device as the same device if I plug it into a different port?"

For those who can’t be bothered to click the link, this occurs if the device doesn’t specify a serial number in its USB descriptors. They decided in this case to treat each (device@port) pairing as a new device rather than the same device in case you had more than one of them; otherwise they would enumerate in a seemingly random order at each boot, and whatever software that interfaced with the devices would have them swapped half the time. Unfortunately, in solving this problem they created some new ones, namely the ol’ “hunt for the driver disk” everytime the device gets unplugged and you don’t remember which physical port it was plugged into before (or something else got plugged in there in the meantime), and the semi-common case where a vendor tries to avoid the driver hunt by every device the same/dummy serial number (e.g. 000000000) causing bizarre behavior (or bluescreens under Windows).

Which brings up the question of which path to choose for the V2 trance vibe… do I…

  • leave off the serial number field, forcing five-knuckle driver shuffle for every port the device is plugged into?
  • fill in the field with the same dummy value for each device? Thinking not an option since certain crappy OSes can’t handle this if more than one is ever plugged in.
  • create a unique serial number for every unit made? Would require some exhaustive/ugly scripting to rewrite the serial number in the .hex file before programming each device myself… the more likely approach would be Serialized Quick Turn Programming (chips pre-programmed from the factory), but this involves extra work, set-up fees and volume purchase requirements. Either way would require keeping track of used/unused numbers. Not to mention the privacy implications of any given “adult” application being able to uniquely identify a user by their vibrator’s serial number…
  • Create a ‘semi-unique’ serial number for each unit? Same hassles and expense as the previous, but not caring if a number is duplicated eliminates keeping track of the last used number in subsequent SQTP orders / etc., as well as most of the privacy concern. One approach would be to just increment the last byte of the SN on each programming, reducing the odds of n devices on the same machine causing a crash.

The good, the bad, and the ugly!

OK, I kind of forgot I have a blog here. Anyway, here’s a bulk update of the last few weeks.

Good:

Thanksgiving: HAL, LE and I went over to TvS’ place two doors down for a most excellent Thanksgiving dinner with their whole family and MP. They had turkey and all the trimmings; we (mainly meaning HAL) made a delicious garlic-roasted leg of lamb and brought it over. Later, fell into a wine-and-food coma for several hours (as expected!).

Narrowly escaped Jury Duty for the time being.

The upstairs bedroom floors are finished…I had no idea wood can be sexy! Check it out:

Only now do I find out I don’t have “before” pictures like I thought I did. Anyway, beneath the carpet we ripped up was a rough, ratty-looking layer of hardwood covered in scratches/gouges that appeared to be from someone dragging heavy furniture all over it (or possibly a large hammer and chisel ;-), and a healthy layer of white paint splotches from whenever the walls were painted. A Craigslist find by the name of M&T Floor Sanders transformed it with a good sand-down, seal and a few coats of polyurethane. Any traces of carpet staples, paint/crap, and most of the scratches are gone without a trace (although a couple really deep gouges are there for the duration). So as of a couple days ago HAL and I are officially moved in.

DTV: My shipment of Trance Vibe circuit boards came in the mail; I populated 2 units for testing. Nearly everything is going smoothly with it so far: they fired up and ran with only minimal code changes (mainly relating to I/O pins being moved around and a couple inputs added). In addition, the boards fit *perfectly* in the enclosures. One minor problem discovered is that if I want to add Blinkenlichten chips to any, I’ll have to buy a shitload of them and have them factory pre-programmed. I thought pressing the chips against an unpopulated footprint and hitting ‘program’ would work, but keeping all legs aligned and touching at once for this process is turning out to be non-trivial.

Xmas party:
Dragged Kr* along to the company ChristmasHoliday party; we had a great time. As is par for my company events :P we both got rather well lubricated (although no more than anyone else there, for sure!), did some dancing, and I came home with my tie around my forehead, ninja-style. My officemate won Bush Job of the Year for the pest-control system he rigged up in our office (to stop ants trying to nibble on our ficus, alternating strips of copper are wrapped around the trunk and wired up to a bench power supply. When the ants climb to the spot where they have to step on both at once, they drop…) The Xmas video somehow ended up on youtube :P

Bad:

*bump* *block* "Excuse me, would you like to take a minute to do something for the environment?"
"No thanks, I already polluted at work."

Crazy guys and rude panhandlers around Davis are multiplying, if the hivemind of Livejournal is to be believed. A thread HAL linked me to today discusses, and reveals some facts about, the one I’m most familiar with near Powderhouse.

My family (folks and brother) will be coming to Boston this weekend. This is a good thing :P But, it means I have to find ways to keep them entertained for the whole weekend, and also felt it necessary to make some token effort at straightening up the place before they show up, particularly my bedroom. I went so far as to put my clothes…in the dresser! (Now that it no longer lives in the kitchen of course.) After this took bloody ages, I quickly realized why Bachelor Tim stopped doing that, and instead adopted the highly efficient clean pile / dirty pile system. If anything, the dresser is a pessimal clothes management system. (I’ve made further optimizations to clean pile / dirty pile and will post the results soon! :P)

Ugly:

I got a response from GMAC about my complaint from that double-billing scam they’re running. “As a courtesy”, they agreed to refund me $20 of the $60 they stole (which comes out to $15 after registered mail). There’s probably a statistical model that calculates the minimum partial refund to make the average angry customer go away, but I’m at a loss as to who I would bother whining to next.

I’m tempted to print out my own little stuffer and enclose it with all future payments: “As a courtesy, I’ve decided to pay my bill this month.”