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

  • Home
  • SEARCH
  • 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 6859395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:16:40+00:00 2026-05-27T02:16:40+00:00

Helo, I’m building a relatively complex Discrete Event Simulation Model in SimPy. When I

  • 0

Helo, I’m building a relatively complex Discrete Event Simulation Model in SimPy.

When I try to put my yield statements inside functions, my program doesn’t seem to work. Below shows an example.

import SimPy.SimulationTrace as Sim
import random

## Model components ##
class Customer(Sim.Process):
    def visit(self):
        yield Sim.hold, self, 2.0
        if random.random()<0.5:
            self.holdLong()
        else:
            self.holdShort()

    def holdLong(self):
        yield Sim.hold, self, 1.0
        # more yeild statements to follow

    def holdShort(self):
        yield Sim.hold, self, 0.5
        # more yeild statements to follow

## Experiment data ##
maxTime = 10.0 #minutes

## Model/Experiment ##
#random.seed(12345)
Sim.initialize()
c = Customer(name = "Klaus") #customer object
Sim.activate(c, c.visit(), at = 1.0)
Sim.simulate(until=maxTime)

The output I get from running this is:

0 activate <Klaus > at time: 1.0 prior: False
1.0 hold  < Klaus >  delay: 2.0
3.0 <Klaus > terminated

The holdLong() and holdShort methods didn’t seem to work at all. How can I fix this? Thanks in advance.

  • 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-05-27T02:16:40+00:00Added an answer on May 27, 2026 at 2:16 am

    Calling a generator function returns a generator object that can be iterated over. You are simply ignoring this return value, so nothing happens. Instead, you should iterate over the generator and re-yield all values:

    class Customer(Sim.Process):
        def visit(self):
            yield Sim.hold, self, 2.0
            if random.random()<0.5:
                for x in self.holdLong():
                    yield x
            else:
                for x in self.holdShort():
                    yield x
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Helo! How can i convert a NSMutableArray object to a NSString ? i try
Helo everyone! I have this live wallpaper in witch I try to show a
Helo! Dropdown in IE7 displayed not correct. When I put mouse over it's appears
Helo! Is this possible to use string value of one node which tells what
Helo, I am pretty new to Ruby (using 1.8.6) and need to know whether
What am I doing wrong here: class Helo { // main: generate some simple
Helo everyone. I have a class MyClass and a function escape () that can
Helo, I have a two Grid where I have to display some records from
Helo, there are 3 files, CustomerClient.java , CustomerServer.java and Customer.java PROBLEM: In the CustomerServer.java
Helo guys, I am working wid CStringArray and i want to know how to

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.