0 - 1 code generation in cde remi lequette ilog. 0 - 2 overview introduction ilog & vcm cde cde...

24
0 - 1 Code Generation in CDE Remi Lequette ILOG

Upload: adolfo-sinclair

Post on 31-Mar-2015

222 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 1

Code Generationin CDE

Remi Lequette

ILOG

Page 2: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 2

Overview

Introduction ILOG & VCM CDE

CDE architecture Cartridge structure Generated artifacts

Generation technique The OPML language The UML model The generators

Conclusion

Page 3: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 3

ILOG

Provides Software Components C++ and Java class libraries Graphics, Rules Optimization: Linear, Constraints, Scheduling, Dispatching. Telecom, Transportation & Finance, VCM Provides consulting

VCM Division Value Chain Management (production & distribution planning) ISV customers (SAP, Oracle, …) ERP - SCM End User customers (in house development)

Page 4: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 4

CDE - Cartridge Development Env.

Target is ERP - SCM users They have data and an execution system They have an optimization problem Generic solution is not applicable

They buy a solution from ILOG consulting Consulting firm Third party reusable solution

CDE provides cartridges Reusable architecture Code, projects, documentation generation Data access (files, RDBMS, ERP system) Increase productivity by focus on optimization code

Page 5: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 5

ApplicationServer

Cartridge

AlgorithmControl

GUIData

Model

CDE Cartridge

Provides a standard architecture Provides a flexible integration framework Provides a toolbox for development

Architecture

Page 6: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 6

Detailed Architecture

Commands

InternalMapping

Data Model

AlgorithmControl

Tran

sform

ation

ExternalMapping

interface to external data sources

internal relational model mapping

high level entry points

internal object-oriented model

GUI, console, batch

optimization algorithm

Architecture

Page 7: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 7

Typical Data Flow

Commands

InternalMapping

Data Model

AlgorithmControl

Tran

sform

ation

ExternalMapping

7. solution saving

6. mapping & check

4. optimization

5. solution transformation

& check

Architecture

1. data loading

2. mapping & check

3. data transformation

& check

Page 8: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 8

Cartridge Generation

ECPIStructure Model TablesCommands

Commands

InternalMapping

Data Model

AlgorithmControl

Tran

sform

ation

ExternalMapping

Inte

grat

or

Devel

ope

r

Inte

grat

or

CDE/ILOG libraries

CDE specification

CDE code generation

customizable module

Architecture

Page 9: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 9

Generated Artifacts

Code Data model in C++ Script access to the data model Relational mapping

Documentation Classes, tables, commands

GUI Code and panels for testing the cartridge

Directories Project organization, test structure

Compilation projects For Microsoft Visual Studio

Page 10: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 10

Generation Technology

OPMLspecification

ModelImplementation

ScriptingInterface

Data Access

Cartridge

CDE Libraries

Templates

CDEGenerator

HTMLdocumentation

AlgorithmArchitecture

ILOG optimizationLibraries

Page 11: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 11

OPML

Cartridge Specification Language

Object Property Modeling Language (OPML) Based on UML concepts: classes, components, stereotypes... Textual language Specification of cartridge organization, data model (C++, script),

mappings, commands…

Advanced property management: Properties can be attached to model elements Property tool

Declares available properties for a tool: cpp, script, documentation... Property definition = name, types, default values, related elements...

Property instance holds property values for a given model

Page 12: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 12

// This is an internal comment

#include <ilcde/case/opml/opml.pty>#include <ilcde/datacon/ecpi/RelationalSchema.pty>#include <ilcde/datacon/ecpi/dbm.pty>

project christmas { cpp : Cpp; // C++ generation jscript : JScript; // scripting category classes {…} subsystem components {…}}

include of other OPML files

declares property instances

contains categories and subsystems

Project

Top level namespace Contains categories and subsystemsOPML

Page 13: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 13

project christmas { ... category christmas { cpp.generate = yes; visibility= private;

/** * HTML Documentation for Location */ class Location { ... } class Application : ilcde::Collector { visibility= protected; } ... }}

defines “christmas::Location” Class

super class

Categories and Classes

OPML

assigns a Cpp property for the category

assigns OPML property

Page 14: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 14

class Member { <<derived>> fullName : String; ...}

class Member { fullName : String { custom = true; readOnly = true; } ...}

<<table>> class EMPLOYEE { ...}

Stereotypes

Gives a specific semantic to an element

Used to set properties on OPML elements

OPML

Page 15: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 15

class Solution { name : String; <<static>> LastId : ID = "0";}class Member { birthDate : Date { before; }}class Location { role family : Family;}

Attributes and Roles

Attribute: primitive types and external classes Role: reference to one or more objects

OPML

Page 16: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 16

class Member { operation computeAge( today : Date ): Integer { const; } <<static>> operation DateToInteger( d1 : Date ) : Integer; <<virtual>> operation doIt();}class Family { operation addNewMember( name : String, birthDate : Date = “0”, info : String = “\”no info\”” ); ...}

parameter

Default value

return type

Operations

OPML

Page 17: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 17

project christmas { ...#include <ilcde/stdtypes.opml>

category christmas { cpp.generate = yes; collect; <<import>> depends : ilcde; class ID { id : String; } class Location { ... } } ...}

imports “ilcde” category

declares the “ilcde” category

Dependencies

Define relations between elements

OPML accessible string type

Page 18: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 18

project christmas { ... category christmas { ... } subsystem doccomp { <<documentation>> component ModelDoc { modelDoc.target = html; modelDoc.htmlHome="http://www.ilog.fr"; modelDoc.htmlHelp="help.html"; modelDoc.title="christmas related classes";

depends categories :christmas;

} }}

component that defines the documentation to be generated

selection of categories

Subsystems and Components

Component = logical or physical part Subsystem = group of components

OPML

Page 19: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 19

Script Language

ILOG Implementation of JavaScript Extended with access to C++ classes generated with CDE Interpreted language with “object-oriented” features

Used for Cartridge Development Test and Debug

Pros Flexible, fast development Clean binding of C++ Good language structure (scopes)

Cons No type checking Weak object-oriented model for pure script code

Page 20: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 20

The UML Model

Written in OPML Model generated with CDE Parser reads the OPML file and create model in

memory Provides powerful property access Script interface for writing generators

Page 21: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 21

Generators

Written in Script Control structure in script Generated areas with special comments (//@) A preprocessor adds the write statements

…//@class ${clazz.name} {if (clazz.hasConstructor() { //@ ${clazz.name}();}...

Page 22: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 22

Preserved Areas

…//beginPreserve beforeClass_MyClass Add user code here//endPreserve beforeClass_MyClassclass MyClass {...

…Generator.printPreserveArea(“beforeClass_”+clazz.name)//@class ${clazz.name} {...

Set by the generator The old file is read The content is preserved Note that new file is compared with old file

Page 23: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 23

Generation Framework

Written in Script A hierarchy of “Controllers” for structure mapping

OpmlController : Iterates on UML elements APIController: Generate operations to access the attributes CppController: Provides filtering for C++ Header and Code file generator

Tools for element mappings C++ name of a class C++ prototype for an operation

Page 24: 0 - 1 Code Generation in CDE Remi Lequette ILOG. 0 - 2 Overview Introduction ILOG & VCM CDE CDE architecture Cartridge structure Generated artifacts Generation

0 - 24

Conclusion

CDE Already used with good feedbacks Used within CDE (UML, libraries)

OPML Powerful modeling tool, easy to extend. Lack graphic interface.

Generators with Script Very flexible (no rigid structure) Easy to write a framework for reuse Lack compile-time checks Lack formal description