Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8155133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:34:54+00:00 2026-06-06T16:34:54+00:00

# Loop(Classroom1, m_count, h_count, t_count, l_count, loopsize) File /Users/maninder/git/TrialScheduler/TrialScheduler/main.py, line 27, in Loop Loop(Classroom1,

  • 0
# Loop(Classroom1, m_count, h_count, t_count, l_count, loopsize)
  File "/Users/maninder/git/TrialScheduler/TrialScheduler/main.py", line 27, in Loop
    Loop(Classroom1, m_count, h_count, t_count, l_count, loopsize)
  File "/Users/maninder/git/TrialScheduler/TrialScheduler/main.py", line 27, in Loop
    Loop(Classroom1, m_count, h_count, t_count, l_count, loopsize)
   File "/Users/maninder/git/TrialScheduler/TrialScheduler/main.py", line 27, in Loop #

The code:

from CProfessor import Professor 
    from CCourse import Course
    from CClassroom import Classroom
    import copy
def Loop(Classroom1, m_count, h_count, t_count, l_count, loopsize):
    for i in range(0, loopsize):
        Mutated = Classroom()
        #Mutated = Classroom1.CopyOfClassroom(Mutated)
        Mutated = copy.deepcopy(Classroom1)#Modification
        Mutated.Mutate()
        HardConstraintClassroomMet = Classroom1.ComputeHardConstraint()
        HardConstraintMutatedMet = Mutated.ComputeHardConstraint()
        if HardConstraintClassroomMet == False and HardConstraintMutatedMet == False:
            h_count + 1
            t_count + 1
            Classroom1.Mutate()
            continue
        if Mutated.FitnessValue() > Classroom1.FitnessValue():
            m_count + 1
            t_count + 1
            Classroom1 = Mutated
        if Classroom1.ComputeHardConstraint() == False:
            l_count + 1
            temp = l_count*loopsize
            print "Unable to meet hard consraints in %d" % temp
        Loop(Classroom1, m_count, h_count, t_count, l_count, loopsize)

    Professor0 = Professor(ProfessorId = 0, PreferedStartTime = 8, PreferedEndTime = 11)
    Professor1 = Professor(ProfessorId = 1, PreferedStartTime  = 10, PreferedEndTime = 13.75)
    Professor2 = Professor(ProfessorId = 2, PreferedStartTime  = 4, PreferedEndTime = 7.75)

# intializing Courses
    Course0 = Course(CourseId = 0, ProfessorId = 0, CourseSlot = 0, CourseType ="UnderGraduate")
    Course1 = Course(CourseId = 1, ProfessorId = 4, CourseSlot = 1) # we decided to leave this 
coursetype to be emmpty and it is set none in the Course class
    Course2 = Course(CourseId = 2, ProfessorId = 1, CourseSlot = 2, CourseType ="UnderGraduate")
    Course3 = Course(CourseId = 3, ProfessorId = 4, CourseSlot = 3)
    Course4 = Course(CourseId = 4, ProfessorId = 1, CourseSlot = 4, CourseType ="UnderGraduate")
    Course5 = Course(CourseId = 5, ProfessorId = 4, CourseSlot = 5)
    Course6 = Course(CourseId = 6, ProfessorId = 2, CourseSlot = 6, CourseType ="Graduate")
    Course7 = Course(CourseId = 7, ProfessorId = 2, CourseSlot = 7, CourseType ="UnderGraduate")

# intializing 
    Classroom1 = Classroom(FirstCourseStartTime = 8, LastCourseEndTime = 7.75)
# Add all courses to Classroom1
    Classroom1.AddCourse(Course0)
    Classroom1.AddCourse(Course1)
    Classroom1.AddCourse(Course2)
    Classroom1.AddCourse(Course3)
    Classroom1.AddCourse(Course4)
    Classroom1.AddCourse(Course5)
    Classroom1.AddCourse(Course6)
    Classroom1.AddCourse(Course7)

# Add Professors to the classroom.

    Classroom1.AddProfessor(Professor0)
    Classroom1.AddProfessor(Professor1)
    Classroom1.AddProfessor(Professor2) 

    m_count = 0 # mutations caused by grea
    h_count = 0
    t_count = 0
    l_count = 0
    loopsize = 10000
    Loop(Classroom1, m_count, h_count, t_count, l_count, loopsize)
    """
    Printing out the results:
    """
    print '\n'
    print "Mutation caused by greater fitness value %d" % m_count
    print "Mutation caused by Hard Constraint Violations %d" % h_count
    print "Number of Mutations before Converging" % t_count
    Classroom1.PrintClassroom()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T16:34:56+00:00Added an answer on June 6, 2026 at 4:34 pm

    Here’s the relevant part of the code:

    def Loop(Classroom1, m_count, h_count, t_count, l_count, loopsize):
        for i in range(0, loopsize):
            Loop(Classroom1.Mutate(), m_count, h_count, t_count, l_count, loopsize)
    

    In other words, when you call Loop with loopsize=10, it will call Loop 10 more times with loopsize 10… which will call Loop 100 more times… which will call it 1000 more times. So eventually, you’re going to run out of stack space.

    The only way you ever skip the recursive case is if Classroom1.ComputeHardConstraint(), in which case you skip over one call to Loop, but you’ve still got loopcount-1 other calls. A properly-defined algorithm might complete, but it seems like you’re diverging—you cut off successful branches of the recursion tree, but continue on the rest forever. And even if it does converge, the recursion is almost certainly going to get very deep and wide, probably enough so to kill the stack anyway. (If you were counting on tail recursion elimination, Python doesn’t do that, and it wouldn’t help anyway except to maybe knock 1 call out of each loopcount.)

    As a side note, much of your code doesn’t actually do anything. For example:

    h_count + 1
    

    This evaluates the expression “h_count + 1”, then throws away the result. It doesn’t store it anywhere, use it for anything, change the value of h_count, or anything else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This loop works fine in Main function but when copy this loop code in
The loop for root, dir, file in os.walk(startdir) works through these steps? for root
This loop leaks memory: int64_t i,verylongnumber; //misc. code for(i=0;i<verylongnumber;i++){ NSMutableArray *myArray = [[NSMutableArray alloc]
I'm trying to loop some array using foreach . This is the code which
I have a for loop that reads lines from an Excel file, checks them
// Loop each users profile using (DataClassesDataContext db = new DataClassesDataContext()) { var q
Javascript loop continue,or break to display? This is my code use for show or
the loop: for h=1:t_max REST OF CODE end if t_max is equal to 100,
I want to loop over the contents of a text file and do a
I loop through a bunch of directories recursively. Some of them (like D:\$RECYCLE.BIN\S-1-5-20 )

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.