Monday, January 30, 2012

Lucid Charts

http://www.lucidchart.com/ 

The other day I was working on a group project (whose entire summary would be beyond this quick post, but will more than likely soon to be coming) and was creating some diagrams to model the general flow of the programs execution. I was doing this in my notebook, but got the compulsion to create a flow chart. I had just moved over to start up paint.net when I decided to see if there was a free online flow chart maker available. Wonderfully, there was. The above link is a fantastic resource for anyone who organizes and likes to keep a stable head during their projects. Signing up is free and can be done through a google or yahoo account, although the free version does limit the number of objects you have in your diagram to about 60.

Despite the limit on the free version, the software is fantastic and you edit the diagrams directly in your browser. My favorite part about this is that there's built in UML tools. Which is really great for creating project documents.

Monday, December 12, 2011

End Semester Results and Plans for the next semester

It's nearing the end of the semester, and the WiiSmartBoard has a semi-working prototype. However, it crashes due to memory errors and the way the images are controlled, as a group, my project group has decided that it would be best to take the working parts of the code, and use them to construct a multithreaded version of the smartboard so that it has better memory management,encapsulation, and abstraction.

Also, I've been thinking about a new data structure. Basically, trying to create a data structure based off of circles, and indexing by angles. this way a directional search could be created that would be able to search in some smart way. However as of right now, I'm imagining the overhead might not be worth the trade, and it's worst run time if implemented incorrectly could be on par with NP problems due to the connectivity of the omnidirectional graphs... its still a work in progress and more of a thought idea than anything else.

Thursday, December 1, 2011

Wii SmartBoard Calibration

Today, my project group working on creating a smartboard finally got the calibration code to work and run in such a way that the board waits for each point and doesnt just grab a bunch of points right away, also we got the board actually drawing points which is fantastic! Right now I've too many projects and homework to really update this project, but once the WiiBoard is done, a full paper is in the works, so look forward to that!

Wednesday, November 23, 2011

Papers available and project directions

So, under the suggestion of a database admin for the Green Mountain Coffee Roasters, I made myself a website. It's not the greatest thing and definitely still needs work. But within the projects page there are links to read the papers that I've written on a couple of the projects that I've talked about here.

I'm also thinking about redoing my Python Obstacle Avoidance program, either in python with cleaner code and a nice paper alongside of it to walk through the reasoning in the code itself, or to redo it in Matlab because I feel that Matlab's plotting functions could be of great use. Especially because I could make demo code that would show the algorithm working in real time and could animate a graph on screen to show what it is doing. I really like this idea, and despite moving away from Python, I feel like it will be really good. I'll either have to look up how to do lambda expressions in Matlab, or just throw away their use all together. (If you recall, I used lambda expressions to create functions that would return the value of y given an x, using an equation of a line that was the instance of the class itself.) They weren't necessary in the implementation and were mainly just me trying out something new.

The Smartboard is still coming along, and a paper is in the works for that one. I'm also going to probably be doing some small program in MIPS assembly pretty soon and will have to present it to a class I'm enrolled in, so that may make itself onto my website as well, and quite possibly this blog.
I'm also contemplating redoing the Budget Buddy in C# due to it's Visual Studio capabilities and how easy file IO is in C#, not to mention packaging into an exe. These are all things for the future, and hopefully I'll have time to do them!

Heres the URL to my website:
http://www.uvm.edu/~ejeldrid

Hope you all enjoy.

Tuesday, November 22, 2011

Lambda Expressions in Python


Below is just a sample piece of code that I was playing with the other day, it was fun to mess with and interesting to see how the scope of the variables declared for the lambda expressions behaved. Mainly, that sometimes it seemed that variables declared within lambda expressions were accessible outside of what I thought their scope should be. This happened with the lambda expressions containing lambda expressions both expressions taking variables. It was a fun case study that got me away from all this serious project stuff I'm working on. And I figured I would share, so without further ado, here is the code: throw it into your favorite python IDE (command line, IDLE, eclipse) and run the show function and then play with it yourself. :)


#LAMBDA EXPRESSION TESTING
#Can you horribly abuse lambda expressions such that
#you dont have to actually create functions in a class?


class LamClass1:
    def __init__(self,x,y,z):
        self.x = x
        self.y = y
        self.z = z
        self.getX = lambda: self.x
        self.getY = lambda: self.y
        self.getZ = lambda: self.z
        self.norm = lambda a: a/(self.x+self.y+self.z)
        self.xyLine = lambda m: (lambda n: n*m*self.x+self.y)
        self.xzLine = lambda m: m*self.x+self.z
        #nesting functions to return functions
        self.makeLine = lambda m: lambda b:  lambda x: (m*x+b)
        #nesting arguments!
        self.nesting = lambda m,b,x: (((self.makeLine(m))(b))(x))
        #tupling it up
        self.listF = lambda a,b,n: a+b,a*b,a-b,b-a,n
        #This is a tuple you access to access a function how cool!
        self.listT = lambda a,b: lambda n: (a+b)**n,lambda a,b: lambda n: (a-b)**n
        self.shallowCopy = lambda: self
        self.deepCopy = lambda: LamClass1(self.x,self.y,self.z)
        self.tupleReturn = lambda a,b: (a,b)
        self.funcList = lambda: (self.getX,self.getY,self.getZ,self.xyLine)
        #you cant do multiple statements inside a lambda
        #but you could nest everyline of code as a lambda being called and such


def show():
    l = LamClass1(2,3,4)
    #Standard gets but with lambda
    l.getX()
    l.getY()
    l.getZ()
    #An example of argument passing
    f=l.xyLine(2)(3)
    #Multi Function Computation:
    f=l.listF[0](2,2,3)
    #Example of how Scope Changes
    f=l.listF[1]
    print 'Global Scope of lambda variables'
    print a,b,n
    #you could write a =1 and then another print and watch it be strange
    #Lambda Expression Variables are global, this could be bad
    #Example of tupled functions
    f=l.listT[0](1,2)(2) #(a+b)^n
    f=l.listT[1](2,3)(3) #(a-b)^n
    print a,b,n
    #Notice how I have never declared a,b,n
    #an example of shallowCopying and mutability
    print 'Shallow Copy'
    L2 = l.shallowCopy()
    print 'l.x=',l.getX()
    print 'L2.x=',L2.getX()
    l.x = 3
    print 'l.x = 3'
    print 'L2.x=',L2.getX()
    #an example of deep copy
    L3 = l.deepCopy()
    print 'Deep Copy'
    print 'l.x=',l.getX()
    print 'L3.x=',L3.getX()
    l.x = 5
    print 'l.x =',l.x
    print 'L3.x=',L3.getX()
    print 'Function List'
    print 'l.funcList()[0]() -> getX()'
    print l.funcList()[0]()
    print 'l.funcList()[1]() -> getY()'
    print l.funcList()[1]()
    print 'l.funcList()[2]() -> getZ()'
    print l.funcList()[2]()
    print 'l.funcList()[3](2)(3) -> xyLine(2)(3)'
    print l.funcList()[3](2)(3)
    

Monday, November 21, 2011

Wii Smartboard

The WiiSmartBoard that I'm working on with CS Crew is really coming along, we started working on it 2 days a week every week since early September. We're writing it in C# and using an open source library for interfacing with the Wiimote through bluetooth. When we first started working on it I went and looked through all the documentation for the WiiMote and found out which bits and bytes were returned from the wiimote and was ready to write my own assembly level parsing code. But then we were lucky enough to find the library that we did and I could focus on the actual concepts instead of the nitty gritty detail.
The cool thing is that we're going to attempt to implement a 2 and a half D flicking system to switch between "slides". I suppose I should talk a little bit more about the details.

We're using the Wiimote as a receiver for an infrared pen we built. We're drawing onto bitmaps on our GUI, but we also have buttons that will be able to be clicked. Each bitmap is a slide, stored inside of a lecture class my friend Scott and I created, when we save, we save a .lecture file that holds the information of the order of the slides to load, and saves the images into a subdirectory. It works really well because we're using two stacks to contain the bitmaps, so saving is as easy as popping and pushing them from one slide to the next and saving each one. And then when we load, we just load them in reverse order which is really the right way to do it because of the FILO structure of the stack.

I'm also writing up documentation on it and I'll definitely publish that onto my website.

Tuesday, October 11, 2011

Proportions of a schema at time step t+1 with respect to mutation.

Firstly, I'd like to say that this is in no way linked to the Budget Project that has been on hold since my semester started again, this little gem comes from my own musings during a homework assignment for my evolutionary computation class.

Background knowledge for this piece of work:

Read up on Holland's Schema Theorem: Wikipedia Page on it
Understand how to multiply vectors, or at least take their dot product.

Moving on,

For a given population, at time step t, the number of schema's represented in the population is given by a vector of values between 0 and 1. We can compute the expected number of individuals from extending Holland's schema theorem with our own intuitive (and correct) terms. Doing this now, for a 2 bit problem:
(meaning that each schema in the population is only 2 bits long, and when I say schema here, I do not mean templates, I mean the actual members of the population of say, schema 00 or schema 11, NO wildcards.)

The probability of a schema surviving is the probability of both it's bits not being mutated. If we were mutating with probability Pm, then we can determine this survival rate as (1-Pm) squared.

The probability of a schema's complement (Think a standard not gate applied to all the bits, aka inverting, or flipping the bits, like twos complement but without the plus 1...) mutating into the given schema is the probability that it gets both bits flipped, or Pm squared.

The probability of terms representing half or partial complements being mutated is the probability of the bits matching the schema to not be mutated multiplied by the probability of the schema's non matching bits to be mutated into them. In short, (1-Pm)(Pm) and each term is raised by whatever bits match, and not match respectfully. (If this makes no sense, for a 2 bit problem, this would be (1-Pm)(Pm) or (Pm)(1-Pm) for the schema 01 and 10 if the desired schema was 00)

Now that we have those probabilities, we recognize that those probabilities multiplied by the number of the matching schema (not desired in most cases), and then summed, will give us the expected number of schema in the next generation at time t.

Now, my 'theorem' I suppose.

Let (1-Pm) = A, and (Pm)= B, o=number of bits, P= proportions of population

number of expected schema H at time t+1 = V((A+B)^n) dot P

Where V is a vector where each element i is the i-th term in the binomial expansion of (A+B)

We use the dot product to multiply the corresponding schema with the right probabilities and then tada, we're done. doing this for each schema in the population results in 2^n equations being calculated and the proportions of a generation at the next time step has been calculated.

Because this might not be very clear, due to my lack of knowledge if blogger supports latex or not, heres a bit more elaboration.

Expansions of a binomial are usually simplified, and then their coefficients make what is known as pascals triangle, however, in this theorem, the vector is composed of the UN-simplified version of the expansion, why? Because the proportions of the population can be different from one another, so you can't simply factor out the expansion, get the coefficients and multiply by the population now can you?
Also, the population vector goes from the desired schema up to the one previous to it. How? modulo arithmatic and mathematical trickery of course.
if we want schema 00, then our vector would be [00 01 10 11 ]. if we wanted 01? [01 00 11 10], what about 10? [10 11 00 01]

The goal of course of any population vector is to have the desired on the left, and the complement on the right, any bits between must correspond to their proper probability. This is the difficult part of any implementation, However consider this

000    A^3
001    A^2B
010    A^2B
011    AB^2
100    A^2B
101    AB^2
110    AB^2
111    B^3

Take the first, 000 as the desired bit string, and the other column as the probabilities assigned to it by the theorem, well we can notice that the number of complementary bits in the schema indicate how many times we should apply B, and the number of bits matching the schema apply to how many times A is multiplied by itself. Extrapolating from this, we could produce an implentation if we wanted to.

That is all.