Alright, so if you look at my previous posts, you’ll see that we defined the initial building blocks of the SSC, we today we can start talking about some of the fun stuff. Today I’ll tell you how to write the SSC syntax of constraint net with some constraints. Don’t worry, soon we’ll actually have something you can play with, but like everything, gotta get the initial data in place first. For more details on that, check out the previous posts, they will help you catch up:
Variant Configuration – SSC Stand Alone Installation
Variant Configuration SSC – tricks to installing the local database
Variant Configuration SSC – using the Modeling Environment
Variant Configuration SSC – Syntax for Classification
Variant Configuration SSC – Syntax for Materials
Constraint Nets:
constraintNet SHELF_CNET {
name “Shelf Constraints”
constraints
AM_SHELF_RESTRICT_VALS,
AM_SHELVES_HOLD_BOOKS,
AM_RESTRICT_SHELF_DIM,
AM_CHECK_SIZE,
AM_GET_LOAD
}
You’ll notice, these are very simple. All they need is a name, a description and the list of constraints that it will include. Please note, we’ll talk about Rules at a later date, and the syntax is similar, but the key words are different.
Now for the real fun… Constraints.
First, here’s a nice easy one that just restricts the value set of a characteristic.
constraint AM_SHELF_RESTRICT_VALS {
name “Restrict Cstic Values”
objects:
?SH is_a (300)AM_SHELF
restrictions:
?SH.domain AM_THICKNESS in
(1.75, 2.50, 3.50)
inferences:
?SH.domain AM_THICKNESS
}
Now for me, the biggest change is the new keyword domain. I’m still used to the old school world of VC, it used to be just enter in the cstic and tell it what values are acceptable. In the SSC, you have to use the word domain to restrict the values (and you cstics still need to be restrictable). Notice though that all the other pieces are the same. Objects, restrictions & inferences (conditions are still available too).
Now, let’s step it up a level. This next example will use some ADT’s and give you a peak at how those look.
constraint AM_SHELVES_HOLD_BOOKS {
name “Shelf Holds Books”
objects:
?SH is_a (300)AM_SHELF,
?BK is_a (300)AM_BOOK
condition:
?BK.AM_IS_HELD_BY = ?SH
restrictions:
?SH.AM_HOLDS_BOOKS = ?BK
inferences:
?SH.AM_HOLDS_BOOKS
}
In this example, we are relating the Shelf to the Book. Notice that here we can start talking about the ?SH or ?BK as a whole, and even assign it to a characteristics. In the VC world, you would have to assign characteristics, but now we are talking about “instances”. In the SSC there is going to be a lot of talk about instances and instantiation. Back to the code… this rule says that if the book (?BK) is held by a shelf (AM_IS_HELD_BY is a characteristic with an ADT or Abstract Data Type). Then we want to set the shelf ?SH to show that it holds the book. The important thing to realize is that it’s not just any book, but it’s one specific book. Using the ADT characteristics hold the instance number of a particular book.
How about one more example?
constraint AM_RESTRICT_SHELF_DIM {
name “Restrict Shelf dims by books”
objects:
?SH is_a (300)AM_SHELF
restrictions:
?SH.domain AM_DEPTH >= ?SH.AM_HOLDS_BOOKS.AM_WIDTH,
?SH.domain AM_HEIGHT >= ?SH.AM_HOLDS_BOOKS.AM_HEIGHT,
?SH.domain AM_WIDTH >= ?SH.AM_WIDTH_TOTAL
inferences:
?SH.domain AM_DEPTH,
?SH.domain AM_HEIGHT,
?SH.domain AM_WIDTH
}
This constraint restricts the shelf dimensions based on the books that have been assigned. One other thing I didn’t mention before, AM_HOLDS_BOOKS is multiple value since a shelf can hold many books. The restrictions in this constraint show a new syntax (at least it’s new to me in the VC world). This is the ?SH.AM_HOLDS_BOOKS.AM_WIDTH. What this syntax say is that the shelf (?SH) has an ADT (AM_HOLDS_BOOKS) and we are looking at the specific characteristic of the Book. Now, since AM_HOLDS_BOOKS is multiple value, it is smart enough to look at all the books assigned to the shelf and check those values… pretty cool, huh?
There is a lot more stuff that can go into a constraint, and I’m sure I’ll talk more about it in the future… but this should give you a good place to start playing. I’m still excited about this SSC stuff… once you get past the hurdle of getting it installed, it really is pretty slick. Thanks for reading.
As always, thanks for reading and don't forget to check out our SAP Service Management Products at my other company JaveLLin Solutions,
Mike