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 8301201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:51:21+00:00 2026-06-08T16:51:21+00:00

I created a function with an if flow control, I am wondering a few

  • 0

I created a function with an if flow control, I am wondering a few things about it.

class Supplier(Process):

    def weeklySupply(self):
        global D1Vals
        xMeet = D1Vals[0]
        lead = 0
        capac = 150.0
        supply = 0
        if stocked.amount >= 15000:
            supply = 0
            yield put, self, stocked, supply
            S1Vals.append(0)
        elif supply >= capac:
            supply = capac
            yield put, self, stocked, supply
            S1Vals.append(capac)
        else:
            supply = random.triangular(.70 * xMeet , xMeet , xMeet * 1.05)
            yield put, self, stocked, supply
            print ('Week:'+'%6.0f:Supplied: %6.0f units. CurSupply = %6.0f' %
                   (now() + 1., supply, stocked.amount))
            yield hold, self, lead
            S1Vals.append(supply)
            del D1Vals[0]

What I though I coded was:

  • If the amount in the stocked object was >= 15000, then the object generates zero supply
    or if a supply value was generated which was greater than a predefined ‘capac’ amount, then the supply value = ‘capac’.

  • If non of the above were true then the supply value was generated as a random distribution. When I get my output though, the supply value does exceed the ‘capac’ value of 150.

Have I misunderstood how to do the flow?

  • 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-08T16:51:24+00:00Added an answer on June 8, 2026 at 4:51 pm

    Do not mixup the if elif construct with some kind of or as you did in your question. The elif condition will only be evaluated if the if condition is False.
    I think, what you really want is:

    if stocked.amount >= 15000:
        if supply >= capac:
            supply = capac
            yield put, self, stocked, supply
            S1Vals.append(capac)
         else:
            supply = 0
            yield put, self, stocked, supply
            S1Vals.append(0)
    else:
        supply = random.triangular(.70 * xMeet , xMeet , xMeet * 1.05)
        ...
    

    But this would only work, if supply is not initialised with 0 at the beginning of the function.

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

Sidebar

Related Questions

I'm missing some fundamental understanding of javascript function flow control... I've created a jquery
This is my current flow of JQuery: Object is created. Object has a function
I ve created function and trigger as follows: CREATE OR REPLACE FUNCTION New_Ticket() RETURNS
Ive created a function which returns all the obserables items in my html page.
I created a function which loads a very basic map file of the form:
I created a function for splitting an image into multiple images, but when I
I have created a function that shows/hides different messages according to a combination of
i am created one function to upload image with random name and it worked
So I created a function: -(void)checkCount:(UITableView *)tableView isIndexPathChecked:(NSIndexPath *)indexPath{ NSString *name = [[NSString alloc]
I have created a function which gets an encoded string (possibly UTF-16 not sure)

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.