summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--impl/Complete.hpp8
-rwxr-xr-ximpl/MCFClass.h12
-rw-r--r--impl/MCFSimplex.cpp63
-rw-r--r--impl/MCFSimplex.h2
-rw-r--r--impl/MCFSimplex.obin205412 -> 0 bytes
-rw-r--r--impl/Makefile9
-rw-r--r--impl/main.cpp4
8 files changed, 60 insertions, 39 deletions
diff --git a/.gitignore b/.gitignore
index 93c639b..3b8ddd5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
/impl/build/*
/impl/parser/*
gmon.out
+*.o
diff --git a/impl/Complete.hpp b/impl/Complete.hpp
index 664d71f..73c8f23 100644
--- a/impl/Complete.hpp
+++ b/impl/Complete.hpp
@@ -4,9 +4,15 @@
#include <cassert>
#include <ostream>
#include <istream>
+#include <limits>
template<typename T>
-T infinity() { }
+T infinity();
+
+template<>
+double infinity() {
+ return std::numeric_limits<double>::infinity();
+}
template<typename T>
struct Complete {
diff --git a/impl/MCFClass.h b/impl/MCFClass.h
index f10cb5a..9534776 100755
--- a/impl/MCFClass.h
+++ b/impl/MCFClass.h
@@ -993,7 +993,7 @@ class MCFClass {
/** @name Getting unboundedness certificate
@{ */
- virtual Index MCFGetUnbCycl( Index_Set Pred , Index_Set ArcPred )
+ virtual Index MCFGetUnbCycl( Index_Set , Index_Set )
{
return( Inf<Index>() );
}
@@ -1041,7 +1041,7 @@ class MCFClass {
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- virtual void MCFPutState( MCFStatePtr S ) {}
+ virtual void MCFPutState( MCFStatePtr ) {}
/**< Restore the solver to the state in which it was when the state `S' was
created with MCFGetState() [see above].
@@ -1342,7 +1342,7 @@ class MCFClass {
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- virtual CNumber MCFQCoef( cIndex i )
+ virtual CNumber MCFQCoef( cIndex )
/**< Return the quadratic coefficients of the cost of the i-th arc. Note that
the method is *not* pure virtual: an implementation is provided for "pure
@@ -1524,8 +1524,8 @@ class MCFClass {
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- virtual void ChgQCoef( cCRow NQCoef = NULL , cIndex_Set nms = NULL ,
- cIndex strt = 0 , Index stp = Inf<Index>() )
+ virtual void ChgQCoef( cCRow NQCoef = NULL , cIndex_Set = NULL ,
+ cIndex = 0 , Index = Inf<Index>() ) //HERE
/**< Change the quadratic coefficients of the arc costs. In particular,
change the coefficients that are:
@@ -1555,7 +1555,7 @@ class MCFClass {
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- virtual void ChgQCoef( Index arc , cCNumber NQCoef )
+ virtual void ChgQCoef( Index , cCNumber NQCoef )
/**< Change the quadratic coefficient of the cost of the i-th arc.
diff --git a/impl/MCFSimplex.cpp b/impl/MCFSimplex.cpp
index 60c70d1..d7543d7 100644
--- a/impl/MCFSimplex.cpp
+++ b/impl/MCFSimplex.cpp
@@ -411,7 +411,7 @@ void MCFSimplex::SetAlg( bool UsPrml , char WhchPrc )
MemDeAlloc(false);
if( Senstv && ( status != kUnSolved ) ) {
nodePType *node = dummyRootP;
- for( int i = 0 ; i < n ; i++ )
+ for( unsigned int i = 0 ; i < n ; i++ )
node = node->nextInT;
node->nextInT = NULL;
@@ -484,7 +484,7 @@ void MCFSimplex::SetAlg( bool UsPrml , char WhchPrc )
CreateAdditionalDualStructures();
MemDeAlloc(true);
nodeDType *node = dummyRootD;
- for( int i = 0 ; i < n ; i++ )
+ for( unsigned int i = 0 ; i < n ; i++ )
node = node->nextInT;
node->nextInT = NULL;
@@ -514,11 +514,12 @@ void MCFSimplex::SetAlg( bool UsPrml , char WhchPrc )
//#endif
}
#endif
- if( newPricingRule == kFirstEligibleArc )
+ if( newPricingRule == kFirstEligibleArc ) {
if( newUsePrimalSimplex )
arcToStartP = arcsP;
else
arcToStartD = arcsD;
+ }
if( ( nmax && mmax ) && ( newPricingRule == kCandidateListPivot ) )
MemAllocCandidateList();
@@ -942,13 +943,13 @@ void MCFSimplex::ChgCosts( cCRow NCost , cIndex_Set nms ,
for( arcDType *arc = arcsD + strt ; arc < (arcsD + stp) ; arc++ )
arc->cost = *(NCost++);
- if( Senstv && ( status != kUnSolved ) )
+ if( Senstv && ( status != kUnSolved ) ) {
if( usePrimalSimplex )
ComputePotential( dummyRootP );
else {
#if( QUADRATICCOST == 0 )
for( arcDType *arc = arcsD ; arc != stopArcsD ; arc++ )
- if( arc->ident > BASIC )
+ if( arc->ident > BASIC ) {
if( GTZ( ReductCost( arc ) , EpsCst ) ) {
arc->flow = 0;
arc->ident = AT_LOWER;
@@ -957,13 +958,15 @@ void MCFSimplex::ChgCosts( cCRow NCost , cIndex_Set nms ,
arc->flow = arc->upper;
arc->ident = AT_UPPER;
}
+ }
CreateInitialDModifiedBalanceVector();
PostDVisit( dummyRootD );
#endif
}
- else
+ } else {
status = kUnSolved;
+ }
} // end( MCFSimplex::ChgCosts )
@@ -994,8 +997,8 @@ void MCFSimplex::ChgCost( Index arc , cCNumber NCost )
node = ( arcsD + arc )->head;
ComputePotential( dummyRootD );
- for( arcDType *a = arcsD ; a != stopArcsD ; a++)
- if( a->ident > BASIC )
+ for( arcDType *a = arcsD ; a != stopArcsD ; a++)
+ if( a->ident > BASIC ) {
if( GTZ( ReductCost( a ) , EpsCst ) ) {
a->flow = 0;
a->ident = AT_LOWER;
@@ -1004,6 +1007,7 @@ void MCFSimplex::ChgCost( Index arc , cCNumber NCost )
a->flow = a->upper;
a->ident = AT_UPPER;
}
+ }
CreateInitialDModifiedBalanceVector();
PostDVisit( dummyRootD );
@@ -1017,8 +1021,8 @@ void MCFSimplex::ChgCost( Index arc , cCNumber NCost )
/*-------------------------------------------------------------------------*/
-void MCFSimplex::ChgQCoef( cCRow NQCoef , cIndex_Set nms ,
- cIndex strt , Index stp )
+void MCFSimplex::ChgQCoef( cCRow NQCoef , cIndex_Set ,
+ cIndex , Index stp )
{
if( stp > m )
stp = m;
@@ -1058,7 +1062,7 @@ void MCFSimplex::ChgQCoef( cCRow NQCoef , cIndex_Set nms ,
/*-------------------------------------------------------------------------*/
-void MCFSimplex::ChgQCoef( Index arc , cCNumber NQCoef )
+void MCFSimplex::ChgQCoef( Index , cCNumber NQCoef )
{
#if( QUADRATICCOST )
if( arc >= m )
@@ -1363,7 +1367,7 @@ void MCFSimplex::CloseArc( cIndex name )
ComputePotential( dummyRootD );
for( arcDType *a = arcsD ; a != stopArcsD ; a++ )
- if( a->ident > BASIC )
+ if( a->ident > BASIC ) {
if( GTZ( ReductCost( a ) , EpsCst ) ) {
a->flow = 0;
a->ident = AT_LOWER;
@@ -1372,6 +1376,7 @@ void MCFSimplex::CloseArc( cIndex name )
a->flow = a->upper;
a->ident = AT_UPPER;
}
+ }
}
CreateInitialDModifiedBalanceVector();
@@ -2565,11 +2570,12 @@ void MCFSimplex::DualSimplex( void )
while( fine == false ) {
/* If node is the root of subtree T2, Dual Simplex jumps to the node
(if exists) which follows the last node of T2 */
- if( node == h2 )
+ if( node == h2 ) {
if( lastNodeOfT2->nextInT )
node = lastNodeOfT2->nextInT;
else
break;
+ }
// Search arc in the Backward Star of nodes of T1
arcDType *arc = node->firstBs;
@@ -2761,7 +2767,6 @@ void MCFSimplex::DualSimplex( void )
theta = leavingArc->flow - leavingArc->upper;
// Initial value of theta is the infeasibility of the leaving arc
- FNumber t;
nodeDType *k1;
nodeDType *k2;
/* if entering arc is in U, Dual Simplex pushs flow in the cycle
@@ -2906,7 +2911,7 @@ void MCFSimplex::DualSimplex( void )
/*--------------------------------------------------------------------------*/
template<class N, class A>
-void MCFSimplex::UpdateT( A *h , A *k , N *h1 , N *h2 , N *k1 , N *k2 )
+void MCFSimplex::UpdateT( A * , A *k , N * , N *h2 , N *k1 , N *k2 )
{
/* In subtree T2 there is a path from node h2 (deepest node of the leaving
arc h and root of T2) to node k2 (deepest node of the leaving arc h and
@@ -3422,7 +3427,7 @@ MCFSimplex::arcDType* MCFSimplex::RuleDualCandidateListPivot( void )
// Search other arcs to fill the list
do {
nodeDType *node = nodesD + groupPos;
- for( node ; node < stopNodesD ; node += numGroup ) {
+ for( ; node < stopNodesD ; node += numGroup ) {
arcDType *arc = node->enteringTArc;
cFNumber flow = arc->flow;
if( LTZ( flow , EpsFlw ) ) {
@@ -3599,18 +3604,19 @@ void MCFSimplex::PostPVisit( nodePType *r )
// The method controls if "r" is a leaf in T
bool rLeaf = false;
int i = r - nodesP;
- if( r->nextInT )
+ if( r->nextInT ) {
if( ( r->nextInT )->subTreeLevel <= r->subTreeLevel )
rLeaf = true;
else
rLeaf = true;
+ }
- if( rLeaf ) // If "r" is a leaf
+ if( rLeaf ) { // If "r" is a leaf
if( ( r->enteringTArc)->head == r ) // If enteringTArc of "r" goes in "r"
( r->enteringTArc )->flow = modifiedBalance[ i ];
else // If enteringTArc of "r" goes out "r"
( r->enteringTArc )->flow = - modifiedBalance[ i ];
- else { // If "r" isn't a leaf
+ } else { // If "r" isn't a leaf
nodePType *desc = r->nextInT;
// Call PostPVisit for every child of "r"
while( ( desc ) && ( desc->subTreeLevel > r->subTreeLevel ) ) {
@@ -3625,12 +3631,13 @@ void MCFSimplex::PostPVisit( nodePType *r )
desc = desc->nextInT;
}
- if( r != dummyRootP )
+ if( r != dummyRootP ) {
if( ( r->enteringTArc )->head == r ) // If enteringTArc of "r" goes in "r"
( r->enteringTArc )->flow = modifiedBalance[ i ];
else // If enteringTArc of "r" goes out "r"
( r->enteringTArc )->flow = - modifiedBalance[ i ];
}
+ }
}
/*--------------------------------------------------------------------------*/
@@ -3651,11 +3658,12 @@ void MCFSimplex::BalanceFlow( nodePType *r )
else {
// The method controls if "r" is a leaf in T
bool rLeaf = false;
- if( r->nextInT )
+ if( r->nextInT ) {
if( ( r->nextInT )->subTreeLevel <= r->subTreeLevel )
rLeaf = true;
else
rLeaf = true;
+ }
if( rLeaf ) // If "r" is a leaf
AdjustFlow( r ); // The method controls if entering basic arc in "r" is
@@ -3681,7 +3689,7 @@ void MCFSimplex::BalanceFlow( nodePType *r )
void MCFSimplex::AdjustFlow( nodePType *r )
{
arcPType *arc = r->enteringTArc;
- if( arc >= dummyArcsP ) // If entering arc of "r" is a dummy arc
+ if( arc >= dummyArcsP ) { // If entering arc of "r" is a dummy arc
if( LTZ( arc->flow , EpsFlw ) ) {
// If this dummy arc has flow < 0, the algorithm overturns the arc
nodePType *temp = arc->tail;
@@ -3750,6 +3758,7 @@ void MCFSimplex::AdjustFlow( nodePType *r )
}
}
}
+ }
/*--------------------------------------------------------------------------*/
@@ -3793,11 +3802,12 @@ void MCFSimplex::PostDVisit( nodeDType *r )
// The method controls if "r" is a leaf in T
bool rLeaf = false;
int i = r - nodesD;
- if( r->nextInT )
+ if( r->nextInT ) {
if( ( r->nextInT )->subTreeLevel <= r->subTreeLevel )
rLeaf = true;
else
rLeaf = true;
+ }
if( rLeaf ) // If "r" is a leaf
if( ( r->enteringTArc)->head == r ) // If enteringTArc of "r" goes in "r"
@@ -3820,12 +3830,13 @@ void MCFSimplex::PostDVisit( nodeDType *r )
desc = desc->nextInT;
}
- if( r != dummyRootD )
+ if( r != dummyRootD ) {
if( ( r->enteringTArc )->head == r ) // If enteringTArc of "r" goes in "r"
( r->enteringTArc )->flow = modifiedBalance[ i ];
else // If enteringTArc of "r" goes out "r"
( r->enteringTArc )->flow = - modifiedBalance[ i ];
}
+ }
#endif
}
@@ -3962,7 +3973,7 @@ void MCFSimplex::PrintDArc( arcDType *arc )
MCFSimplex::nodePType* MCFSimplex::RecoverPNode( Index ind )
{
- if( ( ind < 0 ) || ( ind > n ) )
+ if( ( ind > n ) )
return( NULL );
if( ind )
return( nodesP + ind - 1 );
@@ -3994,7 +4005,7 @@ MCFSimplex::arcPType* MCFSimplex::RecoverPArc( nodePType *tail ,
MCFSimplex::nodeDType* MCFSimplex::RecoverDNode( Index ind )
{
- if( ( ind < 0 ) || ( ind > n ) )
+ if( ( ind > n ) )
return( NULL );
if( ind )
diff --git a/impl/MCFSimplex.h b/impl/MCFSimplex.h
index a8d84f6..6dc0f4f 100644
--- a/impl/MCFSimplex.h
+++ b/impl/MCFSimplex.h
@@ -1015,7 +1015,7 @@ inline MCFClass::CNumber MCFSimplex::MCFCost( MCFClass::cIndex i )
/*-------------------------------------------------------------------------*/
-inline MCFClass::CNumber MCFSimplex::MCFQCoef( MCFClass::cIndex i )
+inline MCFClass::CNumber MCFSimplex::MCFQCoef( MCFClass::cIndex )
{
#if( QUADRATICCOST )
if( usePrimalSimplex )
diff --git a/impl/MCFSimplex.o b/impl/MCFSimplex.o
deleted file mode 100644
index f9378b6..0000000
--- a/impl/MCFSimplex.o
+++ /dev/null
Binary files differ
diff --git a/impl/Makefile b/impl/Makefile
index 492528d..831857d 100644
--- a/impl/Makefile
+++ b/impl/Makefile
@@ -2,8 +2,8 @@ CC=gcc
CPP=g++
BUILD=build
PARSER=parser
-FLAGS= -lantlr3c -fno-exceptions -lrt
-#-Wall -Werror -Wextra -pedantic -lantlr3c -fno-exceptions -lrt
+CHECKER_FLAGS=-Wall -Werror -Wextra -pedantic
+FLAGS=-lantlr3c -fno-exceptions -lrt $(CHECKER_FLAGS)
NORMAL_FLAGS=$(FLAGS) -g -pg
OPTIMISED_FLAGS=$(FLAGS) -O3
@@ -14,12 +14,15 @@ fast: $(BUILD)/fast
.PHONY: check-syntax
check-syntax: $(PARSER)
- -$(CPP) $(FLAGS) -o /tmp/null -x c++ $(CHK_SOURCES)
+ -$(CPP) $(CHECKER_FLAGS) -o /tmp/null -x c++ $(CHK_SOURCES)
# the - is to ignore the return code.
$(BUILD)/main: $(BUILD) $(PARSER) main.o MCFSimplex.o
$(CPP) main.o MCFSimplex.o $(PARSER)/*.o -o $(BUILD)/main $(NORMAL_FLAGS)
+$(BUILD)/fast: $(BUILD) $(PARSER) main.o MCFSimplex.o
+ $(CPP) main.o MCFSimplex.o $(PARSER)/*.o -o $(BUILD)/fast $(OPTIMISED_FLAGS)
+
main.o: main.cpp *.hpp *.h
$(CPP) -c main.cpp $(NORMAL_FLAGS)
diff --git a/impl/main.cpp b/impl/main.cpp
index 0daa72a..267d11c 100644
--- a/impl/main.cpp
+++ b/impl/main.cpp
@@ -26,7 +26,7 @@ vector<T> toSupplies(pANTLR3_BASE_TREE node) {
vector<T> supplies;
pANTLR3_BASE_TREE childNode;
- for (int i = 0; i < num; ++i) {
+ for (unsigned int i = 0; i < num; ++i) {
childNode = (pANTLR3_BASE_TREE) node->getChild(node, i);
stringstream stream((char*)childNode->getText(childNode)->chars);
assert(stream >> output);
@@ -65,7 +65,7 @@ vector<pair<int,int> > toArcs(pANTLR3_BASE_TREE node) {
vector<pair<int,int> > arcs;
ANTLR3_UINT32 num = node->getChildCount(node);
pANTLR3_BASE_TREE childNode;
- for (int i = 0; i < num; ++i) {
+ for (unsigned int i = 0; i < num; ++i) {
childNode = (pANTLR3_BASE_TREE) node->getChild(node, i);
arcs.push_back(toArc(childNode));
}