RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge...

19
RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) BAP Partitioning Challenge Partitioning only – not packing The BAP Software Overview Input / Output Files Project File – what and why BAPS Software Architecture Coding the BAP Partitioner BAPS – Main Program BAP Package Partitioner, Packer

Transcript of RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge...

Page 1: RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview.

RAS-Group, SoC, NUS

(BAP: CS5234) Page 1

RAS Meeting (October-2002)

BAP Partitioning Challenge Partitioning only – not packing

The BAP Software Overview Input / Output Files Project File – what and why BAPS Software Architecture

Coding the BAP Partitioner BAPS – Main Program BAP Package Partitioner, Packer

Page 2: RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview.

RAS-Group, SoC, NUS

(BAP: CS5234) Page 2

BAP Partitioning Challenge

For CS5234, only need to solve BAP Partitioning

Solve only BAP Partitioning Sub-Problem BAP Packing component is GIVEN TO YOU

What does that mean? For each vessel, you only need to assign it to a section NO NEED TO ASSIGN WHARFMARK

What if you like to also do BAP Packing? Can talk to me to get details, BUT Do it after the end of the course No need to jeopardize your grades

Page 3: RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview.

RAS-Group, SoC, NUS

(BAP: CS5234) Page 3

BAPS Software Overview

How to Use the BAPS Software usage: BAPS <ProjectFileName> eg: BAPS proj-d001.prj

BAP Project File specifies section-file, vessel-file, transshipment-file parameter file (what alg to use for)

partitioning algorithm to useany associated parameters

packing algorithm to useany associated parameters

name of output file, trace file, summary file

Page 4: RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview.

RAS-Group, SoC, NUS

(BAP: CS5234) Page 4

BAPS Software Architecture

BAPS Package Class acts as the interface class;

BAPS Solver Class encapsulates solution; Initializes BAPPackage; invokes Partitioning and

Packing

Library Components

BAP Classes

BAP PackageBAP Solver

BAPPartitioningComponents

BAPPacking

Components

Page 5: RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview.

RAS-Group, SoC, NUS

(BAP: CS5234) Page 5

About the BAPS Software

Software belongs to the RAS-Group, SoC, NUS

/*************************************************************************

*

* File Name: BAPS.cpp

* BAPS v2.0

* Author : David Ong Tat Wee

* Date : 25 Apr 2000

*

* Copyright (C) 1998, 1999, 2000

* All Rights Reserved by

* The RAS Group, Algorithms Lab

* School of Computing

* National University of Singapore

*

*************************************************************************/

Page 6: RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview.

RAS-Group, SoC, NUS

(BAP: CS5234) Page 6

BAPS Software Overview

Data Sources

BAP-XXPacker

BAP-XXPacker

BAPPackers

BAPTVPartitioner

BAP Solver

BAPPackage

GUIModule

BAPSEngine

Page 7: RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview.

RAS-Group, SoC, NUS

(BAP: CS5234) Page 7

BAPS Software Overview

baps (Main)

create

call

BAP Package

BAPSolver

Partition

Packing

BAPPartitioner(Abstract)

BAPPacker(Abstract)

Page 8: RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview.

RAS-Group, SoC, NUS

(BAP: CS5234) Page 8

BAP (Main Program)

BAPS Main (baps.cpp) Checks the command-line parameters Reads the Project File Initializes the BAPPackage Initializes the BAPSolver Calls BAPSolver.solve();

Page 9: RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview.

RAS-Group, SoC, NUS

(BAP: CS5234) Page 9

baps (Main Program)

#include "def.h“ // Include important stuffs used

#include "BAPPackage.h"

#include "BAPSolver.h"

int main(int argc, char *argv[])

{

if (argc != 2 && argc != 3) // CHECK command-line arguments!!

{…}

… // Check env variables BAPHOME BAPTMP

string ProjectFile(argv[1]); // Get ProjectFile

string Job("all");

BAPPackage TheBAP(ProjectFile); // Initializes the BAPPackage

BAPSolver Solver(TheBAP, Job); // Initializes the Solver

Solver.Solve(); // Invokes Solve() method

cout << "End of program" << endl;

return 0;

}

Page 10: RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview.

RAS-Group, SoC, NUS

(BAP: CS5234) Page 10

BAP Solver Class

BAP Solver (BAPSolver.{h,cpp}) Takes in a BAPPackage and … Read parameter file to get details of

partitioning algorithm to use packing algorithm to use, etc, etc

Invokes Partitioning-Solver Class Creates appropriate Partitioner (with BAPPackage) Invokes Solve() method of Partitioner Updates BAPPackage after partitioning;

Invokes appropriate Packing-Solver Class Creates appropriate Packer (with BAPPackage) Invokes Solve() method of Packer Updates BAP Package after packing;

Page 11: RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview.

RAS-Group, SoC, NUS

(BAP: CS5234) Page 11

BAP Solver Class

/******************************************************************

* Filename : BAPSolver.cpp

* Description : Implements the BAP Solver class

* Notes : This class calls the BAP partitioning and packing

* algorithms. It serves as an interface between the

* BAP Package class and the BAP algorithms.

******************************************************************/

#include "BAPSolver.h"

BAPSolver::BAPSolver(BAPPackage& aPackage, string aJob = "all") // CONSTRUCTOR

: BAPBase(), mPackage(aPackage), mJob(aJob),

mPartitioner("GP"), mPacker("BP")

{

ReadParameterFile(); // GET PARAMETERS

}

BAPPackage& BAPSolver::Package() const // GET the BAPPackage

{

return mPackage;

}

Page 12: RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview.

RAS-Group, SoC, NUS

(BAP: CS5234) Page 12

BAP Solver Class (2)

void BAPSolver::Solve() // THE SOLVE() METHOD

{

if (mJob == "all") // everything is obvious here!!

{

cout << "running all" << endl;

DoPartitioning();

DoPacking();

}

else if (mJob == "part")

{

cout << "running partitioning" << endl;

DoPartitioning();

}

else if (mJob == "pack")

{

cout << "running packing" << endl;

DoPacking();

}

else

{

cerr << "BAPSolver: unknown job '" << mJob << "'" << endl;

}

}

Page 13: RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview.

RAS-Group, SoC, NUS

(BAP: CS5234) Page 13

The BAP Partitioning Solver Class

Code Given to All of You One Partitioner – BAPTVPartitioner

inherit from BAPPartitioner BAP Packer Component – BAPBPPacker

Given as .h and .o files

BAPSolver Class

BAPPackingSolver

BAPPartitioning

Solver

BAPPackage BAPPackage

Page 14: RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview.

RAS-Group, SoC, NUS

(BAP: CS5234) Page 14

Generic Partitioner (DoPartitioning)

void BAPSolver::DoPartitioning() // Job: Call the correct BAP Partitioner

{

BAPPartitioner* Partitioner; // Init Generic Partitioner first

if (mPartitioner == "TV") // Check for specified BAP PARTITIONER

Partitioner = new BAPTVPartitioner(mPackage); // Create BAPTVPartitioner (with BAPPackage)

//else if (mPartitioner=="new partitioner") // PLACE for your NEW PARTITIONER

else

{

cerr << "Unknown partitioner: " << mPartitioner << endl;

return;

}

Partitioner->Solve(); // Invokes Solve Method of Partitioner

delete Partitioner;

}

Page 15: RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview.

RAS-Group, SoC, NUS

(BAP: CS5234) Page 15

Generic Packer (DoPacking)

void BAPSolver::DoPacking() // Job: Get the correct BAP Packer

{

BAPPacker* Packer; // Init generic Packer first

if (mPacker == "BP") // Check for specified packer

Packer = new BAPBPPacker(mPackage); // Create BP Packer

else

{

cerr << "Unknown packer: " << mPacker << endl;

return;

}

Packer->Solve(); // Invokes Solve() method of packer

delete Packer;

}

Page 16: RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview.

RAS-Group, SoC, NUS

(BAP: CS5234) Page 16

Your Project

Code up another BAP Partitioner Use BAPTVPartitioner as model Your partitioner will be very similar

Study code for BAPTVPartitioner Note the APIs for

calling BAPPackage’s methods; calculating section local/global density; checking feasibility for adding a vessel to a section adding vessel to section; calculating transshipment cost

Page 17: RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview.

RAS-Group, SoC, NUS

(BAP: CS5234) Page 17

Software Directory Structure

software-root-dir doc man src partitioning packing bin database param project solution result

Page 18: RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview.

RAS-Group, SoC, NUS

(BAP: CS5234) Page 18

Page 19: RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview.

RAS-Group, SoC, NUS

(BAP: CS5234) Page 19