Two Plus Two Newer Archives  

Go Back   Two Plus Two Newer Archives > Other Topics > Science, Math, and Philosophy
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #11  
Old 08-28-2007, 09:44 PM
m_the0ry m_the0ry is offline
Senior Member
 
Join Date: Aug 2006
Posts: 790
Default Re: A Math Problem (NP Complete?)

You can't generalize with the "highest cal/$ for each category" because of the $10 budget restriction. Take the following example:

type1:
fooda - 500cal,$4
foodb - 600cal,$4.01
type2:
foodc - 800cal, $6
foodd - 992cal, $6
foode - 500cal, $7

You might think of this as an extreme example but I guarantee that when the number of categories rises and the number of entries in each category rises, this kind of counterexample will become more and more prevalent.

The only addition to an exhaustive permutation search to optimize this is to remove an entry that shares the *exact* same cost as another entry but has a lower cal. For example we can remove foodc safely because there is no conceivable situation where we would replace foodd with foodc.

With few exceptions, when a minimum/maximum problem is to be found using a limited amount of resources it will be a non polynomial time problem. This means that we must exhaustively calculate all possibilities or permutations and check for the minimum/maximum.
Reply With Quote
  #12  
Old 08-28-2007, 10:32 PM
KUJustin KUJustin is offline
Senior Member
 
Join Date: Mar 2004
Posts: 1,616
Default Re: A Math Problem (NP Complete?)

Ok, I'm trying to meet people halfway, but you've got to read the problem.

Getting the highest cal/$ is where I started my solution from. The problem with that is the goal is to maximize calories, not cal/$. I'm pretty sure my solution is a viable approximation, though m_the0ry's example is a situation in which it would probably have a pretty significant error. Though if we're working with thousands of items and choosing 10 that effect should be reduced.
Reply With Quote
  #13  
Old 08-28-2007, 10:47 PM
m_the0ry m_the0ry is offline
Senior Member
 
Join Date: Aug 2006
Posts: 790
Default Re: A Math Problem (NP Complete?)

I think I convoluted my point a little bit too much in my last post,

The only way to solve this problem is by calculating every possible combination and finding the maximum. It is an NP complete problem. The approximation becomes worse as more items are added because more loss of information occurs.
Reply With Quote
  #14  
Old 08-28-2007, 11:42 PM
KUJustin KUJustin is offline
Senior Member
 
Join Date: Mar 2004
Posts: 1,616
Default Re: A Math Problem (NP Complete?)

m_the0ry, could you give me some insight on the problems with my idea for approximating this? My instinct is telling me it should get me pretty close, but I'm way out of my area here.
Reply With Quote
  #15  
Old 08-29-2007, 01:12 AM
m_the0ry m_the0ry is offline
Senior Member
 
Join Date: Aug 2006
Posts: 790
Default Re: A Math Problem (NP Complete?)

Sorry I didn't really answer your OP's question...

First to clarify the problem, you want to maximize calories with using at least 1 item from each category with the total cost <$10.

My question is why you subtract the stats of the highest cal/$ item from the rest. I was assuming that the prices and calories listed are of the lowest denomination. I think I'm not understanding some critical part of your algorithm here. A few potential problems arise from this step because we can very easily corrupt our data. For example you would commonly get a negative cal, negative price, or both, or even worse a divide by zero. This really messes with the algorithm and the way it does comparison. If we have an item with a good ratio but low stats, it will be quickly corrupted by this process (66cal for $.33 for example) but any time the best ratio item has more calories or more cost associated with it than another, something bad will happen.
Reply With Quote
  #16  
Old 08-29-2007, 01:47 AM
KUJustin KUJustin is offline
Senior Member
 
Join Date: Mar 2004
Posts: 1,616
Default Re: A Math Problem (NP Complete?)

m_the0ry, the constraint is ONLY 1 from each category. So the negative numbers would work with that in that those would be rejected. We'd want the maximum incremental cal/$.
Reply With Quote
  #17  
Old 09-01-2007, 02:28 AM
LondonBroil LondonBroil is offline
Senior Member
 
Join Date: Jan 2003
Location: USA #1!
Posts: 2,159
Default Re: A Math Problem (NP Complete?)

Hamburger, bowl of cheese, and pie. I ARE TEH SMART!
Reply With Quote
  #18  
Old 09-05-2007, 12:01 AM
br.bm br.bm is offline
Senior Member
 
Join Date: Jul 2006
Posts: 601
Default Re: A Math Problem (NP Complete?)

why do you guys try to solve this problem?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:01 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.