[Tutor] Structure of my simulation / monte-carlo

Vincent Davis vincent at vincentdavis.net
Sun Nov 1 17:15:33 CET 2009


Just to be clear,or try, given a set of applicants and institutions the
Match will always have the same result. So when I am repeating the Match
this only makes sense to do is I am also making new applicants and
institutions. So I am sampling Match results drawn from a process that is
initiated with a distributions set at the applicant and institution level.

Thanks
Vincent Davis


On Sun, Nov 1, 2009 at 9:58 AM, Kent Johnson <kent37 at tds.net> wrote:

> On Sun, Nov 1, 2009 at 10:47 AM, Vincent Davis <vincent at vincentdavis.net>
> wrote:
> > Kent Johsnon writes
> > "This class has a lot of responsibilities:
> > - create applicants
> > - create institutions
> > - run a single match
> > - run multiple matches
> > - calculate statistics on the result of multiple matches
> > A principle of object-oriented design is that a class should have a
> > single responsibility. I would break your class up a bit using
> > multiple classes, perhaps."
> > I am trying to do what you recomend, as much as makes sense to me, but
> that
> > is why I ask the question so I should consider your answer.
> > This is what I hear you saying, (I don't mean to represent them as
> > sub-classes but more how they would operate on each other) Should I
> consider
> > making Institutions) a subclass of (Make Institutions)? I can't think of
> > anything that would make sense to inherit.
> > class Simulation:
> >     class Create Institutions:
> >         class Institutions:
> >     class create Applicants:
> >         class Applicants:
> >     class Match:
> >     class Multi Match:
> > I add I am thinking
> > class Simulation:
> >     def__init__:(self, results, stats.....repeat..)
> >     def create_applicants():
> >         class Applicants
> >     def creat_institutions():
> >         class Institutions
> >     def one_simulation(): # one or more
> >         create_applicants()
> >         create_institutions()
> >         class Match()
> >         class Results
> >     def repeat_simulation()
> >         repeat one_simulations
> >         class Results
> > After writing this out I now think you are right, more classes.
>
> Now you are getting too complicated. You don't need to use inheritance
> or nested classes, and you can use simple methods (not classes) to
> create applicants and institutions. You already have Applicant,
> Institution and Match classes that run a single match. Now make a
> RepeatMatch class that uses the Match class to run multiple
> simulations.
>
> Kent
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091101/0221efc2/attachment.htm>


More information about the Tutor mailing list