Minizinc: partial search strategy with sharing indexes - constraint-programming

Given 3 vectors variables of the same length (let's say A, B, and C), is there a way in Minizinc to apply a search strategy on one of them(let's say B), and at each variable of B instantiated, the search goes to the variables in the same position in A and C?
E.g: A =[a1,a2,a3], B=[b1,b2,b3], C=[c1,c2,c3]
I want a search like this:
search on B with some criteria (e.g: first fail, to be sure that we're not going in order)
find the next variable to assign (b2)
assign values to a2 and c2 (same position/same index of b2)
continue the search on B etc...

Complex search heuristics are generally not supported in MiniZinc in general. However, your description of the search might be close to priority search: a search mechanism published for the Chuffed solver.
You can find a description of priority search in the following workshop paper: https://ozgurakgun.github.io/ModRef2017/files/ModRef2017_PrioritySearchWithMiniZinc.pdf

Related

Finding Exact Matches in Text Strings with Search

I've included example screenshots and the forumlas bellow. I'm basically trying to run a list of Competitors against a list of searches. The competitor list is static and the searches list will grow and change overtime.
I'm finding it challenging to get consistent results with the search formula. It either is too loose (example A) or too strict (example B).
Is there a way to use the formula to exact match whole words in a text string? Or do I need to get sneaky with a VBA (something I'm not too familiar with). Or should I be doing this in another program?
Thanks!
Example A
So here, my formula works and says that someone searched containing avamere. However, It gives me a false positive on "roseville communities" because it has seville in roseville.
Example A Formula:
SUMPRODUCT(--ISNUMBER(SEARCH($C$2:$C$5,B2)))>0
Example B
So I tried to normalize the competitors with spaces:
Now they're all false.
Example B Formula:
SUMPRODUCT(--ISNUMBER(SEARCH(" "&$C$10:$C$13&" ",B10)))>0

automatic rota system based on special conditions

I am trying to create system for assigning tasks to a team using existing sequence. I have four separate columns:
Column A – Indicates the given sequence of operators
Column B – Indicates number of current tasks per operator (imported from another file by vlookup)
Column C – Indicates the name of the operator that was assigned to the last task (imported from another file by vlookup)
Column D – Indicates whether any of the operators are currently on holiday (check/uncheck check box (TRUE/FALSE logic)
I would like to automate the system so that the next operator that is due to receive tasks is displayed, however the operator must not have more than 4 tasks already assigned to him/her and must be present (not on holiday).
The selection process must repeat taking into consolidation the given sequence until the name is selected, hence if the last name in the sequence is not the exact match the system must start with the first name in the sequence.
Could someone be able to figure this out please as I am completely stock.
Currently, I have the following, column with the following =IF(B2<=4,A2,"N/A") and another column with the following =IF(E2=FALSE,F2,"N/A"). And one more column with =INDEX(SQESequence,MATCH(C2,SQESequence,0)+1,1), however that is not fully automated.
I think that I understand your problem / question and have come up with a solution. A more elegant formula solution may exist, will play with it more if I have time.
{=IFERROR(INDEX(INDIRECT("A"&MATCH(C2,A2:A5)+1&":A5"),MATCH(1,(INDIRECT("A"&MATCH(C2,A2:A5)+1&":A5")<>$C$2)*(INDIRECT("B"&MATCH(C2,A2:A5)+1&":B5")<4)*(INDIRECT("D"&MATCH(C2,A2:A5)+1&":D5")=FALSE),0)),INDEX($A$2:$A$5,MATCH(1,($A$2:$A$5<>$C$2)*($B$2:$B$5<4)*($D$2:$D$5=FALSE),0)))}
Enter CTRL SHIFT ENTER to set as an array formula, each function then returns an array of values rather than just a single value. You know you have set as an array formula when you see the { } 's
They say that a picture is worth 1000 words....so here are three!

Count categories changes in Excel

I have specific problem which is best described by a picture.
E1:G10 are rules for categories e.g. change from cat C to C will cause 1 hr delay.
There are products which fall into category of a products A, B and C. Next to it you can find quantities of which they are produced.
f you want to rebuild machine from cat. A to B etc. it will cost you time (ruling is described next to it).
I need to find a way how to determine time of rebuild. I did it manually and you can see it column C. However, I wish Excel would do it automatically. Later I am using data in solver.
Does anyone know solution to my problem?
Thanks in advance.
I would use the formula sumifs.
For example the first category "C" with 1000 parts will change to category "A":
"=sumifs(G:G, E:E, A2, F:F, "A")"
I would also suggest you to put additional column with target category change and implement it to the formula.
Hope it helps.

Can excel clean up free-text user entry?

any help would be massively appreciated - I'm really stuck on this.
I have a field on a user entered form that asks people what university they've attended which, due to technical limitations on our system, has to be free text.
This invariably leads to hundreds of different entries for each university, which means I have to use filter on excel and comb through thousands of entries and manually unify - lack of knowledge on how to automate this limits it's practical use massively.
Does anyone know a way we can automate this process of categorizing (and then unifying) different entries which refer to the same thing (e.g someone might put UCL, another might put "university of college, London" and another "university of college london" - I need to teach the system that all 3 are the same and then convert it on excel).
I have a list of the exact entries we want for each university, and I'm happy to manually 'teach' excel when a user entry matches one of these, providing it then learns this for the future (so as time goes on, we have to less and less manual unifying).
Happy to clarify anything, and thanks so much for any help.
Rob
Don't become the victim of user mischief.
Assign a unique ID for each valid response and have the users enter the ID.
Yup...
As you said, you need to do some teaching, here's is the teaching table. Basically just fill up as you go along. You might ask what is UOL, sorry i just crack it out, just for illustration.
And then you have the users inputs (column E), plus 5 calculated columns (F:J)
And now the formulae, I'll show those in row 2 only, the rest are just filled down.
F2 = SUBSTITUTE(E:E," ","*")
G2 = VLOOKUP(E:E,A:B,2,0)
H2 = COUNTIF(A:A,F:F)
I2 = VLOOKUP(F:F,A:B,2,0)
J2 = IFERROR(G2,IF(H2=1,I2,IF(H2=0,"Never seen before","Need validation")))
Basically the logic flow is
do the exact match vlookup of user input in teaching table, if found, then thats it and return the unified name. (Column G)
if the above exact match not found, then we'll proceed to use the star like Helper vallue. Count how many times the HELPER value is found in the teaching table. (Column H)
do the exact match vlookup of helper value in teaching table. (Column I, for use with Column H)
If value in column G is not an error, then use it,
else if value in Column H is 1, then VLOOKUP(HELPER) value is good. If its 0, then you haven't teach excel on the name before. If >2, then it means it need your further attention, the VLOOKUP(Helper) value could be wrong as there are more than one matches.
The trick here is the HELPER column. by replacing blank space with stars, the vlookup now become some sort like vlookup of a sequence of keywords. Doesn't matter how the user's input is, as long as some keywords found and the sequence match, the countif and vlookup return the value.
And at the same time, you also submit an IT enhancement request ! :)

Excel 2013, how to us the "search" function like vlookup

Essentially, I am looking for a way to use the "search" function like the "vlookup" function. In my case, I am have a long list, of say, 1000 descriptions of different types of fasteners and I want to classify them according to what they are, (ie. Nut, bolt, washer etc.). However, I can't sort by description or partnumber because they, alphanumerically, don't line up by class. But he descripotion field does say at some point in it, what it is(ie. Nut, bolt, washer etc.).
As said, I have a table of classes, and I am looking for a formula that would look in the "description" field for all the values in the table,and then return that value, or one associated with it (like vlookup does with cell values).
So that, if it found "nut" in the description, it would return "nut", or if it found "bolt" it would return "bolt."
I hope that this question makes sense. Let me also say that I found a way "manually" do this using the search function, along with others, but the formula was very long and each value in my table had to be specially called out. However, I will include the formula I used to make clear what I was trying to do.
See below.
=IF(ISNUMBER(SEARCH($G$2,C3)),$G$2,IF(ISNUMBER(SEARCH($G$3,C3)),$G$3,IF(ISNUMBER(SEARCH($G$4,C3)),$G$4,IF(ISNUMBER(SEARCH($G$5,C3)),$G$5,...IF(ISNUMBER(SEARCH($G$13,C3)),$G$13,"MISC"))))))))))))
You see that with each item you add to your table, you have to add another if loop. I am hoping there is a better way. (I would call it "vsearch" :-) )
Try this formula
=IFERROR(LOOKUP(2^15,SEARCH($G$3:$G$13,C3),$G$3:$G$13),"MISC")
SEARCH returns an array of numbers or errors depending on whether each term is found in C3. By searching for "bignum" (in this case 2^15) which won't be found, the match is always with the last number, i.e. the last matching term in G3:G13.
MATCH can be used to find the text, and INDEX can be used to return the text
using your example, where you are searching in G:
=MATCH("*"&C3&"*",$G:$G,0)
and then index to return the text
=INDEX($G:$G,MATCH("*"&C3&"*",$G:$G,0))
and as a finishing touch, the #VALUE! replacement
=IFERROR(INDEX($G:$G,MATCH("*"&C3&"*",$G:$G,0)),"MISC")

Resources