Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

MipHandler Class Reference

Interface between AgentF and MIP solver. More...

#include <MipHandler.h>

Collaboration diagram for MipHandler:

Collaboration graph
[legend]
List of all members.

Public Member Functions

Data query functions
int getAgentID () const
 Get the agent identitiy number.
int getSubcatchmentID () const
 Get the subcatchment identitiy number.
AgentProblem *const getSpecificProblemPtr () const
 Returns a pointer to the specific problem.
AgentProblem getSpecificProblem () const
 Returns the specific problem.
ProblemDescription *const getProblemDescriptionPtr () const
 Returns a pointer to the supplementary MIP description.
Set data functions
virtual void setAgentID (int agentID)
 Set the agent identitiy number.
virtual void setSubcatchmentID (int subcatchmentID)
 Set the subcatchment identitiy number.
virtual int setSpecificProblem (const AgentProblem &specificProblem)
 pass template problem to MipHandler
virtual void resetProblem ()
 reset specific to template problem:
Solve and load functions
virtual int solve (AgentSolution &solution_)
 Solve specific problem and return solution.
Set parameter functions
virtual void setSolverType (SolverType solver)
 Set the solver type:.
virtual void setTestFlag (int test)
 Switch testmode of this class on/off.
virtual void setTolerance (double eps)
 Set the tolerance of coefficients.
virtual bool setVerbosity (int verbosity)
 Set the verbosity of the MipHandler.
virtual void setSafePrimalSolutionFlag (bool safePrimalSolution)
 set if primal solution is to be saved
Get parameter functions
virtual SolverType getSolverType () const
 Get the solver type:.
bool getTestFlag () const
 Returns if testmode is on or of.
double getTolerance () const
 Get the tolerance of coefficients.
int getNumberOfSolvedMIPs () const
 get number of solved MIP problems
bool getSafePrimalSolutionFlag ()
 get if primal solution is to be saved
virtual string getSolverName ()
 Get the name of chosen solver.
Functions to read and write files and Debugging fucntions
virtual int readMtx (char *filename)
 Reads Excel file and store data in templateProblem.
virtual int readDat (char *filename)
virtual int writeMtx (char *filename) const
 Write milp tableau to mtx file.
virtual int writeDat (char *filename) const
 Write milp tableau and supplementary information to dat file.
virtual void writeSolutionPrimal (char *filename) const
void writeSolverProblemExcel (char *filename) const
virtual void writeMps (const string filename, const string extension="mps") const
virtual void readMps (const string infile, const string extension="mps")
virtual void templateOutput (string name)
virtual void specificOutput (string name)
virtual void outputSolver (string name)
virtual void manipulateObjective ()
 manipulate Objective functions coefficienst for testing, e.g. warmstart funcionality
Constructors and Destructors
 MipHandler ()
 Standard Constructor.
 ~MipHandler ()
 Destructor.

Private Member Functions

Private methods
virtual int switchSolver ()
 Switch to the solver specified in (solverType solver).
void setInitialParamSym ()
 set some important SYMPHONY parameters
virtual int loadProblem ()
 Load specific problem to specified solver.
virtual int solve ()
 Solve specific problem.
int solveSym ()
 loaded problem and solve using SYMPHONY
int solveOsl ()
 loaded problem and solve using OSL
int warmstart1Osl ()
 use warmstart to solve with mode 1 and Osl
int warmstart2Osl ()
 use warmstart to solve with mode 2 and Osl
int coldstart1Osl ()
 solve with mode 1 and Osl
int coldstart2Osl ()
 solve with mode 2 and Osl
int coldstart3Osl ()
 solve with mode 3 and Osl
virtual void forcedSolution (const AgentProblem &problem_, AgentSolution &solution_, bool save)
 compute forced solution for problem_ and pass it to solution_
virtual void forcedSolution ()
 compute forced solution for specific problem and pass it to solution
virtual int loadSolutionSym ()
 Load solution provided by SYMPHONY to solution.
virtual int loadSolutionOsl ()
 Load solution provided by OSL to solution.
virtual void deleteEmptyRowsAndCols ()
 Find and delete empty Rows and Coumns.
void preForcedSolutionMessages ()
 print some messages before forced solution
void postSolveTest ()
 perform some tests after solving
void printTime (char *mode)
 Print current time to standard out.
template<class ClassType>
int copy (ClassType *&finalObjectPtr_, const ClassType *const originalObjectPtr_)
 Allocates memory for class member finalObjectPtr_ if necessary and copies data from the object originalObjectPtr_ points to.
virtual void errormessage () const

Private Attributes

Private member objects
AgentProblemtemplateProblem
 Object where template data read from mtx file is stored:.
AgentProblemspecificProblem
 Customized templateProblem.
ProblemDescriptionproblemDescriptionObject
 Additional descriptive information on the general MIP.
OsiSolverInterface * mipSolver
 Interface to MIP solver.
AgentSolutionsolution
SolverType solver
 Encodes the type of MIP solver to be used.
string solvername
 stores the specified solver name
int istransposed
 number of blocks the Excel Tableau is made of
int test
 Test flag.
double eps
 Tolerance of coefficients to be distinct from zero.
int agentID
 Agent identity, usefull for runtime debugging.
int subcatchmentID
 Subcatchment identity, usefull for runtime debugging.
int verbosity
 remember the verbosity set in solver
int nudC
 Count dropped columns.
mat lpmatrix
 structur tracing success and failure during the dynamic simulation of each MILP solving process
int mp
 counts loaded MIP problems
int forcedSolutionFlag
 Flag if forced solution was calculated.
bool savePrimalSolution
 Flag if primal solution is to be safed.

Detailed Description

Interface between AgentF and MIP solver.

The class MipHandler is the interface between class AgentF and the solver class OsiSolverInterface. Template problems and problem descriptions can be read from .mtx and .dat files. Agents can pass their specific problem to the MipHandler or manipulate the template problem hold by the MipHandler such that it becomes specific. This problem is solved and the solution passed back to the Agent.


Constructor & Destructor Documentation

MipHandler::MipHandler  ) 
 

Standard Constructor.

Default solver is SYMPHONY

MipHandler::~MipHandler  ) 
 

Destructor.


Member Function Documentation

int MipHandler::coldstart1Osl  )  [private]
 

solve with mode 1 and Osl

int MipHandler::coldstart2Osl  )  [private]
 

solve with mode 2 and Osl

int MipHandler::coldstart3Osl  )  [private]
 

solve with mode 3 and Osl

template<class ClassType>
int MipHandler::copy ClassType *&  finalObjectPtr_,
const ClassType *const   originalObjectPtr_
[private]
 

Allocates memory for class member finalObjectPtr_ if necessary and copies data from the object originalObjectPtr_ points to.

Here is the call graph for this function:

virtual void MipHandler::deleteEmptyRowsAndCols  )  [private, virtual]
 

Find and delete empty Rows and Coumns.

Finds empty rows and columns, i.e. rows and columns which are equal to zero, in the specific problem and deltes them in the solver. CAVE: (i) Has to be used after problem is loaded to solver. (ii) Currently buggy with SYMPHONY(TODO)

virtual void MipHandler::errormessage  )  const [private, virtual]
 

Prints agent ID and subcatchement ID to standard error

virtual void MipHandler::forcedSolution  )  [private, virtual]
 

compute forced solution for specific problem and pass it to solution

Like above with problem_ = specificProblem and solution_ = solution

virtual void MipHandler::forcedSolution const AgentProblem problem_,
AgentSolution solution_,
bool  save
[private, virtual]
 

compute forced solution for problem_ and pass it to solution_

Compute forced solution for problem_ and pass it to solution_. The forced solution consists essentially of the opportunity costs of the Agent.

int MipHandler::getAgentID  )  const
 

Get the agent identitiy number.

This number is a useful runtime debugging information: In case of runtime errors the causing agent can be determined

int MipHandler::getNumberOfSolvedMIPs  )  const
 

get number of solved MIP problems

ProblemDescription* const MipHandler::getProblemDescriptionPtr  )  const
 

Returns a pointer to the supplementary MIP description.

which can be used to read data from the supplementary MIP description. CAVE: The MIP description shoul not be modified!

bool MipHandler::getSafePrimalSolutionFlag  ) 
 

get if primal solution is to be saved

virtual string MipHandler::getSolverName  )  [virtual]
 

Get the name of chosen solver.

virtual SolverType MipHandler::getSolverType  )  const [virtual]
 

Get the solver type:.

AgentProblem MipHandler::getSpecificProblem  )  const
 

Returns the specific problem.

CAVE: expensive; costs lots of time and memory when problem is big, problably not necessary

AgentProblem* const MipHandler::getSpecificProblemPtr  )  const
 

Returns a pointer to the specific problem.

which can be used to manipulate the specific problem

int MipHandler::getSubcatchmentID  )  const
 

Get the subcatchment identitiy number.

Also useful for runtime debugging

bool MipHandler::getTestFlag  )  const
 

Returns if testmode is on or of.

double MipHandler::getTolerance  )  const
 

Get the tolerance of coefficients.

Get the tolerance of coefficients (=eps) below which they are regarded as zero

virtual int MipHandler::loadProblem  )  [private, virtual]
 

Load specific problem to specified solver.

Load the specific problem which was given e.g. by readMtx(), to the specified solver (solverType solver)

virtual int MipHandler::loadSolutionOsl  )  [private, virtual]
 

Load solution provided by OSL to solution.

virtual int MipHandler::loadSolutionSym  )  [private, virtual]
 

Load solution provided by SYMPHONY to solution.

virtual void MipHandler::manipulateObjective  )  [virtual]
 

manipulate Objective functions coefficienst for testing, e.g. warmstart funcionality

virtual void MipHandler::outputSolver string  name  )  [virtual]
 

Write the solver contents to separate files

void MipHandler::postSolveTest  )  [private]
 

perform some tests after solving

void MipHandler::preForcedSolutionMessages  )  [private]
 

print some messages before forced solution

void MipHandler::printTime char *  mode  )  [private]
 

Print current time to standard out.

virtual int MipHandler::readDat char *  filename  )  [virtual]
 

virtual void MipHandler::readMps const string  infile,
const string  extension = "mps"
[virtual]
 

Read a MIP problem from MPS file and load it to specified solver and to specificProblem

virtual int MipHandler::readMtx char *  filename  )  [virtual]
 

Reads Excel file and store data in templateProblem.

Reads in MILP tableau from Excel input file and sends data to MipHandler->templateProblem. This function is supposed only to be used by 'MilpCheck' application. CAVE: no return code implemented, yet

virtual void MipHandler::resetProblem  )  [virtual]
 

reset specific to template problem:

virtual void MipHandler::setAgentID int  agentID  )  [virtual]
 

Set the agent identitiy number.

This number is a useful runtime debugging information: In case of runtime errors the causing agent can be determined

void MipHandler::setInitialParamSym  )  [private]
 

set some important SYMPHONY parameters

virtual void MipHandler::setSafePrimalSolutionFlag bool  safePrimalSolution  )  [virtual]
 

set if primal solution is to be saved

virtual void MipHandler::setSolverType SolverType  solver  )  [virtual]
 

Set the solver type:.

virtual int MipHandler::setSpecificProblem const AgentProblem specificProblem  )  [virtual]
 

pass template problem to MipHandler

virtual void MipHandler::setSubcatchmentID int  subcatchmentID  )  [virtual]
 

Set the subcatchment identitiy number.

Also useful for runtime debugging

virtual void MipHandler::setTestFlag int  test  )  [virtual]
 

Switch testmode of this class on/off.

test = true -> setVerbosity(10)

virtual void MipHandler::setTolerance double  eps  )  [virtual]
 

Set the tolerance of coefficients.

Set the tolerance of coefficients (=eps) below which they are regarded as zero

virtual bool MipHandler::setVerbosity int  verbosity  )  [virtual]
 

Set the verbosity of the MipHandler.

larger numbers -> larger verbosity verbosity = -2 -> no verbosity

virtual int MipHandler::solve  )  [private, virtual]
 

Solve specific problem.

Solves the specific problem hold by the MipHandler with the specified solver (solverType solver). The specific problem is automatically loaded to the solver.

virtual int MipHandler::solve AgentSolution solution_  )  [virtual]
 

Solve specific problem and return solution.

Solves the specific problem hold by the MipHandler with the specified solver (solverType solver) and passes back the solution in solution_. The specific problem is automatically loaded to the solver.

int MipHandler::solveOsl  )  [private]
 

loaded problem and solve using OSL

int MipHandler::solveSym  )  [private]
 

loaded problem and solve using SYMPHONY

virtual void MipHandler::specificOutput string  name  )  [virtual]
 

Write the specific model contents to separate files

virtual int MipHandler::switchSolver  )  [private, virtual]
 

Switch to the solver specified in (solverType solver).

virtual void MipHandler::templateOutput string  name  )  [virtual]
 

Write the template model contents to separate files

int MipHandler::warmstart1Osl  )  [private]
 

use warmstart to solve with mode 1 and Osl

int MipHandler::warmstart2Osl  )  [private]
 

use warmstart to solve with mode 2 and Osl

virtual int MipHandler::writeDat char *  filename  )  const [virtual]
 

Write milp tableau and supplementary information to dat file.

Writes the MILP tableau loaded to specificProblem and supplementary informationin loded descriptionObject to dat output file filename CAVE:not testet yet (TODO:test this)

virtual void MipHandler::writeMps const string  filename,
const string  extension = "mps"
const [virtual]
 

Write the (to solver) loaded(!) MIP problem to MPS file

virtual int MipHandler::writeMtx char *  filename  )  const [virtual]
 

Write milp tableau to mtx file.

Writes the MILP tableau loaded to specificProblem in mtx output file filename

virtual void MipHandler::writeSolutionPrimal char *  filename  )  const [virtual]
 

write primal solution into output files: name is <filename>.<solvername>-pri

void MipHandler::writeSolverProblemExcel char *  filename  )  const
 

Writes the MILP tableau loaded to the specified solver in Excel style to output file filename


Member Data Documentation

int MipHandler::agentID [private]
 

Agent identity, usefull for runtime debugging.

double MipHandler::eps [private]
 

Tolerance of coefficients to be distinct from zero.

int MipHandler::forcedSolutionFlag [private]
 

Flag if forced solution was calculated.

int MipHandler::istransposed [private]
 

number of blocks the Excel Tableau is made of

mat MipHandler::lpmatrix [private]
 

structur tracing success and failure during the dynamic simulation of each MILP solving process

OsiSolverInterface* MipHandler::mipSolver [private]
 

Interface to MIP solver.

int MipHandler::mp [private]
 

counts loaded MIP problems

int MipHandler::nudC [private]
 

Count dropped columns.

ProblemDescription* MipHandler::problemDescriptionObject [private]
 

Additional descriptive information on the general MIP.

This additional information on the genaral MIP describes in particular special economic and hydrological properties. The contents of AgentProblem (i.e. mtx file contents) and the contents of ProblemDescription correspond to the contents and structure of a dat file.

bool MipHandler::savePrimalSolution [private]
 

Flag if primal solution is to be safed.

AgentSolution* MipHandler::solution [private]
 

As it is a pointer no memory is allocated to copy it from the AgentF's and no time is needed for a copy process in solve(AgentSolution& solution);

SolverType MipHandler::solver [private]
 

Encodes the type of MIP solver to be used.

string MipHandler::solvername [private]
 

stores the specified solver name

AgentProblem* MipHandler::specificProblem [private]
 

Customized templateProblem.

int MipHandler::subcatchmentID [private]
 

Subcatchment identity, usefull for runtime debugging.

AgentProblem* MipHandler::templateProblem [private]
 

Object where template data read from mtx file is stored:.

int MipHandler::test [private]
 

Test flag.

int MipHandler::verbosity [private]
 

remember the verbosity set in solver


The documentation for this class was generated from the following file:
Generated on Thu Aug 28 12:41:31 2008 for MPMAS by  doxygen 1.3.9.1