Sock quality modelling and optimisation?
June 14, 2007 7:10 AM   Subscribe

Let's say I buy s socks. Now, these socks feel the very best (have a quality factor of 100) after f wearings, and must be discarded (have a quality factor of zero) after f × 100 wearings. I want to add these socks to a pool from which I draw two daily, and want to maximise the probability of selecting socks with the highest quality over the life of the pool...

So, presuming I want a function which describes the quality of my socks... how do I model and optimize it? I've taken a few courses in basic calculus and statistics, but have no idea how to model this. What branch of mathematics deals with these sorts of problems, and what is a good (better?) example of an attendant/canonical problem for that branch?

This is not homework!
posted by TheNewWazoo to Grab Bag (24 answers total) 9 users marked this as a favorite
 
So is it a theoretical problem, or an actual problem you want to solve with your own socks?
posted by reklaw at 7:11 AM on June 14, 2007


I'm confused. If it's a random draw, there's no strategy, and if it's not a random draw, you would just pick the two socks with the max quality factor.
posted by smackfu at 7:16 AM on June 14, 2007


Response by poster: Well, I did recently buy a big bunch of socks, but I'm more looking for the first steps on how to model this, and maybe some further reading so I can grow my knowledge of these sorts of things (without having to get an Industrial Engineering degree).

Answers for this specific problem are, of course, appreciated!
posted by TheNewWazoo at 7:16 AM on June 14, 2007


Response by poster: It's a random draw from the pool, but I'm wondering if there's a way to optimise the addition of socks to (i.e. the size of) the pool. Would it be better to just add them all in at once? What if the socks' quality doesn't start at 100, but they must be "broken in"?
posted by TheNewWazoo at 7:19 AM on June 14, 2007


That seems kind of complicated to model mathematically. I'd go with Monte Carlo simulation!

Comrade "What do you expect from someone with my name" robot.
posted by Comrade_robot at 7:20 AM on June 14, 2007


If your sole goal is to maximize quality of sockwear, then the obvious solution is to buy a lifetime's supply of socks, outsource the wearing of the socks for the first f - 1 times, and then have a pair of socks with optimal f wear every day, discarding or selling them after that single wear.

If, on the other hand, you are seeking to maximize quality of sockwear subject to some financial constraint, then you're asking a different problem.
posted by commander_cool at 7:24 AM on June 14, 2007


And as you've asked the problem, you've left out some critical details. What's the shape of the Q path between 0 and f? What's the shape of that path between f and 100f? Linear? Exponential? Parabolic?
posted by commander_cool at 7:26 AM on June 14, 2007


It sounds like the OP is imagining a Lifetime Sock Quota, is assuming he wears all his own socks, and is asking how to space the individual purchases that make up that quota.
posted by nebulawindphone at 7:29 AM on June 14, 2007


This is similar to an equipment maintenance scheduling problem.

The answer is simple: laundry marking pen. You build a schedule wherein you wear your socks in a particular order on a daily basis. You mark each pair with a code that you will use (ie, on July 6th, I wear pair xyzzy). On July 6th, you pull out that pair.

You keep a number of pairs of socks in reserve and wear them for emergencies (downpour, red wine spill, etc) and mark them with a dot for each emergency wear so you know when to use them.

Ultimately, you'll just be doing a round-robin on your sock pool, continually tossing the worn ones and putting a new pair into rotation.

Or you could do what I do which is to buy socks in batches of 10 or 12 pair, filling the sock drawer and keeping the extras in a closet. When a sock is too old, chuck and cycle in a new one.

Or you could do what my friend Toby does, which is to never wear matching socks ever.
posted by plinth at 7:34 AM on June 14, 2007


Response by poster: commander_cool, let's assume that I have spent all of my money assuring that I have an infinite sock supply available to me, and can't afford to pay someone else to wear them those f - 1 times. Also, my math is rusty enough that I can't think of a way to describe the Q function except in a piecewise fashion, but let's assume it's linear between f = 0, peak Q, and 100f.
posted by TheNewWazoo at 7:47 AM on June 14, 2007


Best answer: Do you have a GOOD understanding of calculus? Then, you could read this book, which talks about how to formulate optimization problems. You could also take a class in optimization.

Basically, an Optimization problem has four main elements (examples in parenthesis):
1) Objective Function (Maximize the Quality of Socks I put on any given day for the next year)
2) Constraints (Subject to the constraint that the socks must be greater than z quality measurement and cannot be any greater than the maximum quality)
3) Parameters (Given that the sock quality varies according to a parabolic function over time, and that the maximum quality is fx100)
4) Variables (Maximize by changing or varying the number of socks I add to the pool in number X and time interval Y)

You can set this up in Excel using the Solver PlugIn. Play around with Solver a bit, it's fun!
posted by Eringatang at 7:56 AM on June 14, 2007 [2 favorites]


I'm only half joking, by the way. You could totally do this by Monte Carlo simulation.

* Write a computer program that tracks number of wearings of n pairs of socks, randomly selecting a pair of socks to increment by one each day. (Quality is a function of number of times your socks have been worn.) At the end, you can pretty simply find an average quality.

* Repeat this program a lot of times. The more times, the better the result. Nested for loops, baby.

* Repeat this program lots of times for different n. Another giant nested for loop.

* Let your computer run happily along. Come back when it's done. During this entire time, you are 'working', so do not feel guilty about sleeping in and watching TV. You are 'waiting for your simulation to finish.'

Can you tell that I am an engineer and not a math person? Yes.
posted by Comrade_robot at 8:02 AM on June 14, 2007 [1 favorite]


I don't know the canonical "here's the term for this" response, but I think your question is better put this way:

- Given a lot of X items, that each degrade linearly in quality Y from an initial 100 (new) to 0 (completely unusable), all of which begin this exercise at 100,

- Also given A is the quality value below which you will not use the items (note, this is not 0), and B is the value of optimal usability (note, this is not 100),

- If I randomly draw 2 of X items each day and decrease their quality by 1,

Here are the questions:

- How far into the process will I expect the first items to hit A?

- Assuming these are immediately replaced, at what point will the system become homeostatic (or whatever the mathematical term for this equilibrium is)? When this point is reached, how often, on average, will it occur on any given day that an item has reached A and must be removed?

- Complicated further: If I want to maximize the odds of drawing items within a given range of B+/-C, how does that change the system?

Again, I'm not a stats guy, but I know that if you break it down, there are a bunch of straightforward questions here.
posted by mkultra at 8:06 AM on June 14, 2007


Response by poster: Ooh, you make a very good point, mkultra - it simplifies the math a lot if I consider the quality curve to instead be a linear lifetime curve and then attempt to optimise around some point other than zero. I had been thinking of it in terms of peak Q being the peak of some curve which degrades with f.

Keep in mind, though, that the only control I have over the process is the rapidity with which I introduce new socks - after they degrade they're removed, but not necessarily replaced.
posted by TheNewWazoo at 8:12 AM on June 14, 2007


It seems to me that if you want to maximize the probability of selecting the highest quality socks when each sock has a set lifetime, then you won't do better than throwing the socks in the laundry after use, and not doing the laundry until all are worn. Wash them all, then start over. Of course, you will also maximize the probability of selecting the lowest quality socks later on, but the two maximums aren't mutually exclusive. You could bypass the low quality part by choosing to discard the socks before their arbitrarily determined lifetime of f x 100 wearings.

If you're just washing and throwing the socks back into a pool, then your selection is random, and there's no formula to maximize.
posted by weapons-grade pandemonium at 8:23 AM on June 14, 2007


If by "maximise the probability of selecting socks with the highest quality over the life of the pool", you mean "maximise the expectation value of the quality of the day's socks over the lifetime of the pool", then you can't. Every day you will wear a pair of socks, and so if you have s pairs of socks that you throw out after n wearings, that pool of socks will be exhausted after sn days. The average daily quality factor you can expect over this period, <Q(t)>, will just be the sum of the quality factor for each day divided by st. But the sum of the quality factor for each day is just the sum of the quality factor over the lifetime of each individual pair of socks, multiplied by s. This means that <Q(t)> over the lifetime of an arbitrary number of pairs of socks will be the same as it is over the lifetime of a single pair of socks.

Put another way, every pair of socks has a given amount of "quality" that it can dispense to you, and once the "quality" is exhausted you throw it away. Assuming that all the socks are identical, then, the average quality of the socks is unaffected by the number of socks you have in your drawer at a given time. It's possible, of course, that by clever addition of socks at appropriate times, you could minimize the variations of Q(t) from it's average value; but that requires more effort, and would probably depend on the shape of the individual quality curve for a pair of socks.

In conclusion, HI I'M ON METAFILTER AND I COULD OVERTHINK A SOCK DRAWER.
posted by Johnny Assay at 8:29 AM on June 14, 2007


Response by poster: Johnny Assay, you touch on exactly the crux of the problem - I'm not dealing with a pool of fixed size which can ever be exhausted. I have an infinite number of new socks to add to the pool at some (for simplicity's sake) constant rate, and the "clever addition" is precisely what I'm trying to optimise.
posted by TheNewWazoo at 9:18 AM on June 14, 2007


I do something sort of like this already with my socks. (Yes I mostly definately have overthunk my sock drawer). I enough socks to get me through a laundry cycle which are all identical. Each day I get to randomly choose to socks, but since I dont wash them until they all have been worn they all are at the same approximate quality level. One of these days I'll have to buy a fresh batch to replace them as they are startign to lose their quality. Two other considerations: my socks haven't really worn out particularly evenly since what you do in the socks makes a big difference, (e.g. a pair of socks you wear around without shoes on get considerably more wear) .
posted by vegetableagony at 9:32 AM on June 14, 2007


Best answer: Well, ok, as I understand the problem:
Each sock (or, pair of socks) has a quality function (q) which increases from 0 wearings through f wearings and decreases from f wearings to X wearings, at which point, it is automatically retired.

If you are trying to maximize total q (i.e. summation or integration of q over all days) using a random draw of a pair of socks, then one thing you do know:

once q drops below q0 (i.e. initial quality), it is optimal to retire that pair. If you can't track how many times you've worn a pair or directly compare q to a new sock, then there is a simple optimal addition scheme: without the addition of other constraints, the optimal solution (as I define it) is to introduce a single pair of socks every Y days, where Y is the number of days required for q to pass through its maximum and return to q0. At that point, you retire the pair of socks and add a new pair. (Yes, I'm suggesting the optimal solution is to wear the same pair of socks many days in a row; the desire to not do that is another constraint that needs to be quantified.)

If you cannot retire socks until they're at the true retirement age, the optimal solution is to wait until all the socks are of q < q0 and then add many socks to minimize your probability of getting the older socks. those additional socks have average q q0, you want to add many more still.br>
IAAEBNASE. (I am an engineering, but not a sock engineer). None of this is rigorous.
posted by JMOZ at 9:52 AM on June 14, 2007


I should mention that if q0 is the maximum quality (which is, in my opinion, the case for real socks), then the optimal solution is quite trivial: wear a new pair of socks every day and throw them out at the end of the day.

Of course, this is why real problems require additional constraints such as costs (cost of the socks, environmental impact, and the effort to buy enough socks to have an infinite supply).
posted by JMOZ at 9:54 AM on June 14, 2007


Response by poster: JMOZ, thank you for that response - now we're getting somewhere! It looks to me like the optimal solution that has no boundaries would be to infinitely dilute the pool with new socks at the q < qsub>0 boundary, but how can I prove that? And how would I extend that to a maximum pool size?

Any suggestions for further reading, anyone? :)
posted by TheNewWazoo at 11:13 AM on June 14, 2007


Best answer: When the objective function of an optimization problem goes off into infinity, one can call it "poorly constrained." If you want to prove it is poorly constrained, you can use monotonicity analysis, which is pretty simple to understand and in the first chapters of that book I mentioned by Papalambros and Wilde. There are papers out there that you can read, too, but the book does a good job. Monotonicity analysis can be tedious for complex problems, but since yours is pretty straight forward it should be doable.
posted by Eringatang at 12:23 PM on June 14, 2007


Any suggestions for further reading, anyone? :)

LOL, how about Introduction to Operations Research.
posted by neuron at 12:27 PM on June 14, 2007


The Hayekian (F.A. Hayek) answer to this would be: you know how many socks most people have in their sock drawers? About that many. That is to say, tradition compresses a lot of this sort of information so that we don't have to do algebra every morning just so that our socks fit.
posted by dagnyscott at 3:51 PM on June 14, 2007 [2 favorites]


« Older What are these hoofprints?   |   Hotel in Asheville NC? Newer »
This thread is closed to new comments.