what does the term rep-invariant and rep ok means? [closed] - abstraction

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 years ago.
Improve this question
I heard this a lot when talking about software engineering and abstract data types, what does this do? Can anyone give me a concrete example of this concept?

A representation invariant is a condition concerning the state of an object. The condition can always be assumed to be true for a given object, and operations are required not to violate it.
In a Deck class, a representation invariant might be that there are always 52 Cards in the deck. A shuffle() operation is thus guaranteed not to drop any cards on the floor. Which in turn means that someone calling shuffle(), or indeed any other operation, does not need to check the number of cards before and after: they are guaranteed that it will always be 52.

Related

OpenCL conditional atomic functions [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 2 years ago.
Improve this question
Can atomic functions be placed inside if conditions or for loops in OpenCL. If possible can someone provide me with an example kernel?
Yes, they can.
There's no special lock-step requirement for atomic functions like there is for barriers.
It's common to reduce a group-wide result of a calculation, and then only one work-item from the group updates the global buffer with this sub-result.
if (get_local_id(0) == 0)
atomic_add(result_ptr, group_result);

Can you make a DFA/NFA/ Lambda NFA for determining whether a number is prime or not? [closed]

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 2 years ago.
Improve this question
As the title says, is it possible?
No, this isn’t possible. There are several ways you can encode “the set of all prime numbers” as a language, and the standard ways of doing so (writing the number out in binary, writing out a number of tally marks equal to the number, etc.) aren’t regular.
Formally proving this is a bit tricky but is doable using either the pumping lemma for regular languages or the Myhill-Nerode theorem. The crux of the arguments boil down to the fact that replicating parts of prime numbers repeatedly will eventually give you a non-prime number, and that’s where the technical details of the proofs come in.
Hope this helps!

Measurable indicator for usability [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 6 years ago.
Improve this question
I am starting a new project and I have the problem with the measurability of the requirement usability.
With is an good atomic measurable indicator for usability?
Number of klicks or keystrokes per action, weighted with the estimated relative frequency of the action.
However, this metric does not take into account a few important aspects of usability:
How easy it is to memorize the sequence of clicks and keystrokes
The amount of feedback provided to the user
The likelyhood of invalid inputs
Still it can be useful for comparing user interfaces that are similar with respect to these aspects.

Get Branch and Bound (BAB) tree structure [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 4 years ago.
Improve this question
I want to achieve the BAB tree structure like,
I am trying to use R, matlab and CPLEX, but cannot figure it out.
In C++ you could retrieve the Branch-and-Bound (B&B) information via a Callback. In simple terms, a callback is an instruction that is declared before optimisation to CPLEX and whenever the condition is met during the B&B, CPLEX will stop and enter the callback to execute your code.
As you can see this is exactly what you need, although most people use them to impose cuts or valid inequalities as a walkaround to avoid setting a priori an exponential number of constraints, and only add them on-the-go. Nothing stops you from declaring a very general condition that will be satisfied at every node of the tree, and then extract all the information you might need and construct the tree based on that info. You only have to go read CPLEX documentation to determine which is the more suitable callback depending on your problem and need.
One is glad to be of service

Can you provide a specific situation illustrating when a loop in R could be preferred to an apply function? [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
Can you please provide a specific situation illustrating when a for loop might work more effectively than the more commonly cited apply suite of solutions?
If the results of the previous computation are used in the next computation, it is appropriate to use a for loop, since this behavior is difficult to replicate with lapply (you would have to use something like Reduce). R is not necessarily slow with for loops, merely with memory allocation (which is easy to get wrong with for loops). See Chapter 2 of the R Inferno.

Resources