Why does the Alloy API solution's ".next()" method keep returning the same solution? Can I force it to return the next unique solution? - alloy

Can anyone explain why the Alloy API solution's ".next()" might return the exact same solution ad infinitum? It doesn't always, but when it does, I get stuck in an infinite loop. Is there a way to get the next unique solution?

Related

Spotfire In Statements, Ranges, Etc

I come from an SQL background, so trying to limit data coming into the Spotfire project using the expression builder has become a challenge. For instance, I can't seem to find an example of the equivalent of the following:
SELECT *
FROM TABLE
WHERE COLUMN IN ('X','Y','Z')
It's probably staring me in the face, but the only examples I can find are for IF and CASE statements, which are not what I want.
Another example is trying to find an example of an equivalent BETWEEN statement (i.e, WHERE COLUMN BETWEEN 1 and 20). I found the RANGE function, but I have not found any good examples on how to use it.
Does anyone have any suggestions to sites which would provide some examples of what should be easy expressions to create? The online Spotfire guide is not that helpful and my google fu has failed to find anything.
If you could give me some pointers on the two statements above, I would really appreciate it!
Thanks!
I managed to get some suggestions from some friends of mine. Gaia, thank you for your suggestion--YouTube was one suggestion I did receive. I also heard about community.tibco.com, which I will be checking out.

Generating multiple optimal solutions using Excel solver

Is there a way to get all optimal solutions when you are solving some problem with Excel Solver (Simplex LP method)?
If not, what is the best way/add-in to Excel to solve it and convert existing VBA code to use this new way?
Actually, I have found a way to do this with Excel solver, although it is not optimal in sense of time consumption but that is not issue for me.
If you can assign unique id for each possible solution on some way, which is true in my case, then for each solution you find you can check if there is some solution with same value with different id on following way :
Find first optimal solution and save solution id and result. I will call this origID, origRes
Check if there is some solution with id < origID and res = origRes
If yes, then consider newId as initial id and continue with step 2 until you can't find solutions which satisfied criteria
After that, do the same thing with condition id > origID and res = origRes
After you make sure you found all solutions with optimal solution origRes, then we can go and find solution which is not optimal as origRes. I did it on a way to add condition that new solution needs to be <= (origRes - 0.01) because I know that all solutions will be with 2 decimal places.
Go to step 2 again
I know this is not the best way but I usually do not need more than 100 solutions and currently I can get it in 2 mins which is acceptable for me.
Although this looks easy, it actually is not such an easy question. Even the definition of "all possible optimal solutions" is not clear. There may by infinitely many of them. Asking for "all basic feasible solutions" (i.e. corner points) sounds better. To my knowledge there are no solvers providing this. I also do not know of a really simple technique to enumerate all optimal bases.
One interesting approach is to use a MIP formulation to enumerate all optimal bases:
Sangbum Lee, Chan Phalakornkule, Michael M. Domach, Ignacio E. Grossmann, "Recursive MILP model for finding all the alternate optima in LP
models for metabolic networks," Computers and Chemical Engineering 24 (2000) 711-716. (link)

JAVAFX8 updating controls models?

UI Control such as LISTVIEW or Tree or ... comes with model that is observable.
When one make a change to that model, I suppose JavaFX knows how to refresh it automatically in the display.
However my question here is as follows:
Is it the intent way, that someone who wants to update and not replace this model, do so in a background thread with a platform.runlater.
In other words, one has some serious computation to do, and needs to to update an ObservableList as a result. Is it the intended way, to do the heavy work in a background thread and at the end of it, run the update in a platform run later?
I'm asking this because this is what I have been doing so far without problem. But from my reading here and there, in particular in
http://docs.oracle.com/javase/8/javafx/api/javafx/concurrent/Task.html
It seems that some other mechanism shall be used. One should rather return a full list instead of updating the observable list.
But this works only if things comes from the GUI. In case the update is triggered from the back end, there is no way to do so.
The solution that I have used so far, was always to hold a reference to the observable list and updating it by means of platform.Runlater.
Is there any other way ?
The link you give has an example (the PartialResultsTask) that does as you describe: it updates an existing ObservableList as it progresses via a call to Platform.runLater(). So this is clearly a supported way of doing things.
For updating from the back end (i.e. from a class unaware that the data are being used in a UI), you'd really have to post some code for anyone to be able to help. But you might have a look at the techniques used in this article. While he doesn't actually update lists from the backend in the examples there, the same strategy could be used to do so.

Use of INDEX MATCH to find absolute closest value

I've long sought a method for using INDEX MATCH in Excel to return the absolute closest number in an array without reorganizing my data (since MATCH requires lookup_array to be in descending order to find the closest value greater than lookup_value, but ascending order to find the closest value less than lookup_value).
I found the answer in this post. XOR LX's solution:
=INDEX(B4:B10,MATCH(TRUE,INDEX(ABS(A4:A10-B1)=MIN(INDEX(ABS(A4:A10-B1),,)),,),0))
worked perfectly for me, but I don't know why. I can rationalize most of it but I can't figure out this part
INDEX(ABS(A4:A10-B1)=MIN(INDEX(ABS(A4:A10-B1),,))
Can anyone please explain this part?
I guess it makes sense for me to explain it, then!
Actually, it didn't help that I was employing a technique which is designed to circumvent having to enter a formula as an array formula, i.e. with CSE. Although that could be considered a plus by some accounts, I think I was wrong to employ it here, and probably wouldn't do so again.
The technique involves inserting extra INDEX functions at appropriate places within the formula. This forces the other functions, which without array-entry would normally act upon only the first element of any array passed to them, to instead operate over all elements within that array.
However, whilst inserting a single INDEX function for the purpose of avoiding CSE is, in my opinion, perfectly fine, I think when it gets to the point where you're using two or three (or even more) such coercions, then you should probably re-think whether it's worth it all (the few tests that I've done suggest that, in many cases, performance is actually worse off in the non-array, INDEX-heavy version than the equivalent CSE set-up). Besides, the use of array formulas is something to be encouraged, not something to be avoided.
Sorry for the ramble, but it's kind of to the point actually since, if I had given you the array version, then you may well not have come back looking for an explanation, since that version would look like:
=INDEX(B4:B10,MATCH(TRUE,ABS(A4:A10-B1)=MIN(ABS(A4:A10-B1)),0))
which is objectively far easier syntactically to understand than the other version.
Let me know if that helps and/or you still want me to go through a breakdown of either solution, which I'd be happy to do.
You may also find the following links of interest (I hope that I'm not breaking any of this site's rules by posting these):
https://excelxor.com/2014/09/01/index-an-alternative-to-array-cse-formulas
https://excelxor.com/2014/08/18/index-returning-entire-rowscolumns
Regards

Backbone.js: form fields are not being sent in the request

Please forgive the newb question, but I am not finding answers elsewhere... probably because I'm not sure what the question should really be.
I am VERY new to Backbone.js, and I am trying to figure out why changes in the page's form fields are not being sent in POST/PUT requests. The 'change' event IS firing, and the View is catching it, but the model does not have the fields it should have from the form. I haven't been able to find anything that deals with this, so I am fairly certain we have just done something very wrong in our app... but I don't know how to figure out what that might be.
I realize this is not the most complete question, so please let me know if more info is required. I am so new to this that I am not even sure what one might need to track this down.
Any help at all would be greatly appreciated. Thank you in advance,
vegtabill
With backbone.js, there is more than one way to do something. I personally update my model with the data from the view and then json serialize that data for transmission to the server side if I'm not using the REST capabilities build into backbone collections of models (i.e. the fetch, save, etc.) You can use the model.set() method to do this. I am fairly new to backbone too so please don't slam me if you take offense to my approach. I know there are others out there that know a lot more about this topic than me. This approach works for me and it enforces my personal goal of the model not having a reference to the view. That separation is important to me personally. To be more explicit, I listen for events on my view that I then use to update my model.

Resources