Expectation Gap

NPR had a great interview with Wes Moore a few weeks ago on his new book. There was an especially poignant idea in the interview though: that expectations are what bounds us.

Do you think we’re products of our environment?
No, we’re products of our expectation.

I’m personally guilty of having expectation-ism, constantly deeming people not useful because they won’t be going very far in some fashion. A math person asking me about something he or she should know? I’ll answer the question, but in my mind I have already lowered my expectations of that person.

“Oh, (s)he’ll never be working for a company or in a position to help me advance my career too much.”

“Oh, (s)he’s really struggling. Might drop out of the major soon.”

These are thoughts that I shouldn’t have. Expectations of someone will change my behavior towards that person, which can create a positive feedback loop. I should be more encouraging in these cases, and remember what great people I had in my life which always expected more of me.

Never lower expectations for anyone, especially oneself.

Emerson

“Let me never fall into the vulgar mistake of dreaming that I am persecuted whenever I am contradicted.”

 

Clashodoro

Instead of using the Pomodoro method, I’ve been relying increasingly on my Clash of Clan method while working. Every 20 minute or so, I would check my phone in order to attack as my troops have been replenished.

Last Semester

Today marks the last first day of my undergraduate career, assuming nothing messes up. It was also a productive day, with me unpacking after arriving in Ithaca last night, and finally applied for a CS minor. With this newfound busyness, my mind can’t really stray to be too nostalgic.

When I arrived in my room last night, a wave of nostalgia swept over me. The want for the status quo is quite strong; change seems to be bad now. The best way I can explain it is in terms of mathematics:

For the past 22 years, fortune has smiled upon me. Time after time, the dice has favored my family’s endeavors and health. I fear that the math dictates that tragedy will strike soon with the new dice roll. It seems that my grandma’s health has already started to decline. I was too young to comprehend the death of my dad’s mother, but being 22 means I will understand now.

Am I scared of this? Oh definitely. Is this fear irrational? I think so.

Clash of Clans: Barracks Optimization

Hopefully this’ll be the first of a many part series to examine CoC in a more mathematical manner, and actually use some of the skills and technologies I have acquired over the years.

The first thing that raiders in CoC know is that time spent not raiding is wasted time. In order to minimize that wasted time, a critical thing to minimize is time spent building troops, spells and resting heroes. Spells and heroes has no build order to minimize, while troops has countless possibilities of building a set army.

The problem is fairly easy to define: given a certain army composition, use the given set of barracks and create that army in the shortest possible time.

Sounds easy right? Meh.

Scheduling Theory

My first impression is to use scheduling theory, and turn it into a simple library call to an approximation algorithm there. Unfortunately, there are several complications.

First of all, since there are multiple barracks, this is a multiple processor problem. Multiple processor problem are actually NP-hard, equivalent to the partitioning problem. Many heuristics exist for a standard problem of many processor, and many jobs for minimizing time. The standard is longest processing time first (LPT).

If one simply implements LPT on this problem, we have a weird problem. The heuristic was designed for processors of equal power, and barracks of different levels have different capacity. The second (more minor problem) is that we need to impose the constraint that a barrack can produce that particular troop (i.e. level 1 creating a P.E.K.K.A).

So in essence, this problem became much tougher using this approach. I guess I can read up on heterogenous processor research, but that’s for another day.

Integer programming

The next approach was to convert it to an integer programming problem.

Let us define our problem then. Let n be the number of barracks, and k be the number of different types of troops (defined to be 10 by the current patch, but let’s keep it flexible). Let T be a column matrix of time to produce a single barbarian, archer etc., and C be a column matrix of the corresponding capacity needed to train a troop. This means that both T, C have height k. We define a matrix A such that each entry i, j corresponds to the ith barracks and jth type of troop (by barracks level). For example, the position at (2, 3) corresponds to the 2nd barracks and Giants.

We simply want to minimize the maximal entry of the matrix AT such that AC \leq Cap where Cap is the capacity of each barrack with regards to level.

The unfortunate thing about this whole section is that there is no known general way to solve integer programing problems in polynomial time; it is also NP-hard. Many heuristics are available, and many sub-cases solved, but I’m not at that level yet. One technique which I suspect might do well is to simply relax the problem to a linear programming problem, and then round the result. Thing is, this LP relaxation method kind of sucks most of the time.

Conclusion

So do I have a final product? Nope.

Scheduling theory proves to have little Python implementations, while integer programming is only available from obscure libraries. The best thing to do might be to create my own little meta-heuristic.

Faded Glory

No, not the jeans.

I did a round of Power 90, not P90X, yesterday evening. And goodness was it tough. This is what I get for not working out for a whole semester.

Same thing is happening for my clarinet skills too. It’s just so rusty.

It’s too bad I can’t do the stuff I used to be able to do in high school right now. 🙁

Lattice Polygons and Squares

It’s fairly obvious that a square is a regular lattice polygon, but it’s fair from obvious that it’s the only one. In the past semester, we actually proved that it’s the only regular polygon on the lattice without invoking any complicated mathematics.

Sketch of Proof:
We first show that regular triangles and hexagons can’t exist. The easiest way is to apply the irrationality of sine to either the area or a rotational perspective. Regular hexagons cannot exist because it’s composed of equilateral triangles.

For any other polygons, we apply infinite descent. Let P1P2…PN be the vertices of the polygons, then consider the vector P2P3 applied to P1. Since it’s a lattice vector applied to a lattice point, we will end up with another lattice point. Applying this procedure to all of the lattice points will result in a smaller lattice polygon! This concludes the proof.

Now what are the implications, and some other problems to consider?

Well for one, what other lattices will give us more regular polygons? For example a triangular lattice will give a triangle and a hexagon as the regular polygons. Is there any others? Does there contain a maximal lattice with such numbers?

Furthermore, does this imply the irrationality of sines and cosines of certain angles? If a regular polygon in the lattice exist, then the trig functions are rational. Is the converse true? I’m pretty certain it is, but haven’t worked it out yet.