Questions tagged [invariants]

In computer science, a predicate is called an invariant to a sequence of operations provided that: if the predicate is true before starting the sequence, then it is true at the end of the sequence.

In loops, invariants are data structures referenced within the loop that do not change during any iteration. In design-by-contract, invariants are invariants are properties of a class than must be satisfied at the end of any method call that is invoked from outside of the class itself.

References

199 questions
0
votes
1 answer

Always Valid Entities

I'm interested to see how supporters of the "Always-Valid" entity approach (vs isValid method later) would suggest modelling a object with collections. I really like the idea behind this approach, but I am having difficulty with implementing it as…
Milambardo
  • 300
  • 2
  • 12
0
votes
2 answers

OCL define invariant

If I have to define an invariant to state that the age of a person requesting a loan should be greater than 18 for the attached class diagram would this be context Person inv: age > 18 or context Person inv: self.age > 18 and what is the…
CompilerSaysNo
  • 325
  • 2
  • 11
0
votes
1 answer

Bad result on shape recognition using invariant moments

My project is shape recognition of leaf. I use Invariant Moments to feature extraction and City Block Distance to compute the distance between test image and image in database. Bust the result i get is very bad. I can say the recognition is only get…
gussurya_w
  • 83
  • 5
  • 14
0
votes
1 answer

how to omit program points in Daikon invariant detector?

I am using Daikon (likely program invariant detector) to generate invariants for a simple java class with different methods. I wanted to omit few methods from this class which I achieved through the following command: java daikon.Chicory…
Mian Asbat Ahmad
  • 2,594
  • 7
  • 36
  • 60
0
votes
1 answer

Domain Driven Design - Order of child of entites with respect to parent entity

I have two aggregates Parent and Child, say. A Parent can have many Childs (Children). A Child can only belong to one Parent. I need to keep track of a sort order of the Child entities so that when you get the Child entities for a Parent the list is…
0
votes
1 answer

Scala anonymous function genric variance issues

I'm on the road to learn Scala and I'm having a hard time understanding contravariants, covariants, invariance, etc. From Why doesn't the example compile, aka how does (co-, contra-, and in-) variance work? I have learned how functions can be…
Miles
  • 1
  • 1
0
votes
1 answer

Class invariants within code

I am wondering if there is a definitive procedure in determining invariant for a specific class or does it change on a case by case basis? Obviously it depends on certain variables and require statements but my question is, Is there some sort of…
Jim
  • 482
  • 1
  • 4
  • 20
0
votes
1 answer

Compilers Exam Explanation

I am preparing for a Compilers exam and I found the following two questions in past papers that I don't know how to answer: 1. Array bounds checking requires code to check each array subscript to ensure it falls within the array's declared range.…
Sorin Cioban
  • 2,169
  • 6
  • 28
  • 35
0
votes
0 answers

Code Contracts- Invariants are not rewritten

I am using VS2010 Ultimate with Code Contracts. After getting unexpected runtime behavior, I reviewed the source code in reflector and realized that my invariants are not being compiled. The generated __ContractsRuntime class only contains…
smartcaveman
  • 38,142
  • 26
  • 119
  • 203
0
votes
1 answer

OCL Requirement: Invariant for possible range of attribute values

So I have the following Object structure: Class Node RSSI: int I need to write a OCL invariant for the requirement that the the RSSI values of all Node objects do not differ by more than 2. I tried to solve it with an iterate expression but since…
gaussd
  • 874
  • 5
  • 15
  • 28
0
votes
1 answer

How to compute radon transform with invariant properties

I try to work the R transformation that, according with what is written in the scientific article "Recognition of Human Home Activities via Depth Silhouettes and R Transformation for Smart Homes", is computed in this way: where In Matlab I get…
Mario Lepore
  • 307
  • 1
  • 7
  • 17
0
votes
1 answer

OCL constraint using Ecore classifiers - Unknow type exception

I'm developing an Ecore model with some invariants defined in OCL, using the OCLinEcore editor. In my model, some elements have references to EClassifier; in some OCL constraints, I need to check if the EClassifier referred to is an EDataType or an…
Luc Touraille
  • 72,907
  • 15
  • 82
  • 134
0
votes
1 answer

Loops and Invariants?

I'm trying to swap the values of array b and to store a value in k so that the postcondition b [0...h] <= 9 and b[k+1..] > 9 is true. I have this so far: for ( int b = 0; k!= b.length; k = k+1 ) { int p = k+1; for ( int h= k+1; h !=…
-1
votes
1 answer

Run-Time complexities of the following functions

I need some help with these functions and if the run-time complexities for it are correct, I'm learning the concepts currently in class and I've looked at videos and such but I can't find any videos explaining these tougher ones, so I'm hoping I can…
-1
votes
1 answer

The name does not exist in the current context in invariant method

I am trying to use invariants(code contracts library) in my program inside a carpark class where all my methods are implemented but "The name does not exist in the current context" appears.The highlighted words appeared to make the problem. The…
user11001389
1 2 3
13
14