I want to change the service code of an object whenever there has been any service operated upon it. Suppose, I have a operation whenever that applies to an object, the service code of that object will be 1 and again when another operation executes then the service code will be 2. I want to save the latest service code to each object. Unfortunately, I am not able design my predicate well, that's why getting predicate inconsistent message from alloy.
I have tried some code for assigning service code to each object. The complete code shown below-
open util/ordering[Environment]
abstract sig Object{
name: String,
serviceCode: Int,
}{
serviceCode >= 0 and serviceCode <= 3
}
// Events
enum Event {Event1, Event2, Event3}
abstract sig Condition{
name: Event,
object: Object
}
abstract sig BaseOperation{
name: Event,
object: Object
// it will have more attributes than Condition later
}
abstract sig Connector{
condition: Condition,
baseOperation: BaseOperation,
}
sig Environment{
ev : set Event
}
pred execute [u:Environment, u':Environment, r:Connector] {
some e: u.ev | {
e = r.condition.name =>
u'.ev = u.ev + r.baseOperation.name
else
u'.ev = u.ev
}
}
fact {
all u:Environment-last, u':u.next, r:Connector {
execute [u, u', r]
}
}
sig Object1 extends Object{
}{
name = "Object1 Object"
}
sig Object2 extends Object{
}{
name = "Object2 Object"
}
sig Condition1 extends Condition{
}{
name = Event1
object = Object2
object.serviceCode = 1
}
sig Operation1 extends BaseOperation{
}{
name = Event2
object = Object1
object.serviceCode = 1
}
sig Operation2 extends BaseOperation{
}{
name = Event3
object = Object1
object.serviceCode = 0
}
one sig Connector1 extends Connector{
}{
condition = Condition1
baseOperation = Operation1
}
one sig Connector2 extends Connector{
}{
condition = Condition1
baseOperation = Operation2
}
fact {
Event3 !in first.ev &&
Event2 !in first.ev
}
run {Event1 in last.ev} for 10
The above code works fine when I have only one operation link to one object. I have attached the diagram for it here . Whenever there is more than one operation, then alloy fails to find an instance. Need help on designing alloy code for achieving my goal.
Another possible approach might be- instead of one service code, we may have a list of service code. Considering timestamp along with each service code. Then when need to find out the latest service code. We can take the service code of max timestamp. But I am not sure how to design this in alloy.