473,320 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Help with writing algorithm

I writing a economic statistics program..

I need to allocate billions of dollars and I
have been shown projects to consider and ith project estimates
its cost to be dollars and claims to generate jobs.

So I have B billions of dollars
n projects
ci dollars
Ji jobs
I guess I have one objective function and one constraint.

Can someone help me with just write the psuedocode to determine which projects to choose to "maximize" job creation
and an estimate of "how many" jobs will be created.

Do you think I should use a greedy algorithm like Prim's or am I off? I not really knowledgable about these types of algorthims

V. Dugall
Mar 18 '09 #1
3 4474
JosAH
11,448 Expert 8TB
If you get j_i jobs for c_i dollars for project i you can use a greedy algorithm where you select the project i that gives you the most jobs for your dollar, i.e. the ratio j_i/c_i is maximal. Repeat while you still have dollars and projects left.

Your single constraint is:

sum(c_i) <= B

and your cost function is

maximize: sum(j_i)

kind regards,

Jos
Mar 18 '09 #2
jkmyoung
2,057 Expert 2GB
http://en.wikipedia.org/wiki/Knapsack_problem
Greedy algorithm is probably the best way to go.
Mar 19 '09 #3
JosAH
11,448 Expert 8TB
@jkmyoung
For sure it is: pick the project that gives you the most jobs for the dollar; any other choice is a worse choice. Repeat until you're out of dollars. There are never any 'uphill' steps to take so a steepest descent greedy algorithm will do the job.

kind regards,

Jos
Mar 21 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: PHPkemon | last post by:
Hi there, A few weeks ago I made a post and got an answer which seemed very logical. Here's part of the post: PHPkemon wrote: > I think I've figured out how to do the main things like...
1
by: git_cs | last post by:
Hey , guys and gals do any of you have the DES algorithm in C/C++ language. I would be happy if any of you could give the source code. I studied the algorithm, and have written a C language...
16
by: t_pantel | last post by:
I 've got the following structure: typedef struct GROUPED { short val ; short code; short group; short forecast_cd; short double_ind; short min;
9
by: Diane | last post by:
Could you please explain me how can I output nested strings? Here is an example: "adsd{rfkm}xcv" The output should start from the inner parentheses, such as: dfF rfkm
1
by: massdeletion101 | last post by:
Is there an algorithm that allows me to manipulate a variable by a range of falues in the standard STL with standard arithmatic? Something like this: vector.push_back(2); vector.push_back(3); 5 /...
2
by: ricky | last post by:
Hi, I am student and I am doing a final year project on Zig-bee. I have to write low energy routing algorithms. I need to write routing algorithm for LEACH. If anybody can help with some links...
1
by: kester83 | last post by:
hi, i am actually doing a project in C++ that is able to carry out voice morphing properties. however, i am kind of stuck with the peak detection which is essential for carrying on with the...
4
by: uidzer0 | last post by:
Hey everyone, I'm having a little trouble writing an algorithm to create a hierarchal structure from a database which looks like this: Code: parent_id | child_id |...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.