SlideShare une entreprise Scribd logo
1  sur  24
Data Modeling for Optimisation


                 The Database Connection in MPL
The database connection in MPL has the ability to access data from many
different sources, such as:
    •    Relational Databases
    •    Excel Spreadsheets
    •    External Text Files
    •    Internet
This gives the model developer the flexibility to choose the most efficient
and convenient way to incorporate the data into the model. Among the
data formats that are supported by MPL are:
    •    Microsoft Access and Excel
    •    ODBC
    •    FoxPro/DBase
    •    SQL Server
    •    Oracle
    •    SAP
                    Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                  1
Data Modeling for Optimisation


                  Import Indexes from Database
MPL allows you to import the elements for an index directly from a
database. In the INDEX section, where you define the index, enter the
keyword DATABASE after the assignment symbol (:=) followed by
parentheses containing the table name and the column/field name you
want to import from.
  INDEX
     depot := DATABASE("Depots","DepotID");


In the above example, MPL will open the database table Depots, locate
the column DepotID, and then read in the entries for the index depot.




                   Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                 2
Data Modeling for Optimisation


                    Import Indexes from Database
In most cases the imported indexes are the key fields for the table which
are underlined in the following examples:

          The Depots Table                  DepotID              Capacity

                                          Atlanta                400000
                                          Chicago                 50000
                                          New York                70000
                                          Dallas                 100000


The column name defaults to the name of the index so if it is the same you
do not have to specify it. In the example below the column name in the
database table is DepotID which is the same as the index DepotID.
 INDEX
     DepotID   := DATABASE("Depots");



                    Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                  3
Data Modeling for Optimisation


              Import Indexes from Database (Cont.)
MPL can import from more than one database in the same run. In the
example below, MPL will read in the factory index from Access, instead
of the default database:

  INDEX
    factory := DATABASE(Access, "Factory", "FactID");




                   Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                 4
Data Modeling for Optimisation

              Import Indexes from Database (Cont.)
MPL also allows you to import subset indexes from database tables.
  INDEX
      FactoryDepot[factory,depot] := DATABASE("FactDep");

This statement will open the database table FactDep and locate the
columns for factory and depot and then read in the entries for
FactoryDepot.
                               FactID           DepotID           TrCost         Shipment
 The FactDep Table:
                               Houston          Chicago           3200              0
                               Houston          Dallas            5100              0
                               Seattle          Atlanta           2800              0
                               Seattle          Chicago           6800              0
                               Seattle          New York          4700              0
                               Seattle          Dallas            5400              0



Notice that MPL automatically uses the same name as default for the
columns FactID and DepotID, as in the original tables the indexes were
defined from.
                   Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                            5
Data Modeling for Optimisation


                 Import Indexes from Database (Cont.)
If an index column does have a different name than in the original table, you
can specify it following the table name by first entering the index name followed
by an equal sign and the column name.
    INDEX
       FactoryDepot[factory,depot] :=
          DATABASE("FactDep", factory="Factory", depot="Depot");


This means if you are consistent in naming the columns in different tables you
do not have to specify them each time you refer to them in MPL.




                       Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                     6
Data Modeling for Optimisation

                     Import Data Vectors from Database
MPL allows you import the elements for a data vector directly from a database.
In the DATA section, where you define the data vector, enter the keyword
DATABASE after the assignment symbol (:=), followed by parentheses
containing the table name and the column/field name you want to import from.
  DATA
      FactDepCost[factory,depot] := DATABASE("FactDep", "TrCost");

In the above example, MPL will open the database table FactDep, locate the
columns TRCost, FactID, and DepotID, and then read in the entries for the data
vector FactDepCost.

   The FactDep Table:            FactID          DepotID          TrCost          Shipment
                                   Houston        Chicago        3200                 0
                                   Houston        Dallas         5100                 0
                                   Seattle        Atlanta        2800                 0
                                   Seattle        Chicago        6800                 0
                                   Seattle        New York       4700                 0
                                   Seattle        Dallas         5400                 0


                        Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                             7
Data Modeling for Optimisation


             Import Data Vectors from Database (Cont.)
If an index column does have a different name than in the original table,
you can specify it following the table name by first entering the index
name, followed by an equal sign and the column name.
   DATA
     FactDepCost[factory,depot] :=
        DATABASE("FactDep","TrCost",factory="Factory",depot="Depot");



The column name defaults to the name of the data vector, so if it is the
same you do not have to specify it.
  DATA
    TrCost    := DATABASE("FactDep");




                   Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                 8
Data Modeling for Optimisation


            Import Data Vectors from Database (Cont.)
MPL can import from more than one database in the same run. The
default database is specified in the Database Options dialog box in
the Options menu. If you need to import a data vector from table in a
database other than the default, you can do so by specifying the
database name before the name of the table.

In the example below, MPL will read in the data vector DepotCustCost
from Access instead of the default database.
  DATA
         DepotCustCost := DATABASE(Access, "DepCust", "TrCost");




                     Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                   9
Data Modeling for Optimisation


               Export Variable Values to Database
After optimizing the problem, MPL can export the variable values to the
database where it can be used to report the solution back to the user. In
the DECISION VARIABLES section, where you define the variable vector,
enter the keyword EXPORT TO after the defined variable, followed by the
keyword DATABASE and parentheses containing the table name and the
column/field name you want to export to.
   DECISION VARIABLES
      FactDepShip[factory,depot]
         EXPORT TO DATABASE("FactDep", "Shipment");

In the above example, MPL will open the database table FactDep, locate
the columns Shipment, FactID, and DepotID, and then export the solution
values for the variable vector FactDepShip.




                   Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                 10
Data Modeling for Optimisation


           Export Variable Values to Database (Cont.)
Here is an example of the FactDep table after the solution values have
been exported.
  The FactDep Table:

                   FactID            DepotID              TrCost         Shipment

                    Houston          Chicago              3200                   210
                    Houston          Dallas               5100                     0
                    Seattle          Atlanta              2800                   455
                    Seattle          Chicago              6800                     0
                    Seattle          New York             4700                   328
                    Seattle          Dallas               5400                   189


Notice that MPL automatically uses the same name as the default for the
index columns FactID and DepotID, as in the original tables the indexes
were defined from.


                   Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                       11
Data Modeling for Optimisation


                Export Variable Values to Database (Cont.)
MPL also allows you to export variable values other than the activity. You
can export the reduced costs, the upper and lower ranges for the objective
function, as well as the objective function coefficient values. You can change
which values will be exported by entering one of the following keywords directly
after the keyword EXPORT: Activity, ReducedCost, ObjectCoeff, ObjectLower,
ObjectUpper.

For example, if you want to export the reduced cost for a variable enter the
following:
   DECISION VARIABLES
       FactDepShip[factory,depot]
          EXPORT ReducedCost TO DATABASE("FactDep", "ReducedCost");

If you need to export more than one value for a variable vector you can do
so by entering multiple export statements after the variable definition.


                       Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                     12
Data Modeling for Optimisation


           Export Variable Values to Database (Cont.)
MPL offers three different options on how the database table is updated
by the EXPORT statement.
    • UPDATE, which is the default, searches through the database and for
      each record locates the corresponding value in the solver solution and
      updates the database entry with it. This option minimizes the changes
      done to the database table since only the existing values are updated,
      but can sometimes be slow especially on SQL type databases.
    • REFILL keyword right after the EXPORT keyword is used to specify
      that the whole database table should be emptied and then refilled with
      the entries from the solver solution. Since this takes out the necessity
      to search the table this can often lead to faster export times for larger
      tables.
    • CREATE keyword right after the EXPORT keyword is used to specify
      that the database table should be created and then filled with the
      entries from the solver solution. This option is mainly useful when
      exporting to the database table for the first time.

                    Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                  13
Data Modeling for Optimisation


               Export Constraint Values to Database
Just as exporting variable values, MPL can also export the constraint values
to the database. You will need to define constraint vectors in the
CONSTRAINTS section with the keyword EXPORT TO followed by the
keyword DATABASE and parentheses containing the table name and the
column/field name you want to export to.
    SUBJECT TO
       FactoryCapacity[factory]
          EXPORT ShadowPrice TO DATABASE("Factory", "ShadowPrice");


In the above example, MPL will open the database table Factory, locate the
columns FactID and ShadowPrice, and then export in the shadow price
values for the constraint FactoryCapacity.




                     Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                   14
Data Modeling for Optimisation

             Export Constraint Values to Database (Cont.)
Here is an example of the Factory table after the shadow price values have
been exported.
                              FactID          Capacity          ShadowPrice
                                                                     120.938
                             Houston            320000
                                                                           4
                             Seattle             73000
                                                                      0.0000

Notice that MPL automatically uses the same name as the default for the
index column FactID, as in the original tables the factory index was defined
from. If an index column does have a different name than in the original
table you can specify it by first entering the index name followed by an
equal sign and the column name.
 SUBJECT TO
    FactoryCapacity[factory]
      EXPORT ShadowPrice TO DATABASE("Factory", "ShadowPrice”, factory="Factory”);

This means, if you are consistent in naming the columns in different tables,
you do not have to specify them each time you refer to them in MPL.
                    Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                  15
Data Modeling for Optimisation

          Export Constraint Values to Database (Cont.)
In the example below, MPL will export the shadow price of the constraint
vector FactoryCapacity from FoxPro instead of the default database.
   SUBJECT TO
      FactoryCapacity[factory]
         EXPORT ShadowPrice TO DATABASE(FoxPro,"Factory","ShadowPrice");

MPL also allows you to export constraint values other than the shadow
price. You can export the slack values, the upper and lower ranges for the
right-hand-side as well as the right-hand-side values. You change which
values will be exported by entering one of the following keywords directly
after the keyword EXPORT: Activity, Slack, ShadowPrice, RhsValue,
RhsLower, RhsUpper. For example, if you want to export the slack for a
constraint enter the following:
   SUBJECT TO
      FactoryCapacity[factory]
           EXPORT Slack TO DATABASE("Factory","Slack");

If you need to export more than one value for a variable vector you can do
so by entering multiple export statements after the variable definition.
                     Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                   16
Data Modeling for Optimisation


               SpreadSheet Modeling in MPL

• Spreadsheet optimisation allows users to create models that are easy
  to use, enabling the user to quickly update the data and solve the
  model.


• Spreadsheets are efficient at handling and managing 2-Dimensional
  dense data and single scalar values.




                 Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                               17
Data Modeling for Optimisation


                      Import Indexes from Excel
MPL allows you to import the elements for an index directly from an
EXCELRANGE. In the INDEX section, where you define the index, enter
the keyword EXCELRANGE after the assignment symbol (:=) followed by
parentheses containing the table name and the column/field name you
want to import from.
  INDEX
     depot   := EXCELRANGE("Depots");

In the above example, MPL will read in the entries for the index depot from
the Excel range called Depots.




                   Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                 18
Data Modeling for Optimisation

                   Import Data Vectors from Excel
MPL allows you import the elements for a data vector directly from EXCEL.
One can read in data in tabular format using the keyword EXCELRANGE or
in sparse format using the keyword EXCELSPARSE, below is an example of
how to import a data vector from EXCEL.
   DATA
      FactDepCost[factory,depot] := EXCELSPARSE("FactDep", "3");

In the above example, MPL will read in the data vector FactDepCost from the
range called FactDep, as we have specified the data is in sparse format it will
take the first column to be entries for the Factory index, the second column to
be entries for the Depot index and 3 specifies the value of the data parameter
to be taken from the third column.

   The FactDep Table:             FactID        DepotID          TrCost       Shipment

                               Houston         Chicago          3200              0
                               Houston         Dallas           5100              0
                               Seattle         Atlanta          2800              0
                               Seattle         New York         4700              0
                               Seattle         Dallas           5400              0

                    Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                         19
Data Modeling for Optimisation


                  Export Variable Values to Excel
After optimizing the problem, MPL can export the variable values to the
EXCEL where it can be used to report the solution back to the user. In the
DECISION VARIABLES section, where you define the variable vector,
enter the keyword EXPORT TO after the defined variable, followed by the
keyword EXCELRANGE/ EXCELSPARSE and parentheses containing the
range name and the column number if you are using EXCELSPARSE.
  DECISION VARIABLES
       FactDepShip[factory,depot]
              EXPORT TO EXCELRANGE("Shipping");

In the above example, MPL will export the solution values for the variable
vector FactDepShip to the range called Shipping.




                    Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                  20
Data Modeling for Optimisation


                   Sparse Data vs. Dense Data
• Dense Data
   • Standard representation in row and column format
   • Row and column format preferably when data is highly dense,
     containing none or low percentage of null or zero values
   • Can be difficult to deal with for large data sets.
• Sparse Data
   • Includes only non zero values
   • Highly efficient representation if small percentage of the values
     are nonzero
   • Efficient. Generating and Solving models




                   Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                 21
Data Modelling for Optimisation


                Sparse and Dense Data Examples
Dense Data
In the following example shows the datavector Shipcost. The parameter is
indexed over 4 plants, 2 warehouses and 3 products.
   ShipCost[plant, warehouse, product] := [
                  ! p1 p2 p3
   {pl1}            70, 52, 48, !w1
                    65, 40, 74, !w2

   {pl2}           79, 52, 65,              !w1
                   75, 50, 53,              !w2

   {pl3}           47, 52, 51,              !w1
                   78, 52, 52,              !w2

   {pl4}           75, 80, 50, !w1
                   90, 52, 10]; !w2




                   Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                 22
Data Modelling for Optimisation


                  Sparse and Dense Data Examples
Sparse Data
The first entry of each row specifies the first index. In our example this
means plant, the second and third entries refers to the machine and
product indexes and the fourth to the actual data value for ProdCost.
   ProdCost[plant, machine, product] := [

         p1,   m11,   A1,    73.30,
         p1,   m11,   A2,    52.90,
         p1,   m12,   A3,    65.40,
         p1,   m13,   A3,    47.60,

         p2,   m21,   A1,    79.00,
         p2,   m21,   A3,    66.80,
         p2,   m22,   A2,    52.00,

         p3,   m31,   A1,    75.80,
         p3,   m31,   A3,    50.90,
         p3,   m32,   A1,    79.90,
         p3,   m32,   A2,    52.10,

         p4,   m41,   A1,    82.70,
         p4,   m41,   A2,    63.30,
         p4,   m41,   A3,    53.80];

                      Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                    23
Data Modelling for Optimisation

                Text vs. Database vs. Spreadsheet

Data can be read in at different speeds depending on the data source.
    • Text Files - Are compact and simple and by far the quickest way
      to read in data.
    • Databases - Are built for data management pretty quick to import
      and export data.
    • Spreadsheets - Not designed to handle or manage large data sets,
      inefficient in importing data and is the slowest method to read in
      and export data.




                   Copyright © 2012 Maximal Software, Inc. All rights reserved
                                                                                 24

Contenu connexe

Tendances

Graph db as metastore
Graph db as metastoreGraph db as metastore
Graph db as metastoreHaris Khan
 
Vb.net session 05
Vb.net session 05Vb.net session 05
Vb.net session 05Niit Care
 
Introduction to ADO.NET
Introduction to ADO.NETIntroduction to ADO.NET
Introduction to ADO.NETrchakra
 
07 necto data_sources_ready
07 necto data_sources_ready07 necto data_sources_ready
07 necto data_sources_readywww.panorama.com
 
Visual Basic.Net & Ado.Net
Visual Basic.Net & Ado.NetVisual Basic.Net & Ado.Net
Visual Basic.Net & Ado.NetFaRid Adwa
 
Build a Big Data solution using DB2 for z/OS
Build a Big Data solution using DB2 for z/OSBuild a Big Data solution using DB2 for z/OS
Build a Big Data solution using DB2 for z/OSJane Man
 
Intake 38 data access 1
Intake 38 data access 1Intake 38 data access 1
Intake 38 data access 1Mahmoud Ouf
 
For Beginners - Ado.net
For Beginners - Ado.netFor Beginners - Ado.net
For Beginners - Ado.netTarun Jain
 
Chapter 3: ado.net
Chapter 3: ado.netChapter 3: ado.net
Chapter 3: ado.netNgeam Soly
 

Tendances (20)

Graph db as metastore
Graph db as metastoreGraph db as metastore
Graph db as metastore
 
Vb.net session 05
Vb.net session 05Vb.net session 05
Vb.net session 05
 
Introduction to ADO.NET
Introduction to ADO.NETIntroduction to ADO.NET
Introduction to ADO.NET
 
ADO.NET
ADO.NETADO.NET
ADO.NET
 
Sq lite module7
Sq lite module7Sq lite module7
Sq lite module7
 
07 necto data_sources_ready
07 necto data_sources_ready07 necto data_sources_ready
07 necto data_sources_ready
 
Intake 38 10
Intake 38 10Intake 38 10
Intake 38 10
 
Visual Basic.Net & Ado.Net
Visual Basic.Net & Ado.NetVisual Basic.Net & Ado.Net
Visual Basic.Net & Ado.Net
 
Sq lite module2
Sq lite module2Sq lite module2
Sq lite module2
 
Ado.Net Tutorial
Ado.Net TutorialAdo.Net Tutorial
Ado.Net Tutorial
 
Build a Big Data solution using DB2 for z/OS
Build a Big Data solution using DB2 for z/OSBuild a Big Data solution using DB2 for z/OS
Build a Big Data solution using DB2 for z/OS
 
ADO.NET by ASP.NET Development Company in india
ADO.NET by ASP.NET  Development Company in indiaADO.NET by ASP.NET  Development Company in india
ADO.NET by ASP.NET Development Company in india
 
Ado.net
Ado.netAdo.net
Ado.net
 
ADO .Net
ADO .Net ADO .Net
ADO .Net
 
Chap14 ado.net
Chap14 ado.netChap14 ado.net
Chap14 ado.net
 
Intake 38 data access 1
Intake 38 data access 1Intake 38 data access 1
Intake 38 data access 1
 
Sql ch 4
Sql ch 4Sql ch 4
Sql ch 4
 
Sq lite module4
Sq lite module4Sq lite module4
Sq lite module4
 
For Beginners - Ado.net
For Beginners - Ado.netFor Beginners - Ado.net
For Beginners - Ado.net
 
Chapter 3: ado.net
Chapter 3: ado.netChapter 3: ado.net
Chapter 3: ado.net
 

En vedette

Seminar: New Pricing Programs and Free Software Offers by Maximal - Oct 2012
Seminar: New Pricing Programs and Free Software Offers by Maximal - Oct 2012Seminar: New Pricing Programs and Free Software Offers by Maximal - Oct 2012
Seminar: New Pricing Programs and Free Software Offers by Maximal - Oct 2012Bjarni Kristjánsson
 
Project delta hotel atlantis
Project delta hotel atlantisProject delta hotel atlantis
Project delta hotel atlantisEric Ververs
 
Projectpresentatie Quos 100% Maatwerk
Projectpresentatie Quos 100% MaatwerkProjectpresentatie Quos 100% Maatwerk
Projectpresentatie Quos 100% MaatwerkEric Ververs
 
Audi casestudy jameskalbach (1)
Audi casestudy jameskalbach (1)Audi casestudy jameskalbach (1)
Audi casestudy jameskalbach (1)pratish menon
 

En vedette (6)

Global Team Business
Global Team BusinessGlobal Team Business
Global Team Business
 
Seminar: New Pricing Programs and Free Software Offers by Maximal - Oct 2012
Seminar: New Pricing Programs and Free Software Offers by Maximal - Oct 2012Seminar: New Pricing Programs and Free Software Offers by Maximal - Oct 2012
Seminar: New Pricing Programs and Free Software Offers by Maximal - Oct 2012
 
Project delta hotel atlantis
Project delta hotel atlantisProject delta hotel atlantis
Project delta hotel atlantis
 
Projectpresentatie Quos 100% Maatwerk
Projectpresentatie Quos 100% MaatwerkProjectpresentatie Quos 100% Maatwerk
Projectpresentatie Quos 100% Maatwerk
 
Audi casestudy jameskalbach (1)
Audi casestudy jameskalbach (1)Audi casestudy jameskalbach (1)
Audi casestudy jameskalbach (1)
 
Safety door designs
Safety door designsSafety door designs
Safety door designs
 

Similaire à Seminar: Data Modeling for Optimization with MPL - Oct 2012

Disconnected Architecture and Crystal report in VB.NET
Disconnected Architecture and Crystal report in VB.NETDisconnected Architecture and Crystal report in VB.NET
Disconnected Architecture and Crystal report in VB.NETEverywhere
 
Oracle data integrator project
Oracle data integrator projectOracle data integrator project
Oracle data integrator projectAmit Sharma
 
Ado.net session07
Ado.net session07Ado.net session07
Ado.net session07Niit Care
 
Spark Sql and DataFrame
Spark Sql and DataFrameSpark Sql and DataFrame
Spark Sql and DataFramePrashant Gupta
 
Jdbc Dao it-slideshares.blogspot.com
Jdbc Dao it-slideshares.blogspot.comJdbc Dao it-slideshares.blogspot.com
Jdbc Dao it-slideshares.blogspot.comphanleson
 
BI Publisher Data model design document
BI Publisher Data model design documentBI Publisher Data model design document
BI Publisher Data model design documentadivasoft
 
BI Publisher 11g : Data Model Design document
BI Publisher 11g : Data Model Design documentBI Publisher 11g : Data Model Design document
BI Publisher 11g : Data Model Design documentadivasoft
 
Data Warehouse and Business Intelligence - Recipe 2
Data Warehouse and Business Intelligence - Recipe 2Data Warehouse and Business Intelligence - Recipe 2
Data Warehouse and Business Intelligence - Recipe 2Massimo Cenci
 
PBDJ 19-4(woolley rev)
PBDJ 19-4(woolley rev)PBDJ 19-4(woolley rev)
PBDJ 19-4(woolley rev)Buck Woolley
 
Advanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsAdvanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsDave Stokes
 
Intake 38 data access 5
Intake 38 data access 5Intake 38 data access 5
Intake 38 data access 5Mahmoud Ouf
 
ASP.NET 08 - Data Binding And Representation
ASP.NET 08 - Data Binding And RepresentationASP.NET 08 - Data Binding And Representation
ASP.NET 08 - Data Binding And RepresentationRandy Connolly
 
Database Architecture and Basic Concepts
Database Architecture and Basic ConceptsDatabase Architecture and Basic Concepts
Database Architecture and Basic ConceptsTony Wong
 
Bt0082 visual basic2
Bt0082 visual basic2Bt0082 visual basic2
Bt0082 visual basic2Techglyphs
 

Similaire à Seminar: Data Modeling for Optimization with MPL - Oct 2012 (20)

Disconnected Architecture and Crystal report in VB.NET
Disconnected Architecture and Crystal report in VB.NETDisconnected Architecture and Crystal report in VB.NET
Disconnected Architecture and Crystal report in VB.NET
 
Oracle data integrator project
Oracle data integrator projectOracle data integrator project
Oracle data integrator project
 
Ado.net session07
Ado.net session07Ado.net session07
Ado.net session07
 
Spark Sql and DataFrame
Spark Sql and DataFrameSpark Sql and DataFrame
Spark Sql and DataFrame
 
MYSQL.ppt
MYSQL.pptMYSQL.ppt
MYSQL.ppt
 
Jdbc Dao it-slideshares.blogspot.com
Jdbc Dao it-slideshares.blogspot.comJdbc Dao it-slideshares.blogspot.com
Jdbc Dao it-slideshares.blogspot.com
 
BI Publisher Data model design document
BI Publisher Data model design documentBI Publisher Data model design document
BI Publisher Data model design document
 
BI Publisher 11g : Data Model Design document
BI Publisher 11g : Data Model Design documentBI Publisher 11g : Data Model Design document
BI Publisher 11g : Data Model Design document
 
Sql basics
Sql  basicsSql  basics
Sql basics
 
Data Warehouse and Business Intelligence - Recipe 2
Data Warehouse and Business Intelligence - Recipe 2Data Warehouse and Business Intelligence - Recipe 2
Data Warehouse and Business Intelligence - Recipe 2
 
PBDJ 19-4(woolley rev)
PBDJ 19-4(woolley rev)PBDJ 19-4(woolley rev)
PBDJ 19-4(woolley rev)
 
Advanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsAdvanced MySQL Query Optimizations
Advanced MySQL Query Optimizations
 
Intake 38 data access 5
Intake 38 data access 5Intake 38 data access 5
Intake 38 data access 5
 
Ado .net
Ado .netAdo .net
Ado .net
 
ASP.NET 08 - Data Binding And Representation
ASP.NET 08 - Data Binding And RepresentationASP.NET 08 - Data Binding And Representation
ASP.NET 08 - Data Binding And Representation
 
Informatica session
Informatica sessionInformatica session
Informatica session
 
Dancing with the Elephant
Dancing with the ElephantDancing with the Elephant
Dancing with the Elephant
 
Intake 37 linq3
Intake 37 linq3Intake 37 linq3
Intake 37 linq3
 
Database Architecture and Basic Concepts
Database Architecture and Basic ConceptsDatabase Architecture and Basic Concepts
Database Architecture and Basic Concepts
 
Bt0082 visual basic2
Bt0082 visual basic2Bt0082 visual basic2
Bt0082 visual basic2
 

Plus de Bjarni Kristjánsson

New Release 5.0 of MPL and OptiMax Library - OR Vienna 2015
New Release 5.0 of MPL and OptiMax Library - OR Vienna 2015New Release 5.0 of MPL and OptiMax Library - OR Vienna 2015
New Release 5.0 of MPL and OptiMax Library - OR Vienna 2015Bjarni Kristjánsson
 
Maximal: Achieving Optimal Solution Performance for your Optimization Modelin...
Maximal: Achieving Optimal Solution Performance for your Optimization Modelin...Maximal: Achieving Optimal Solution Performance for your Optimization Modelin...
Maximal: Achieving Optimal Solution Performance for your Optimization Modelin...Bjarni Kristjánsson
 
Maximal: Deploying Optimization Models on Servers and Mobile Platforms - Oct ...
Maximal: Deploying Optimization Models on Servers and Mobile Platforms - Oct ...Maximal: Deploying Optimization Models on Servers and Mobile Platforms - Oct ...
Maximal: Deploying Optimization Models on Servers and Mobile Platforms - Oct ...Bjarni Kristjánsson
 
Maximal: Comparison of Optimization Modeling Software for Python - Oct 2012
Maximal: Comparison of Optimization Modeling Software for Python - Oct 2012Maximal: Comparison of Optimization Modeling Software for Python - Oct 2012
Maximal: Comparison of Optimization Modeling Software for Python - Oct 2012Bjarni Kristjánsson
 
Maximal: MPL Software Demo - INFORMS Phoenix Oct 2012
Maximal: MPL Software Demo - INFORMS Phoenix Oct 2012Maximal: MPL Software Demo - INFORMS Phoenix Oct 2012
Maximal: MPL Software Demo - INFORMS Phoenix Oct 2012Bjarni Kristjánsson
 
Seminar: New Stochastic Programming Features for MPL - Nov 2011
Seminar: New Stochastic Programming Features for MPL - Nov 2011Seminar: New Stochastic Programming Features for MPL - Nov 2011
Seminar: New Stochastic Programming Features for MPL - Nov 2011Bjarni Kristjánsson
 
Seminar: CoinMP - Open Source Solver - Nov 2011
Seminar: CoinMP - Open Source Solver - Nov 2011Seminar: CoinMP - Open Source Solver - Nov 2011
Seminar: CoinMP - Open Source Solver - Nov 2011Bjarni Kristjánsson
 
Seminar: Embedding Optimization in Applications with MPL OptiMax - April 2012
Seminar: Embedding Optimization in Applications with MPL OptiMax - April 2012Seminar: Embedding Optimization in Applications with MPL OptiMax - April 2012
Seminar: Embedding Optimization in Applications with MPL OptiMax - April 2012Bjarni Kristjánsson
 
Seminar: Introduction to Maximal Software and the MPL Modeling System - Oct 2012
Seminar: Introduction to Maximal Software and the MPL Modeling System - Oct 2012Seminar: Introduction to Maximal Software and the MPL Modeling System - Oct 2012
Seminar: Introduction to Maximal Software and the MPL Modeling System - Oct 2012Bjarni Kristjánsson
 
OR Connect: A New Web 2.0 Online Initiative for O.R. - INFORMS Jan 2011
OR Connect: A New Web 2.0 Online Initiative for O.R. - INFORMS Jan 2011OR Connect: A New Web 2.0 Online Initiative for O.R. - INFORMS Jan 2011
OR Connect: A New Web 2.0 Online Initiative for O.R. - INFORMS Jan 2011Bjarni Kristjánsson
 
INFORMS: IT Board Report - April 2011
INFORMS: IT Board Report - April 2011INFORMS: IT Board Report - April 2011
INFORMS: IT Board Report - April 2011Bjarni Kristjánsson
 
INFORMS: IT Committee Report - August 2011
INFORMS: IT Committee Report - August 2011INFORMS: IT Committee Report - August 2011
INFORMS: IT Committee Report - August 2011Bjarni Kristjánsson
 

Plus de Bjarni Kristjánsson (12)

New Release 5.0 of MPL and OptiMax Library - OR Vienna 2015
New Release 5.0 of MPL and OptiMax Library - OR Vienna 2015New Release 5.0 of MPL and OptiMax Library - OR Vienna 2015
New Release 5.0 of MPL and OptiMax Library - OR Vienna 2015
 
Maximal: Achieving Optimal Solution Performance for your Optimization Modelin...
Maximal: Achieving Optimal Solution Performance for your Optimization Modelin...Maximal: Achieving Optimal Solution Performance for your Optimization Modelin...
Maximal: Achieving Optimal Solution Performance for your Optimization Modelin...
 
Maximal: Deploying Optimization Models on Servers and Mobile Platforms - Oct ...
Maximal: Deploying Optimization Models on Servers and Mobile Platforms - Oct ...Maximal: Deploying Optimization Models on Servers and Mobile Platforms - Oct ...
Maximal: Deploying Optimization Models on Servers and Mobile Platforms - Oct ...
 
Maximal: Comparison of Optimization Modeling Software for Python - Oct 2012
Maximal: Comparison of Optimization Modeling Software for Python - Oct 2012Maximal: Comparison of Optimization Modeling Software for Python - Oct 2012
Maximal: Comparison of Optimization Modeling Software for Python - Oct 2012
 
Maximal: MPL Software Demo - INFORMS Phoenix Oct 2012
Maximal: MPL Software Demo - INFORMS Phoenix Oct 2012Maximal: MPL Software Demo - INFORMS Phoenix Oct 2012
Maximal: MPL Software Demo - INFORMS Phoenix Oct 2012
 
Seminar: New Stochastic Programming Features for MPL - Nov 2011
Seminar: New Stochastic Programming Features for MPL - Nov 2011Seminar: New Stochastic Programming Features for MPL - Nov 2011
Seminar: New Stochastic Programming Features for MPL - Nov 2011
 
Seminar: CoinMP - Open Source Solver - Nov 2011
Seminar: CoinMP - Open Source Solver - Nov 2011Seminar: CoinMP - Open Source Solver - Nov 2011
Seminar: CoinMP - Open Source Solver - Nov 2011
 
Seminar: Embedding Optimization in Applications with MPL OptiMax - April 2012
Seminar: Embedding Optimization in Applications with MPL OptiMax - April 2012Seminar: Embedding Optimization in Applications with MPL OptiMax - April 2012
Seminar: Embedding Optimization in Applications with MPL OptiMax - April 2012
 
Seminar: Introduction to Maximal Software and the MPL Modeling System - Oct 2012
Seminar: Introduction to Maximal Software and the MPL Modeling System - Oct 2012Seminar: Introduction to Maximal Software and the MPL Modeling System - Oct 2012
Seminar: Introduction to Maximal Software and the MPL Modeling System - Oct 2012
 
OR Connect: A New Web 2.0 Online Initiative for O.R. - INFORMS Jan 2011
OR Connect: A New Web 2.0 Online Initiative for O.R. - INFORMS Jan 2011OR Connect: A New Web 2.0 Online Initiative for O.R. - INFORMS Jan 2011
OR Connect: A New Web 2.0 Online Initiative for O.R. - INFORMS Jan 2011
 
INFORMS: IT Board Report - April 2011
INFORMS: IT Board Report - April 2011INFORMS: IT Board Report - April 2011
INFORMS: IT Board Report - April 2011
 
INFORMS: IT Committee Report - August 2011
INFORMS: IT Committee Report - August 2011INFORMS: IT Committee Report - August 2011
INFORMS: IT Committee Report - August 2011
 

Seminar: Data Modeling for Optimization with MPL - Oct 2012

  • 1. Data Modeling for Optimisation The Database Connection in MPL The database connection in MPL has the ability to access data from many different sources, such as: • Relational Databases • Excel Spreadsheets • External Text Files • Internet This gives the model developer the flexibility to choose the most efficient and convenient way to incorporate the data into the model. Among the data formats that are supported by MPL are: • Microsoft Access and Excel • ODBC • FoxPro/DBase • SQL Server • Oracle • SAP Copyright © 2012 Maximal Software, Inc. All rights reserved 1
  • 2. Data Modeling for Optimisation Import Indexes from Database MPL allows you to import the elements for an index directly from a database. In the INDEX section, where you define the index, enter the keyword DATABASE after the assignment symbol (:=) followed by parentheses containing the table name and the column/field name you want to import from. INDEX depot := DATABASE("Depots","DepotID"); In the above example, MPL will open the database table Depots, locate the column DepotID, and then read in the entries for the index depot. Copyright © 2012 Maximal Software, Inc. All rights reserved 2
  • 3. Data Modeling for Optimisation Import Indexes from Database In most cases the imported indexes are the key fields for the table which are underlined in the following examples: The Depots Table DepotID Capacity Atlanta 400000 Chicago 50000 New York 70000 Dallas 100000 The column name defaults to the name of the index so if it is the same you do not have to specify it. In the example below the column name in the database table is DepotID which is the same as the index DepotID. INDEX DepotID := DATABASE("Depots"); Copyright © 2012 Maximal Software, Inc. All rights reserved 3
  • 4. Data Modeling for Optimisation Import Indexes from Database (Cont.) MPL can import from more than one database in the same run. In the example below, MPL will read in the factory index from Access, instead of the default database: INDEX factory := DATABASE(Access, "Factory", "FactID"); Copyright © 2012 Maximal Software, Inc. All rights reserved 4
  • 5. Data Modeling for Optimisation Import Indexes from Database (Cont.) MPL also allows you to import subset indexes from database tables. INDEX FactoryDepot[factory,depot] := DATABASE("FactDep"); This statement will open the database table FactDep and locate the columns for factory and depot and then read in the entries for FactoryDepot. FactID DepotID TrCost Shipment The FactDep Table: Houston Chicago 3200 0 Houston Dallas 5100 0 Seattle Atlanta 2800 0 Seattle Chicago 6800 0 Seattle New York 4700 0 Seattle Dallas 5400 0 Notice that MPL automatically uses the same name as default for the columns FactID and DepotID, as in the original tables the indexes were defined from. Copyright © 2012 Maximal Software, Inc. All rights reserved 5
  • 6. Data Modeling for Optimisation Import Indexes from Database (Cont.) If an index column does have a different name than in the original table, you can specify it following the table name by first entering the index name followed by an equal sign and the column name. INDEX FactoryDepot[factory,depot] := DATABASE("FactDep", factory="Factory", depot="Depot"); This means if you are consistent in naming the columns in different tables you do not have to specify them each time you refer to them in MPL. Copyright © 2012 Maximal Software, Inc. All rights reserved 6
  • 7. Data Modeling for Optimisation Import Data Vectors from Database MPL allows you import the elements for a data vector directly from a database. In the DATA section, where you define the data vector, enter the keyword DATABASE after the assignment symbol (:=), followed by parentheses containing the table name and the column/field name you want to import from. DATA FactDepCost[factory,depot] := DATABASE("FactDep", "TrCost"); In the above example, MPL will open the database table FactDep, locate the columns TRCost, FactID, and DepotID, and then read in the entries for the data vector FactDepCost. The FactDep Table: FactID DepotID TrCost Shipment Houston Chicago 3200 0 Houston Dallas 5100 0 Seattle Atlanta 2800 0 Seattle Chicago 6800 0 Seattle New York 4700 0 Seattle Dallas 5400 0 Copyright © 2012 Maximal Software, Inc. All rights reserved 7
  • 8. Data Modeling for Optimisation Import Data Vectors from Database (Cont.) If an index column does have a different name than in the original table, you can specify it following the table name by first entering the index name, followed by an equal sign and the column name. DATA FactDepCost[factory,depot] := DATABASE("FactDep","TrCost",factory="Factory",depot="Depot"); The column name defaults to the name of the data vector, so if it is the same you do not have to specify it. DATA TrCost := DATABASE("FactDep"); Copyright © 2012 Maximal Software, Inc. All rights reserved 8
  • 9. Data Modeling for Optimisation Import Data Vectors from Database (Cont.) MPL can import from more than one database in the same run. The default database is specified in the Database Options dialog box in the Options menu. If you need to import a data vector from table in a database other than the default, you can do so by specifying the database name before the name of the table. In the example below, MPL will read in the data vector DepotCustCost from Access instead of the default database. DATA DepotCustCost := DATABASE(Access, "DepCust", "TrCost"); Copyright © 2012 Maximal Software, Inc. All rights reserved 9
  • 10. Data Modeling for Optimisation Export Variable Values to Database After optimizing the problem, MPL can export the variable values to the database where it can be used to report the solution back to the user. In the DECISION VARIABLES section, where you define the variable vector, enter the keyword EXPORT TO after the defined variable, followed by the keyword DATABASE and parentheses containing the table name and the column/field name you want to export to. DECISION VARIABLES FactDepShip[factory,depot] EXPORT TO DATABASE("FactDep", "Shipment"); In the above example, MPL will open the database table FactDep, locate the columns Shipment, FactID, and DepotID, and then export the solution values for the variable vector FactDepShip. Copyright © 2012 Maximal Software, Inc. All rights reserved 10
  • 11. Data Modeling for Optimisation Export Variable Values to Database (Cont.) Here is an example of the FactDep table after the solution values have been exported. The FactDep Table: FactID DepotID TrCost Shipment Houston Chicago 3200 210 Houston Dallas 5100 0 Seattle Atlanta 2800 455 Seattle Chicago 6800 0 Seattle New York 4700 328 Seattle Dallas 5400 189 Notice that MPL automatically uses the same name as the default for the index columns FactID and DepotID, as in the original tables the indexes were defined from. Copyright © 2012 Maximal Software, Inc. All rights reserved 11
  • 12. Data Modeling for Optimisation Export Variable Values to Database (Cont.) MPL also allows you to export variable values other than the activity. You can export the reduced costs, the upper and lower ranges for the objective function, as well as the objective function coefficient values. You can change which values will be exported by entering one of the following keywords directly after the keyword EXPORT: Activity, ReducedCost, ObjectCoeff, ObjectLower, ObjectUpper. For example, if you want to export the reduced cost for a variable enter the following: DECISION VARIABLES FactDepShip[factory,depot] EXPORT ReducedCost TO DATABASE("FactDep", "ReducedCost"); If you need to export more than one value for a variable vector you can do so by entering multiple export statements after the variable definition. Copyright © 2012 Maximal Software, Inc. All rights reserved 12
  • 13. Data Modeling for Optimisation Export Variable Values to Database (Cont.) MPL offers three different options on how the database table is updated by the EXPORT statement. • UPDATE, which is the default, searches through the database and for each record locates the corresponding value in the solver solution and updates the database entry with it. This option minimizes the changes done to the database table since only the existing values are updated, but can sometimes be slow especially on SQL type databases. • REFILL keyword right after the EXPORT keyword is used to specify that the whole database table should be emptied and then refilled with the entries from the solver solution. Since this takes out the necessity to search the table this can often lead to faster export times for larger tables. • CREATE keyword right after the EXPORT keyword is used to specify that the database table should be created and then filled with the entries from the solver solution. This option is mainly useful when exporting to the database table for the first time. Copyright © 2012 Maximal Software, Inc. All rights reserved 13
  • 14. Data Modeling for Optimisation Export Constraint Values to Database Just as exporting variable values, MPL can also export the constraint values to the database. You will need to define constraint vectors in the CONSTRAINTS section with the keyword EXPORT TO followed by the keyword DATABASE and parentheses containing the table name and the column/field name you want to export to. SUBJECT TO FactoryCapacity[factory] EXPORT ShadowPrice TO DATABASE("Factory", "ShadowPrice"); In the above example, MPL will open the database table Factory, locate the columns FactID and ShadowPrice, and then export in the shadow price values for the constraint FactoryCapacity. Copyright © 2012 Maximal Software, Inc. All rights reserved 14
  • 15. Data Modeling for Optimisation Export Constraint Values to Database (Cont.) Here is an example of the Factory table after the shadow price values have been exported. FactID Capacity ShadowPrice 120.938 Houston 320000 4 Seattle 73000 0.0000 Notice that MPL automatically uses the same name as the default for the index column FactID, as in the original tables the factory index was defined from. If an index column does have a different name than in the original table you can specify it by first entering the index name followed by an equal sign and the column name. SUBJECT TO FactoryCapacity[factory] EXPORT ShadowPrice TO DATABASE("Factory", "ShadowPrice”, factory="Factory”); This means, if you are consistent in naming the columns in different tables, you do not have to specify them each time you refer to them in MPL. Copyright © 2012 Maximal Software, Inc. All rights reserved 15
  • 16. Data Modeling for Optimisation Export Constraint Values to Database (Cont.) In the example below, MPL will export the shadow price of the constraint vector FactoryCapacity from FoxPro instead of the default database. SUBJECT TO FactoryCapacity[factory] EXPORT ShadowPrice TO DATABASE(FoxPro,"Factory","ShadowPrice"); MPL also allows you to export constraint values other than the shadow price. You can export the slack values, the upper and lower ranges for the right-hand-side as well as the right-hand-side values. You change which values will be exported by entering one of the following keywords directly after the keyword EXPORT: Activity, Slack, ShadowPrice, RhsValue, RhsLower, RhsUpper. For example, if you want to export the slack for a constraint enter the following: SUBJECT TO FactoryCapacity[factory] EXPORT Slack TO DATABASE("Factory","Slack"); If you need to export more than one value for a variable vector you can do so by entering multiple export statements after the variable definition. Copyright © 2012 Maximal Software, Inc. All rights reserved 16
  • 17. Data Modeling for Optimisation SpreadSheet Modeling in MPL • Spreadsheet optimisation allows users to create models that are easy to use, enabling the user to quickly update the data and solve the model. • Spreadsheets are efficient at handling and managing 2-Dimensional dense data and single scalar values. Copyright © 2012 Maximal Software, Inc. All rights reserved 17
  • 18. Data Modeling for Optimisation Import Indexes from Excel MPL allows you to import the elements for an index directly from an EXCELRANGE. In the INDEX section, where you define the index, enter the keyword EXCELRANGE after the assignment symbol (:=) followed by parentheses containing the table name and the column/field name you want to import from. INDEX depot := EXCELRANGE("Depots"); In the above example, MPL will read in the entries for the index depot from the Excel range called Depots. Copyright © 2012 Maximal Software, Inc. All rights reserved 18
  • 19. Data Modeling for Optimisation Import Data Vectors from Excel MPL allows you import the elements for a data vector directly from EXCEL. One can read in data in tabular format using the keyword EXCELRANGE or in sparse format using the keyword EXCELSPARSE, below is an example of how to import a data vector from EXCEL. DATA FactDepCost[factory,depot] := EXCELSPARSE("FactDep", "3"); In the above example, MPL will read in the data vector FactDepCost from the range called FactDep, as we have specified the data is in sparse format it will take the first column to be entries for the Factory index, the second column to be entries for the Depot index and 3 specifies the value of the data parameter to be taken from the third column. The FactDep Table: FactID DepotID TrCost Shipment Houston Chicago 3200 0 Houston Dallas 5100 0 Seattle Atlanta 2800 0 Seattle New York 4700 0 Seattle Dallas 5400 0 Copyright © 2012 Maximal Software, Inc. All rights reserved 19
  • 20. Data Modeling for Optimisation Export Variable Values to Excel After optimizing the problem, MPL can export the variable values to the EXCEL where it can be used to report the solution back to the user. In the DECISION VARIABLES section, where you define the variable vector, enter the keyword EXPORT TO after the defined variable, followed by the keyword EXCELRANGE/ EXCELSPARSE and parentheses containing the range name and the column number if you are using EXCELSPARSE. DECISION VARIABLES FactDepShip[factory,depot] EXPORT TO EXCELRANGE("Shipping"); In the above example, MPL will export the solution values for the variable vector FactDepShip to the range called Shipping. Copyright © 2012 Maximal Software, Inc. All rights reserved 20
  • 21. Data Modeling for Optimisation Sparse Data vs. Dense Data • Dense Data • Standard representation in row and column format • Row and column format preferably when data is highly dense, containing none or low percentage of null or zero values • Can be difficult to deal with for large data sets. • Sparse Data • Includes only non zero values • Highly efficient representation if small percentage of the values are nonzero • Efficient. Generating and Solving models Copyright © 2012 Maximal Software, Inc. All rights reserved 21
  • 22. Data Modelling for Optimisation Sparse and Dense Data Examples Dense Data In the following example shows the datavector Shipcost. The parameter is indexed over 4 plants, 2 warehouses and 3 products. ShipCost[plant, warehouse, product] := [ ! p1 p2 p3 {pl1} 70, 52, 48, !w1 65, 40, 74, !w2 {pl2} 79, 52, 65, !w1 75, 50, 53, !w2 {pl3} 47, 52, 51, !w1 78, 52, 52, !w2 {pl4} 75, 80, 50, !w1 90, 52, 10]; !w2 Copyright © 2012 Maximal Software, Inc. All rights reserved 22
  • 23. Data Modelling for Optimisation Sparse and Dense Data Examples Sparse Data The first entry of each row specifies the first index. In our example this means plant, the second and third entries refers to the machine and product indexes and the fourth to the actual data value for ProdCost. ProdCost[plant, machine, product] := [ p1, m11, A1, 73.30, p1, m11, A2, 52.90, p1, m12, A3, 65.40, p1, m13, A3, 47.60, p2, m21, A1, 79.00, p2, m21, A3, 66.80, p2, m22, A2, 52.00, p3, m31, A1, 75.80, p3, m31, A3, 50.90, p3, m32, A1, 79.90, p3, m32, A2, 52.10, p4, m41, A1, 82.70, p4, m41, A2, 63.30, p4, m41, A3, 53.80]; Copyright © 2012 Maximal Software, Inc. All rights reserved 23
  • 24. Data Modelling for Optimisation Text vs. Database vs. Spreadsheet Data can be read in at different speeds depending on the data source. • Text Files - Are compact and simple and by far the quickest way to read in data. • Databases - Are built for data management pretty quick to import and export data. • Spreadsheets - Not designed to handle or manage large data sets, inefficient in importing data and is the slowest method to read in and export data. Copyright © 2012 Maximal Software, Inc. All rights reserved 24