What is maximum-edge in minimax algorithm? [closed] - c++

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am having a hard time understanding the minimax or maximin problem from this wikipidea. The thing I can't understand is, what does the problem want? Does it want the shortest path from one node to another? If not this, than what? what is minimum-weight or maximum weight? a clarification with example would be very much helpful.what I exactly want is that what is minimum of maximum weight? I don't understand relation between minimum and maximum.

Explanation through an example: (derived from Wikipedia example)
The minimax path between Maldon and Feering is in red.
Here, the maximum between all the edges is 9.
max(8,9,7,8,9) = 9
There is no possible path where the maximum of all the edges is less than 9.
Note that this is not the shortest path, the shortest path would be the direct path between the two, with a cost of 10, but 10 > 9, so that would not be the minimax path.

The problem is to find a path where the minimum edge on the path is as large is possible.
So, if you have a path P = e1, ..., ek, where ei is the edges weights, let f(P) be min(e1, ..., ek). You should find a path P* so that f(P*) is as high as possible.
Another possible interpretation of the problem: find a maximal weight W such that if you remove every edge with weight < W from the graph, there still will exist a path from source to target. In this case W = f(P*).

Related

About dry and humid heatwaves [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 months ago.
Improve this question
I would appreciate it if someone can assist with a code to calculate the "specific number of heatwaves days where relative humidity > 66% and < 33%".
(whereas, a heatwave event is defined as one in which temperatures exceeded the 90th percentile of the daily mean temperature for at least three consecutive days, respectively).
Ok well here is a solution
# temperature percentile
cdo timpctl,90 infile -timmin infile -timmax t2m.nc t2m_pcen90.nc
# mask the temperature
cdo ge t2m.nc t2m_pcen90.nc mask.nc
# Need to make sure we have three consecutive days
cdo --timestat_date last runmean,3 mask.nc mask3.nc
cdo gec,1 mask3.nc heatwave_T.nc
# Now filter for dry heatwaves, assuming RH is %, change X if fraction
cdo lec,33 rh.nc rhdry.nc
cdo mul heatwave_T.nc rhdry.nc heatwave_dry.nc
# and same for wet
cdo gec,66 rh.nc rhwet.nc
cdo mul heatwave_T.nc rhwet.nc heatwave_wet.nc
Each file should have a 1 in it for each location/time when you are in a heatwave according to your definition. Of course the metadata is appropriate for T2m not the index, use NCO to change that if required. I have several video guides that would help with this question, the key one being the one on masking (it doesn't include the running mean part though). Note also that the RH criterion is applied ONLY on the day (no running mean) but that is how you write the definition in your question. Duplicate the running mean part if needed.
ps: In general it is good to show that you have attempted a solution yourself, before asking, SO guidelines are that questions are of a debugging nature, or can be a request for a one-liner, but not coding requests like "write me a code that does X or Y" - I think that is why you were getting downvoted.

Changing one value of row to column [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I am working on a Power BI report. There are two dimensions DimWorkedClass and DimWorkedService. (The above snippet is obtained by exporting matrix values to csv.)
The requirement is to transform only the Worked Service Text5 into the Worked Class of Text5 as opposed to A (which is the current value).
It can be transformed at the backend, but is there any way to do it in Power BI?
This is trickier than it might appear, but it looks like this question has already been answered here:
Power Query Transform a Column based on Another Column
In your case, the M code would look something like this:
= Table.FromRecords(Table.TransformRows(#"[Source or Previous Step Here]",
(here) => Record.TransformFields(here, {"Worked Class",
each if here[Worked Service] = "text5" then "text5" else here[Worked Class]})))
(In the above, here represents the current row.)
Another answer points out a slightly cleaner way of doing this:
= Table.ReplaceValue(#"[Source or Previous Step Here]",
each [Worked Class],
each if [Worked Service] = "text5" then "text5" else [Worked Class],
Replacer.ReplaceText,{"Worked Class"})

Shortest path without Dijkstra's [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I need some ideas (not solutions) on how to go about solving the following problem.
So there's a guy who need to get to the phones on the top right hand corner of the building. It is guaranteed they will be at that location. We have to find the shortest path he can take to get there. See the image for an example.
The first thing that came to mind was using Dijkstra's algorithm. However, I have been told that it is unnecessary and that there are simpler alternatives.
On another note, if it is a last resort option, I wouldn't mind using Dijkstra's algorithm if someone can guide me through it. I have not much prior knowledge of graph theory, although I'm competent in the language I use (C++).
Explanation:
He takes the escalator from the left side of the ground floor to the right side of the first floor (14 seconds);
He sprints across the first floor from the right side to the left (5 seconds);
He takes the escalator from the left side of the first floor to the right side of the second floor (13 seconds);
He takes the escalator from the right side of the second floor to the left side of the top floor (11 seconds);
He runs from the left side to the right side of the top floor (5 seconds) to claim the phone!
The total time from the front doors to the sales desk is 14+5+13+11+5=48 seconds.
The input will be specified in the following format:
Each line will each contain three integers l f r separated by single spaces, where l represents the number of seconds required to travel from the left-hand side of the current floor to the right-hand side of the floor above, f the number of seconds to run from one side of the floor to the other, and r the number of seconds to travel from the right-hand side of the floor to the left-hand side of the floor above.
Example input:
14 10 15
13 5 22
13 7 11
5
This is a DP question.
f[n][left] = min{f[n-1][left] + time[go_from_left_to_right_on_floor_n-1] + time[escalator_from_right_side_up],
f[n-1][right] + time[escalator_from_right_side_up]}
f[n][right] = min{f[n-1][right] + time[go_from_right_to_left_on_floor_n-1] + time[escalator_from_left_side_up],
f[n-1][left] + time[escalator_from_left_side_up]}
If you want to go to third floor, left side, you can either start from the second floor, left side, go to right side, and take the escalator; or start from the second floor, right side, take the escalator. Choose the way that you use the minimum of time, and keep doing this use a loop(or recursion :) )
The solution should be O(n)
If the problem stays as small as the one you posted, I guess choyukchow's answer will work.
But if the problem gets considerably big, you may want to use heuristics. Example here.

Wondering how twitter does people search [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I've noticed twitter people search can come up with some weird results. Searching for match in screen_name twitter_name and bio is obvious, but they also do something different. I guess it has something to do with Triadic Closure but find its usage for search (instead of suggestions) weird. Wanted to hear your thoughts about this issue.
I think your question might be a little nonspecific, but here are my thoughts:
Suppose your search query was "Miley Cyrus", for instance. Now the top results will for sure include her real account, then fake ones, but then the results will get a little distorted.
I expect it ranks each account / person X in this manner (or something similar):
If person X follows accounts that has the search query in its bio / name, it has a higher rank than if that person didn't.
In our search, "Rock Mafia" is a good example; it doesn't have the term "Miley Cyrus" in its bio nor its name, but if you look at the people "Rock Mafia" is following, you'll find a lot of "similar" names / bios. Another ranking criteria would be this:
If person X has tweets that contains the search query in its content, it would also have a higher rank
A good example is the result "AnythingDisney" (#adljupdated), you can see that the 4th most recent tweet contains "Miley".
So basically the search prioritization looks like this:
Look in name / bio.
Need more results? Rank each person X by his followers and the people he follows, and by tweets that contain the query.
Need even more results? Look at "deeper" levels, rank each person X by the people being followed by the people X is following.
An so on, recursively.
I hope this helped in any manner!

DataMining / Analyzing responses to Multiple Choice Questions in a survey [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have a set of training data consisting of 20 multiple choice questions (A/B/C/D) answered by a hundred respondents. The answers are purely categorical and cannot be scaled to numerical values. 50 of these respondents were selected for free product trial. The selection process is not known. What interesting knowledge can be mined from this information?
The following is a list of what I have come up with so far-
A study of percentages (Example - Percentage of people who answered B on Qs.5 and got selected for free product trial)
Conditional probabilities (Example - What is the probability that a person will get selected for free product trial given that he answered B on Qs.5)
Naive Bayesian classifier (This can be used to predict whether a person will be selected or not for a given set of values for any subset of questions).
Can you think of any other interesting analysis or data-mining activities that can be performed?
The usual suspects like correlation can be eliminated as the response is not quantifiable/scoreable.
Is my approach correct?
It is kind of reverse engineering.
For each respondent, you have 20 answers and one label, which indicates whether this respondent gets the product trial or not.
You want to know which of the 20 questions are critical to give trial or not decision. I'd suggest you first build a decision tree model on the training data. And study the tree carefully to get some insights, e.g. the low level decision nodes contain most discriminant questions.
The answers can be made numeric for analysis purposes, example:
RespondentID IsSelected Q1AnsA Q1AnsB Q1AnsC Q1AnsD Q2AnsA...
12345 1 0 0 1 0 0
Use association analysis to see if there are patterns in the answers.
Q3AnsC + Q8AnsB -> IsSelected
Use classification (such as logistic regression or a decision tree) to model how users are selected.
Use clustering. Are there distinct groups of respondents? In what ways are they different? Use the "elbow" or scree method to determine the number of clusters.
Do you have other info about the respondents, such as demographics? Pivot table would be good in that case.
Is there missing data? Are there patterns in the way that people skipped questions?