--- title: Modeling Quality 4 categories: demo toc: false ... Adding a link to Clafer Moo Visualizer. ```{.clafer .mooviz} ``` Defining quality attributes. * basic feature with `cost` and `mass`. ```clafer abstract Feature cost: integer mass: integer ``` * feature that impacts `comfort` ```clafer abstract ComfortFeature : Feature comfort: integer ``` * feature that impacts `fuel` consumption ```clafer abstract FuelFeature : ComfortFeature fuel: integer ``` Specifying individual contributions of features to quality and defining formulas for total variant quality. ```clafer abstract Car ABS : ComfortFeature ? [cost = 2] [mass = 1] [comfort = 1] xor Transmission : Feature [cost = 0] [mass = 0] Automatic : FuelFeature [fuel = 2] [mass = 1] [comfort = 2] [cost = 4] Manual : FuelFeature [fuel = 0] [mass = 1] [comfort = 1] [cost = 3] FCA : FuelFeature ? [fuel = 2] [mass = 2] [comfort = 4] [cost = 5] xor Sensor : Feature [cost = 0] [mass = 0] Radar : Feature [cost = 3] [mass = 1] Lidar : Feature [cost = 5] [mass = 1] xor Alert : Feature ? [cost = 0] [mass = 0] Haptic : ComfortFeature [comfort = 4] [cost = 2] [mass = 1] Audible : ComfortFeature [comfort = 2] [cost = 1] [mass = 1] CC : FuelFeature ? [fuel = 1] [mass = 1] [comfort = 3] [cost = 4] ACC : FuelFeature ? [fuel = 2] [mass = 2] [comfort = 6] [cost = 3] [ ACC => FCA] total_cost : integer = sum Feature.cost total_comfort : integer = sum ComfortFeature.cost total_fuel : integer = sum FuelFeature.cost total_mass : integer = sum FuelFeature.mass ``` Defining an optimal car `aCar` and its optimization goals. ```clafer aCar : Car << min aCar.total_cost >> << min aCar.total_fuel >> << max aCar.total_comfort >> << min aCar.total_mass >> ``` ```{.clafer .links} ``` > [Back to Intro](Intro)