How do I know if there are any more solutions? - linear-programming

I have done the Einstein's Riddle exercise with linear programming. I implemented this solutions in Gusek. How can i tell if there is more than one solution?
Einsten's riddle:
There are 5 houses in five different colors.
In each house lives a person with a different nationality.
These five owners drink a certain type of beverage, smoke a certain brand of cigar and keep a certain pet.
No owners have the same pet, smoke the same brand of cigar or drink the same beverage.
Constaints:
the Brit lives in the red house
the Swede keeps dogs as pets
the Dane drinks tea
the green house is on the left of the white house
the green house's owner drinks coffee
the person who smokes Pall Mall rears birds
the owner of the yellow house smokes Dunhill
the man living in the center house drinks milk
the Norwegian lives in the first house
the man who smokes blends lives next to the one who keeps cats
the man who keeps horses lives next to the man who smokes Dunhill
the owner who smokes BlueMaster drinks beer
the German smokes Prince
the Norwegian lives next to the blue house
the man who smokes blend has a neighbor who drinks water
Can I tell which constraints are redundant?
Thank you for your help

Your decisions/solution will be in the form of binary or integer varibles.
If they are binary, add in a new constraint like the one below:
(Y are all the binaries which were 1 and `Y are binaries which were 0.)
sum(Y) + sum(i-Y) != |Y|+|Y|
Keep repeating this till you get an infeasible model. This can be extended to the integer case too.
As for redundancy, you have to manually try removing them and see if the solution changes. However, in terms of reduncancy, you might have cases where constraint A and B are redundant OR constraint C is redundant. You could have multiple sets of potential redundant constraints depending on which you eliminate.

Related

NetLogo: How to change shape of a turtle if condition is true?

I want to make 2 turtles(a male and a female) get married. I have 2 different shapes for males and females in my simulation.
If a female meets a male on the same patch, they get married. When they do, I want to bundle them as one unit (i.e. I want to delete one of the turtles, and change the other to a third shape indicating a married couple).
How can I do this. I am already lost at the "meeting" stage.
What I have:
if any? other turtle-here with [?????]
Pseudocode:
if female on_same_patch_as_male:
change her marital-status to married
Remove [one of the two turtles]
change the shape of the remaining turtle to "married-couple-icon"
Any help is appreciated

Is there a "startsWith" method for map keys in flutter?

I am a beginner in Flutter and I am stuck at converting my API fetched data to my custom model.
I am using an API that provides me with this data:
{"meals":[{"idMeal":"52852","strMeal":"Tuna Nicoise","strDrinkAlternate":null,"strCategory":"Seafood",
"strArea":"French","strInstructions":"Heat oven to 200C\/fan 180C\/gas 6. Toss the potatoes with 2 tsp oil and some seasoning. Tip onto a large baking tray, then roast for 20 mins, stirring halfway, until crisp, golden and cooked through.\r\nMeanwhile, put eggs in a small pan of water, bring to the boil, then simmer for 8-10 mins, depending on how you like them cooked. Plunge into a bowl of cold water to cool for a few mins. Peel away the shells, then cut into halves.\r\nIn a large salad bowl, whisk together the remaining oil, red wine vinegar, capers and chopped tomatoes. Season, tip in the onion, spinach, tuna and potatoes, then gently toss together. Top with the eggs, then serve straight away.",
"strMealThumb":"https:\/\/www.themealdb.com\/images\/media\/meals\/yypwwq1511304979.jpg","strTags":null,
"strYoutube":"https:\/\/www.youtube.com\/watch?v=3_UAxkx0u6U",
"strIngredient1":"Potatoes","strIngredient2":"Olive Oil","strIngredient3":"Eggs","strIngredient4":"Red Wine Vinegar","strIngredient5":"Capers","strIngredient6":"Sunflower Oil","strIngredient7":"Red Onions","strIngredient8":"Spinach","strIngredient9":"Tuna","strIngredient10":"","strIngredient11":"","strIngredient12":"","strIngredient13":"","strIngredient14":"","strIngredient15":"","strIngredient16":"","strIngredient17":"","strIngredient18":"","strIngredient19":"","strIngredient20":"",
"strMeasure1":"450g","strMeasure2":"2 tblsp ","strMeasure3":"4","strMeasure4":"1 tbls","strMeasure5":"2 tblsp ","strMeasure6":"50g","strMeasure7":"\u00bd","strMeasure8":"100g ","strMeasure9":"400g","strMeasure10":"","strMeasure11":"","strMeasure12":"","strMeasure13":"","strMeasure14":"","strMeasure15":"","strMeasure16":"","strMeasure17":"","strMeasure18":"","strMeasure19":"","strMeasure20":"",
"strSource":"https:\/\/www.bbcgoodfood.com\/recipes\/9529\/winter-tuna-nioise",
"strImageSource":null,"strCreativeCommonsConfirmed":null,"dateModified":null}]}
I want to store all the values of keys that begin with "strIngredient" into a list, and the same goes for "strMeasure"
But I haven't come across a method yet that could do the mentioned.
You can get all keys and then check each one against your condition.
Map<String,String> meals= api_data['meals'][0];
List<String> allKeys = meals.keys.toList();
for(String key in allKeys){
if(key.startsWith("strIngredient")){
print(meals[key]);
}
}

Google Cloud VideoIntelligence Speech Transcription - Transcription Size

I use Google Cloud Speech Transcription as following :
video_client = videointelligence.VideoIntelligenceServiceClient()
features = [videointelligence.enums.Feature.SPEECH_TRANSCRIPTION]
operation = video_client.annotate_video(gs_video_path, features=features)
result = operation.result(timeout=3600)
And I present the transcript and store the transcript in Django Objects using PostgreSQL as following :
transcriptions = response.annotation_results[0].speech_transcriptions
for transcription in transcriptions:
best_alternative = transcription.alternatives[0]
confidence = best_alternative.confidence
transcript = best_alternative.transcript
if SpeechTranscript.objects.filter(text = transcript).count() == 0:
SpeechTranscript.objects.create(text = transcript,
confidence = confidence)
print(f"Adding -> {confidence:4.10%} | {transcript.strip()}")
else:
pass
For instance the following is the text that I receive from a sample video :
94.9425220490% | I refuse to where is it short sleeve dress shirt. I'm just not going there the president of the United States is a visit to Walter Reed hospital in mid-july format was the combination of weeks of cajoling by trump staff and allies to get the presents for both public health and political perspective wearing a mask to protect against the spread of covid-19 reported in advance of that watery trip and I quote one presidential aide to the president to set an example for a supporters by wearing a mask and the visit.
94.3865835667% | Mask wearing is because well science our best way to slow the spread of the coronavirus. Yes trump or Matthew or 3 but if you know what he said while doing sell it still anybody's guess about what can you really think about NASCAR here is what probably have a mass give you probably have a hospital especially and that particular setting were you talking to a lot of people I think it's but I do believe it. Have a a time and a place very special line trump saying I've never been against masks but I do believe they have a time and a place that isn't exactly a ringing endorsement for mask wearing.
94.8513686657% | Republican skip this isn't it up to four men over the perfumer's that wine about time and place should be a blinking red warning light for people who think debate over whether last for you for next coronavirus. They are is finally behind us time in a place lined everything you need to know about weird Trump is like headed next time he'll get watery because it was a hospital and will continue to express not so scepticism to wear masks in public house new CDC guidelines recommending that mask to be worn inside and one social this thing is it possible outside he sent this?
92.9862976074% | He wearing a face mask as agreed presidents prime minister's dictators Kings Queens and somehow. I don't see it for myself literally main door he responded this way back backstage, but they said you didn't need it trump went to Michigan to this later and he appeared in which personality approaching Mark former vice president Joe Biden
94.6677267551% | In his microwave fighting for wearing a mask and he walked onto the stage where it is massive mask there's nobody understands and there's any takes it off you like to have it hanging off you. I think it makes them feel good frankly if you want to know the truth who's got the largest basket together. Seen it because trump thinks that maths make him and people generally I guess what a week or something is resistant wearing one in public from 1 today which has had a correlation between the erosion of the public's confidence and trump have the corner coronavirus and his number is SE6 a second term in the 67.
94.9921131134% | The coronavirus pandemic in the heels of national and swings they both lots of them that show trump slipping further and further behind former vice president Joe Biden when it comes to General Election good policy would seem to make for good politics at all virtually every infectious disease expert believes that wearing masks in public is our best to contain the spread of coronavirus until a vaccine would do well to listen to buy on this one a mare is the point we make episode every Tuesday and Thursday make sure to check them all out.
What is the predicted size of a transcript that is generated within the speech transcription results. What decides the size of each transcript ? What is the max and minimum character length ? How should I design my SQL table column size, in order to be prepared for the expected transcript size ?
As I mentioned in the comments, the Video Intelligence transcripts are splits with roughly 50-60 seconds from the video.
I have created a Public Issue Tracker case, link, so the product team can clarify this information within the documentation. Although, I do not have an eta for this request, I encourage you to follow the case's thread.

How to analyse the survey to understand how answer to one question impacts rest

I have a survey data with 5 Question
1.) Whom yu are living with : girlfriend, wife
2.) If the person healthy : yes, no, partially
3.) Is the person working : Yes, No
4.) Are you happy with the person : Yes, No, Cant Say
5.) If the person owns a house : yes, no
I want to analyse one answer impacts the rest of the answers. For eg. how many of perople living with wife who has house and are happy. The requirement is to analyse these answers along each other.
The data collected is this format below. Please suggest what would be the best way to analyse the data in such fashion.
UserId Question Answer
1 Whom yu are living with Wife
1 If the person healthy Yes
1 Is the person working No
1 Are you happy with the person Yes
1 If the person owns a house No
2 Whom yu are living with Girlfriend
2 If the person healthy Partial
2 Is the person working Yes
2 Are you happy with the person Yes
2 If the person owns a house No
3 Whom yu are living with Wife
3 If the person healthy Yes
3 Is the person working yes
3 Are you happy with the person No
3 If the person owns a house Yes
I initially thought of to create a tree map with Questions and Answers and use drill through the open second page with tree map filtered on the user id. But later i realized that the drill through could use the filters which are not part of the parent chart.
Than i thought of using parameters like SSRS, but power bi has limitation to have only one value to the parameters.
What i am looking for is a descent way to analyse this data. Or a workaround on the two possible options i tried to remove roadblocks.
I am open to any different way to analyse the data then i am doing if it answers the questions.
Maybe a simple one, but as long as you are not planning on doing statistical analysis and just want to explore the data, maybe create 5 bar charts with the category of the X and a count on the Y and use the build in interactions by clicking on different categories to gain a basic understanding.

Web service or mechanism to detect Person, Place or an Object

Is there a web service or a tool to detect if what a certain text is the name or a person, a place or an object (device).
eg:
Input: Bill Clinton Output: Person
Input: Blackberry Output: Device
Input: New york Output: Place
Accuracy can be low. I have looked at opencyc but I couldnt get it to work. Is there a way I can use WikiPedia for this?
For a start separating a person or a thing will be great.
I think wikipedia would be a very good source. Given the input, you could try and find an entry in wikipedia and scrape the resulting page (if it exists).
Persons and Places should have fairly distinct sets of data - birthdates, locations, etc in the article that you could use to tell them apart, and anything else is an object.
It's worth a shot anyway.
Looking at the output of Wolfram Alpha, it seems that you can possibly identify a person by searching Bill Clinton Birthday or just Bill Clinton, or you can identify a location by searching New York GPS coordinates or just New York, for even better results. Blackberry seems like a tough word for Alpha, because it keeps wanting to interpret it as a fruit. You might have luck searching Froogle to identify a device.
It seems like WA will give you a fairly decent accuracy, at least if you're using famous people/places.
How about using a search engine? Google would be good, and I think Yahoo! has tools for building your own search.
I googled:
Results 1 - 10 of about 27,100,000 for "bill clinton" person
Results 1 - 10 of about 6,050,000 for "bill clinton" place
Results 1 - 10 of about 601,000 for "bill clinton" device
He's a person!
Results 1 - 10 of about 391,000,000 for "new york" place.
Results 1 - 10 of about 280,000,000 for "new york" person.
Results 1 - 10 of about 84,100,000 for "new york" device.
It's a place!
Results 1 - 10 of about 11,000,000 for "blackberry" person
Results 1 - 10 of about 36,600,000 for "blackberry" place
Results 1 - 10 of about 28,000,000 for "blackberry" device
Unfortunately, blackberry is a place as well. :-/
Note that only in the case of 'blackberry' did "device" even get close. Maybe you need to weight the page hit values. What is your application? Do you have any idea which "devices" you'd have to classify? What is the possible range of inputs?
Maybe you want to combine the results you get from different sources.
I think the basic task you're trying to accomplish is more formally known as named entity recognition. This task is nontrivial, and by only inputting the name stripped of any context, you're making it even harder.
For example, we'd like to think examples such as "Bill Clinton" and "New York" are obviously unambiguous, but looking at their disambiguation pages in Wikipedia shows that there are several potential entities they may refer to. "New York" is both a state, city, and movie title. "Bill Clinton" is a bit less ambiguous if you're only looking at Wikipedia, but I'm sure you'll find dozens of Bill Clintons in any phonebook. It might also be the name of someone's sailboat or pet dog. What if someone inputs "Washington"? That could be both a U.S. President, state, district, city, lake, street, island, movie, one of several U.S. navy ships, bridge, as well as other things. Determining which is the "correct" usage you'd want the webservice to return could become very complicated.
As much as Cyc knows, I think you'll find it's still not as comprehensive as Wikipedia. However, the main downside to Wikipedia is that it's essentially unstructured. Personally, I find Cyc's API so convoluted and poorly documented, that parsing Wikipedia's natural language almost seems easier.
If I had to implement such a webservice from scratch, I'd start by downloading a snapshot of Wikipedia, and then writing a parser that would read through all the articles, and generate a named entity index based on article titles. You could manually "classify" a few dozen examples as person/place/object, and train a classifier (Bayesian,Maxent,SVM) to automatically classify other examples based on the word frequencies of their articles.