I want to generate a meal plan consisting of 3 meals, one of the meals are already chosen.
A target for these 3 meals could be 3000 calories and a cooking time on 180 min.
These 3 meals should be as close to the target as possible.
I have a problem with implementing A*. I can't figure out how to translate the usual grid to a graph of recipes. And how this "path" should be generated.
Related
I am trying to build a baseball spreadsheet for my little league team. I have 10 players and 15 games. I am trying to figure out a way to populate the batting order where everyone gets an equal numbers of games batting 1-10 in the order.
Does anyone know of an easy way to do this?
As mentioned in the comments, it's impossible to evenly distribute 10 players in 10 batting order positions over 15 games. It's similar to trying to divide 15 by 10 evenly. So you'll have to get creative on how to handle the five remaining games (fundraiser?)
Random but Fair For Ten Games
In answer to your question of creating a random batting order, you'd probably only want to randomize once, and then offset the order by 1 position each game. This will get you each player in one position in for ten games.
Random Each Game
If you truly wanted random each game, you'd probably have some undesirable distribution with some kids getting to bet first multiple times while others never get a turn (hazards of truly random).
I built out a quick spreadsheet on google sheets here that you can see how such a tool could work. If you download and hit delete in a blank cell it will re-randomize the sheet. It's using the functions index and Rank and Rand.
Good luck.
I am using a pivot table to count the number of loans that a certain state has in a certain category. For example:
Label Count
Arizona 50
Payment on time 25
Payment delayed one month 15
Payment delayed two months or more 5
This means that Arizona has 50 loans, from which 25 are on time, 15 have a slight delay and 5 have a serious delay. Unfortunately, there are certain states that have no loans in a given category and I would like the pivot table to display a zero in one such case.
For example, I would like to go from this:
Label Count
Texas 50
Payment on time 45
Payment delayed one month 5
To this:
Label Count
Texas 50
Payment on time 45
Payment delayed one month 5
Payment delayed two months or more 0
In essence, I want every state to display all three categories: On time, 1 month delay and 2+ months delayed. Even if they have no loans in either one of those categories.
Thanks in advance!
I apologize for posting something with such an easy fix. Here's how I managed it.
I went into the fields popup window and selected:
Rows -> Field settings -> Design and Layout -> Show items with no data
The pivot table now display all three categories for every state.
Thanks for your help anyway.
Background
I wish to compare menu sales mix ratios for two periods.
A menu is defined as a collection of products. (i.e., a hamburger, a club sandwich, etc.)
A sales mix ratio is defined as a product's sales volume in units (i.e., 20 hamburgers) relative to the total number of menu units sold (i.e., 100 menu items were sold). In the hamburger example, the sales mix ratio for hamburgers is 20% (20 burgers / 100 menu items). This represents the share of total menu unit sales.
A period is defined as a time range used for comparative purposes (i.e., lunch versus dinner, Mondays versus Fridays, etc.).
I am not interested in overall changes in the volume (I don't care whether I sold 20 hamburgers in one period and 25 in another). I am only interested in changes in the distribution of the ratios (20% of my units sold were hamburgers in one period and 25% were hamburgers in another period).
Because the sales mix represents a share of the whole, the mean average for each period will be the same; the mean difference between the periods will always be 0%; and, the sum total for each set of data will always be 100%.
Objective:
Test whether the sales distribution (sales mix percentage of each menu item relative to other menu items) changed significantly from one period to another.
Null Hypothesis: the purchase patterns and preferences of customers in period A are the same as those for customers in period B.
Example of potential data input:
[Menu Item] [Period A] [Period B]
Hamburger 25% 28%
Cheeseburger 25% 20%
Salad 20% 25%
Club Sandwich 30% 27%
Question:
Do common methods exist to test whether the distribution of share-of-total is significantly different between two sets of data?
A paired T-Test would have worked if I was measuring a change in the number of actual units sold, but not (I believe) for a change in share of total units.
I've been searching online and a few text books for a while with no luck. I may be looking for the wrong terminology.
Any direction, be it search terms or (preferably) the actual names appropriate tests, are appreciated.
Thanks,
Andrew
EDIT: I am considering a Pearson Correlation test as a possible solution - forgetting that each row of data are independent menu items, the math shouldn't care. A perfect match (identical sales mix) would receive a coefficient of 1 and the greater the change the lower the coefficient would be. One potential issue is that unlike a regular correlation test, the changes may be amplified because any change to one number automatically impacts the others. Is this a viable solution? If so, is there a way to temper the amplification issue?
Consider using a Chi Squared Goodness-of-Fit test as a simple solution to this problem:
H0: the proportion of menu items for month B is the same as month A
Ha: at least one of the proportions of menu items for month B is
different to month A
There is a nice tutorial here.
The situation is akin to the following:
Assume I am a store selling fruits, I would like to record the costs of each type of fruit. Assume the customer has specific tastes, and they can differentiate everything.
A fruit can be an orange, apple,
pear, or peach
It could be n days fresh from the vendor
The fruits come from different countries and have different taxes for export
Fruits are also valued by weight
Fruits could have handling requirements (Fridge,water sprigs)
Fruits could also be valued just because of different origins
One idea is to do what is done in some industries, assign a unique product code for each variation: e.g. Orange5dayfreshAustralia200gfridgeSydney
This however, would be a HUUUUUGE long list of values, and should any costs change, it would be hell to search for Apples from Turkey that are 200 grams have now 20cents more export tax. Adding new variables would also massively mess up the whole table and require much recoding.
The other way is to assume a standard orange, peach, apple and pear and different weight(2 dimensional table). On other tables, prepare a list of cost savings/increase for any given deviation. (Law of probability should show me I have 80% "standard" fruits, and 20% niche fruits from funky places having funky costs)
E.g. a 1 day fresh orange compared to a standard 4 day fresh orange is 50cents more, regardless of weight.
(Yes, this means the primary table would need to have at least one variable that dont affect the others)
Final constrain: The data entry is done by hired hands, needs to be simple to enter in Excel. The programing can be difficult, but not the general interface.
Any suggestions?
If the information needs to be encoded in the product code, you can use subcodes to build a complete product code.
Type of fruit
AP - Apple
OR - Orange
PR - Pear
PC - Peach
You can use Country Codes for the country, and other subcodes for handling and origin.
EXAMPLE:
AP06BR145HROR
is a Brazilian apple, six days old, weighing 145 grams, with HR handling and OR origins.
Obviously you would need a lookup table and foreign keys for each of the code types.
You seem to have twigged your problem - your data structure is wrong.
Your list is really a collection of attributes that apply to each "batch" of stock you purchase - except perhaps for "n days fresh" where the attribute is the difference between the attributes of date picked and date delivered.
So what you really want is a data table for each attribute type, and then a transcation data table where you add the attributes. The input is a form where the attributes are loopups.
You also need your pricing rules in a table, which you can use to calculate prices.
If your transaction table records both sales and purchases then you can filter on the attributes to report by any combination you like.
But the bit that interests me is how you work out how old the fruit is you are selling. You might know from the paperwork that you have purchased x oranges from Spain on one day and y oranges from Italy on another day, but in the box oranges are just oranges - so how do you tell which are which? Or are you planning to use a FIFO or LIFO scheme?
Usually players in a soccer manager game have market values. The managers sell their players in accordance with these market values. They think: "Oh, the player is worth 3,000,00 so I'll try to sell him for 3,500,000".
All players have three basic qualities:
strength value (1-99)
maximal strength they can ever attain (1-99)
motivation (1-5)
current age (16-40)
Based on these values, I calculate the market values at the moment. But I would like to calculate the market values dynamically according to the player transfers in the last period of time. How could I do this?
I have the above named qualities and the player transfers of the last period of time available for calculation.
How could I calculate it? Do I have to group the last transferred players by the qualities and simply take the average transfer price?
I hope you can help me.
Note: players=items/goods, managers=users
My suggestion: define a distance function that takes two players stats and return a distance value. Now that you have a distance between the two (that corresponds to the similarity between them) you can use the K-means algorithm to find clusters of similar players.
For each cluster you can take a number of values that can help you calculate the so called 'market price' (like the average or median value).
Here's a very simple example of how you could compute the distance function between two players:
float distance(Player player1, Player player2){
float distance = 0.0;
distance += abs(player1.strength - player2.strength) / strengthRange;
distance += abs(player1.maxStrength - player2.maxStrength) / maxStrength;
distance += abs(player1.motivation - player2.motivation) / motivationRange;
distance += abs(player1.age - player2.age) / ageRange;
return distance;
}
Now that you have the distance function you can apply the k-means algorithm:
Assign each player randomly to a cluster.
Now compute the centroid of each cluster. In your case the centroid coordinates will be (strength, maxStrength, motivation, age). To compute the centroid strength coordinate, for example, just average the strengths for the all players in the cluster.
Now assign each player to the nearest centroid. Note that in this step some players may have its cluster changed.
Repeat steps 2 and 3 until you have convergence or, in other words, until no player have its cluster changed in step 3.
Now that you have the clusters, you can calculate the average price fore similar players.
One thing that you could do is look at recent transfers of similar(1) players. Say all transfers within 2-5 game weeks of similar players and then take the average (or median or some other calculated value) of their sale price.
(1) You will have to define similiar in some way, i.e a defender with +-10 in defence, +-3 in passing and +-2 years of age. More factors give more precise results.
Or you could use a little Economics 101 and try to define the supply and demand for that specific player based on:
Number of players in the league with similar capabilities (you could use the clustering method mentioned before) and number of those players "available" for transfer
Number of teams that own the players with similar capabilities and number of teams that are in need for such players
Now with these number you could calculate the supply (available players for transfer) and demand (teams in need for those players) and use that to modify your base price (which can be your last transfer price or a base price for a player) up or down (ie more demand than supply will tend to push the prices up and vice versa)
After that it becomes negotiation game where you can take a look at some of the Game Theory literature to solve the actual exchange price.
Hope this at least give you a different look into it.