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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:12:51+00:00 2026-05-11T17:12:51+00:00

I am using VB.NET and I am trying to come up with some algorithm

  • 0

I am using VB.NET and I am trying to come up with some algorithm or some pseudo-code, or some VB.NET code that will let me do the following (hopefully I can explain this well):

I have 2 collection objects, Cob1 and Cob2. These collection objects store objects that implement an interface called ICob. ICob has 3 properties. A boolean IsSelected property, a property called Length, which returns a TimeSpan, and a Rating property, which is a short integer.

OK, now Cob1 has about 100 objects stored in the collection and Cob2 is an empty collection. What I want to do is select objects from Cob1 and copy them over to Cob2. I want the following rules obeyed when selecting the objects though:

  1. I want to be able to specify a timespan and I want enough objects to be selected to fit into the timespan I specify (based on the Length property). So for example, if I pass a 10 minute timespan to my function, it should pick enough objects that fill the entire 10 minute window, or come as close to filling it as possible.

  2. No objects should be selected twice.

  3. Objects that have a higher rating (via the Rating property) should have a better chance at being picked then other objects.

  4. No object that has been selected in the last 30 minutes should be selected again (so that each object will eventually get selected at least once), regardless of rating.

Can anyone give me some tips on how to achieve this? The tips can be in the form of mental processes, VB.NET example code, Pseudo-code or just about anything else that might help me.

Thanks

EDIT:

Maybe It would help to everyone if I revealed what I’m trying to do in real life.

I am writing software for a radio station that will automatically select the music and advertisments to play, kinda of like a computerized program manager.

The length represents the length of the sound byte (either a song or an advertisement) and the rating is just that. If the song is popular, it gets more airtime. If an advertiser pays more money, then it also gets more airtime.

So my program should pick songs that play for 20 minutes or so, then pick some advertisements to play for about 5 minutes or so.

Hopefully this helps a little.

Thanks for the input from everyone!

Alan

  • 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-11T17:12:51+00:00Added an answer on May 11, 2026 at 5:12 pm

    Note that:

    The restriction 1 is from the classical knapsack problem, which works on sets, as requested by restriction 2.

    Restriction 3 is rather vague. It is better to have higher value or higher coverage of the lifespan? If you don’t specify a objective function to maximaze (or, to be precise, there are two: lifespan itself and rate), there are some pareto optimal solutions.

    Restriction 4 is implementable by making a map object -> last time selected., in the form of black list.

    Long story short: first I’d filter the set by blacklisting the object by restriction 4, and then apply a knapsack algorithm.

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

Sidebar

Ask A Question

Stats

  • Questions 103k
  • Answers 103k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Would this be practical for a complete XPath implementation, given… May 11, 2026 at 8:22 pm
  • Editorial Team
    Editorial Team added an answer Conditional comments are IE specific and therefore "<![if !IE]>" is… May 11, 2026 at 8:22 pm
  • Editorial Team
    Editorial Team added an answer Yes you can, but it is a little convoluted, and… May 11, 2026 at 8:22 pm

Related Questions

I am trying to create an XML file based on data fields from a
Good evening/morning/after/noon. I have an ASP.net 3.5 website and I am using vb.net in
Good evening/morning/after/noon. I have an ASP.net 3.5 website and I am using vb.net in
I am trying to compare two long bytearrays in VB.NET and have run into
In my vb.net program, I am using a webbrowser to show the user an

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.