Are all field of a list belong to one CFS - specman

Do generatable array fields always belong to the same CFS?
In case one of the list fields has a constraint, and another field has a different constraint and they are not connected. Will both the fields belong to the same CFS?

If the fields aren't connected than each field will be on a different CFS.

The question is not totally clear but here is an attempt to answer:
if this is a list of struct with several fields, the different fields will belong to the same CFS only if connected (e.g. l[0].x and l[0].y will belong to the same CFS only if there is a constraint connecting them).
assuming the question referred to different indices of the same list path (e.g. l[0].x and l[1].x, or m[0] and m[1]), then we need to differentiate between the static and runtime considerations:
statically, both paths are considered to belong to the same CFS. For example, ICFS analysis assume that, so "keep x < f(m[0]); keep m[1] < g(x)" will create an ICFS.
on runtime, IntelliGen tries to solve the list items one-by-one (as if they were in different CFSs), for performance reasons. However, when the list items are connected (either directly or to different variables), which in IntelliGen's terms is called 'lace', they are indeed solved as one CFS, which can be very large.
for more details, I suggest to read section 4.3 ("Avoid Dependencies Between List Elements") in the IntelliGen user guide.

Related

Using found set of records as basis for value list

Beginner question. I would like to have a value list display only the records in a found set.
For example, in a law firm database that has two tables, Clients and Cases, I can easily create value list that displays all cases for clients.
But that is a lot of cases to pick from, and invites user mistakes. I would like the selection from the value list to be restricted to cases matched to a particular client.
I have tried this method https://support.claris.com/s/article/Creating-conditional-Value-Lists-1503692929150?language=en_US and it works up to a point, but it requires too much entry of data and too many tables.
It seem like there ought to be a simpler method using the find function. Any help or ideas greatly appreciated.

Swift: Implementing custom merge policy

I'm building an OSX app using Swift, with Coredata as my data layer. As part of this, I have table that lists a large number of files, with metadata associated with each. Each record can include a URI that points to one of three services it can be hosted on.
1. title created_at size uuid source_local source_remote source_cloud
I generate all the records using information pulled from the local source. These records all have a source_local string.
Later I import a number of records from the remote source. These records are all added and have a source_remote string.
A number of these records are hosted on both services, and have matching UUIDs. There is a unique constraint on the UUID field, and I want Swift to merge these two records' fields in some way when it has a constraint error.
I've tried:
NSMergeByPropertyStoreTrumpMergePolicy
and
NSMergeByPropertyObjectTrumpMergePolicy
But these policies result in one record completely trumping the other.
Currently I have to work around this limitation by checking if a record already exists with the UUID and updating the existing record with any missing fields in the new file.
However this feels non-optimal – is there a way to create a custom merge policy, in order to have Swift automatically handle conflicts in this way? At this stage I am not concerned with whether the Store or Memory record trumps the other, as long as I can correctly the merge the source_* fields.
Thanks
First of all, thanks to #tom-harrington for his nod to extend NSMergePolicy. Huge oversight on my part that I hadn't even considered going down that route.
While exploring how NSMergeByPropertyStoreTrumpMergePolicy/NSMergeByPropertyObjectTrumpMergePolicy are implemented, however, I realised that this issue stems from a misunderstanding on my part. These policies already handle conflicts at a property level. Rather than discarding the entirety of one of the object states on conflict, they compare each property and only apply the policy to those properties which have both changed/exist.
NSOverwriteMergePolicy and NSRollbackMergePolicy are policies that will result in one of either object A or B being completely discarded on conflict.

Database and item orders (general)

I'm right now experimenting with a nodejs based experimental app, where I will be putting in a list of books and it will be posted on a forum automatically every x minutes.
Now my question is about order of these things posted.
I use mongodb (not sure if this changes the question or not) and I just add a new entry for every item to be posted. Normally, things are posted in the exact order I add them.
However, for the web interface of this experimental thing, I made a re-ordering interaction where I can simply drag and drop elements to reorder them.
My question is: how can I reflect this change to the database?
Or more in general terms, how can I order stuff in general, in databases?
For instance if I drag the 1000th item to 1st order, everything below needs to be edited (in db) between 1 and 1000 the entries. This does not seem like a valid and proper solution to me.
Any enlightenment is appreciated.
An elegant way might be lexicographic sorting. Introduce a String attribute for each item. Make the initial length of the values large enough to accomodate the estimated number of items. E.g., if you expect 1000 items, let the keys be baa, bab, bac, ... bba, bbb, bbc, ...
Then, when an item is moved from where it is to another place between two items, assign a value to the sorting attribute of the moved item that is somewhere equidistant (lexicographically) to those items. So to move an item between dei and dej, give it the value deim. To move an item between fadd and fado, give it the value fadi.
Keys starting with a were initially not used to leave space for elements that get dragged before the first one. Never use the key a, as it will be impossible to move an element before this one.
Of course, the characters used may vary according to the sort order provided by the database.
This solution should work fine as long as elements are not reordered extremely frequently. In a worst case scenario, this may lead to longer and longer attribute values. But if the movements are somewhat equally distributed, the length of values should stay reasonable.

Specifying Resource Allocation algorithm?

Can someone help me to solve or specify what type of problem is this:
I have a set of resources and a number of users, and for each user there is a specific subset of resources that can choose a single resource from for allocation. Two different users could not be assigned to the same resource.I need to allocate resources to users in a way to maximize the allocation. for example:
R={r1,r2,r3,r4} %set of resources
U={u1,u2,u3,u4} %set of users
u1 can choose a single resource from: {r1, r2, r3}
u2 can choose a single resource from: {r1, r2}
u3 can choose a single resource from: {r1, r4}
u4 can choose a single resource from: {r2}
in this case I should allocate
r3->u1, r1->u2, r4->u3, r2->u4.
If this was allocated differently u4 will have no resource to be allocated.
This is only to explain the problem, I need to solve this for 200 users and 100 resources.
Can I seek your advise on which algorithm to use or how to solve this?
I often solve these type of assignment problems with an LP/MIP solver. The size is not too big so almost any solver will do and there are many readily available. It may look like a bit of overkill but in my experience it offers some useful flexibility (e.g. fixing some assignments, allowing additional ad-hoc constraints).
Your problem could be formulated as:
I solved the problem as an RMIP which is just an LP (the x variables are automatically integer for this type of problem).
In response to your question let me try to explain the equations.
First of all we need to note that the variables x(u,r) only assume the values 0 or 1. This is a property of linear assignment problems. The reason is not totally obvious but a good book on linear programming can tell you more.
The first equation assign1 says: we can assign each user to at most one resource. E.g. for user u1 we have: x(u1,r1)+x(u1,r2)+x(u1,r3) <= 1. This equation forbids that a user is assigned to two or more resources. We allow for unassigned users in case we are short of resources (e.g. if we have a dataset with 2 users and just 1 resource). As a user cannot be assigned to all resources, we do not sum over all r but only over the allowed combinations.
The second equation assign2 says: we can assign each resource to at most one user. E.g. for resource r1 we have: x(u1,r1)+x(u2,r1)+x(u3,r1) <= 1. This equation forbids that a resource is assigned to two or more users. We need this one also otherwise several different users could be assigned to the same resource. We allow for unassigned resources in case we are short of users (e.g. for the case where we have 2 resources and just 1 user). As a resource cannot be assigned to any user, we do not sum over all u but only over the allowed combinations.
Finally the objective counts how many valid assignments were made. This is the value we want to maximize. The trick is again to sum over the allowed combinations to prevent illegal assignments.
The model is a slight variation on the LP model described here. Much more information on the assignment problem can be found in this book.
For your little data set, here is the input data and the results:
I've written a simple assembler that allocates variable to registers. What I found to be most efficient to to do the hardest allocation first, then proceed to do the next hardest.
So in your case, you have a list of users who want an allocation. Since each user has a different rule for the allocation, you need to create a count for each of the available resources.
Then proceed as follows:
using the specific rules, count available resources
select the user with the minimum
in cases of ties, randomally select one
allocate the resource for the selected user
repeat
In this manner, you're giving priority to those users that are hardest to allocate for. But given the users and resources there may not be a solution so you may need to retry several times. If after N tries, no solution is found abort.

Do having multiple labels for a node in Neo4j make any sense?

Following this post from Neo4j's google group I have to say that I don't see any benefits when using this multiple-label-thing but rather, on the contrary, IMHO it just adds complexity for what a uniqueness constraint is. It could also tempt the user to introduce inheritance into the data model which would cause frustration since that's not possible at all...
Labels have not the notion of just representing a type, they are rather roles which are viable in different contexts.
So in one role, certain attributes and relationships of a node might matter and in another role (label) a different set (that might intersect with the first one).
We stayed away from inheritance as it opens a new can of worms, and we favor composition. So you'd rather compose a node whole as the sum of its parts. You can also mimic an inheritance by also attaching the "super"-types as labels to the child elements in your hierarchy.
Node labels can also be used to separate subgraphs in a larger graph, e.g. label the proteins that are active in human pathways and phylo pathways with those labels. So you can quickly select a part of the graph that you're interested in.
Those separate subgraphs can also come from different domains, like geo,social,catalogue,supplier that are combined in a single graph.
And multiple labels also make sense to separate "technical" namespaces of your graph that are used to represent "in-graph-indexes" from your "domain"-labels.
Regarding uniqueness - all uniqueness constraints for the existing labels and properties on your nodes are enforced at the same time. If they cannot be resolved on insert or update the operation will fail.