* Removed the qoca library and the layouter implementation using it.

* Use the new ComplexLayouter for the more complex layouting tasks.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22335 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2007-09-27 22:48:20 +00:00
parent c29edec13e
commit 8c2647695a
177 changed files with 4 additions and 33316 deletions

View File

@ -64,8 +64,6 @@ BEOS_SYSTEM_LIB = libbe.so $(HAIKU_LIBSTDC++) libmedia.so libtracker.so
libtextencoding.so libz.so libfreetype.so libpng.so libmidi.so libmidi2.so
libdevice.so libgame.so libscreensaver.so <revisioned>libroot.so
$(X86_ONLY)libGL.so libfluidsynth.so
# constraint solver lib
lib$(LAYOUT_CONSTRAINT_SOLVER).so
;
BEOS_SYSTEM_SERVERS = registrar debug_server syslog_daemon media_server
net_server media_addon_server input_server app_server fake_app_server

View File

@ -32,8 +32,6 @@ SharedLibrary libbe.so :
<libbe>storage_kit.o
<libbe>support_kit.o
lib$(LAYOUT_CONSTRAINT_SOLVER).so
libicon.a
libagg.a
@ -68,8 +66,6 @@ SharedLibrary libbe_haiku.so :
<libbe>storage_kit.o
<libbe>support_kit.o
lib$(LAYOUT_CONSTRAINT_SOLVER).so
libicon.a
libagg.a

View File

@ -29,22 +29,6 @@ UsePrivateHeaders app input interface shared tracker ;
UseLibraryHeaders icon ;
# constraint solver to use
local constraintSolverSources = ;
switch $(LAYOUT_CONSTRAINT_SOLVER) {
case qoca :
{
DEFINES += USE_QOCA_CONSTRAINT_SOLVER ;
constraintSolverSources = QocaConstraintSolverLayouter.cpp ;
SubDirSysHdrs [ FDirName $(HAIKU_TOP) src libs ] ;
SubDirHdrs [ FDirName $(HAIKU_TOP) src libs qoca ] ;
}
case * :
{
}
}
SEARCH_SOURCE += [ FDirName $(SUBDIR) textview_support ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) layouter ] ;
@ -138,9 +122,9 @@ MergeObject <libbe>interface_kit.o :
WidthBuffer.cpp
# layouter
ComplexLayouter.cpp
Layouter.cpp
LayoutOptimizer.cpp
OneElementLayouter.cpp
SimpleLayouter.cpp
$(constraintSolverSources)
;

View File

@ -13,7 +13,7 @@
#include <List.h>
#include <View.h>
#include "ConstraintSolverLayouter.h"
#include "ComplexLayouter.h"
#include "OneElementLayouter.h"
#include "SimpleLayouter.h"
@ -581,7 +581,7 @@ BTwoDimensionalLayout::CompoundLayouter::ValidateMinMax()
if (elementCount <= 1)
fLayouter = new OneElementLayouter();
else if (_HasMultiElementItems())
fLayouter = new ConstraintSolverLayouter(elementCount, _Spacing());
fLayouter = new ComplexLayouter(elementCount, _Spacing());
else
fLayouter = new SimpleLayouter(elementCount, _Spacing());

View File

@ -1,18 +0,0 @@
/*
* Copyright 2007, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef CONSTRAINT_SOLVER_LAYOUTER_H
#define CONSTRAINT_SOLVER_LAYOUTER_H
#ifdef USE_QOCA_CONSTRAINT_SOLVER
# include "QocaConstraintSolverLayouter.h"
typedef QocaConstraintSolverLayouter ConstraintSolverLayouter;
#else
# include "SimpleLayouter.h"
typedef SimpleLayouter ConstraintSolverLayouter;
#endif
#endif // CONSTRAINT_SOLVER_LAYOUTER_H

File diff suppressed because it is too large Load Diff

View File

@ -1,144 +0,0 @@
/*
* Copyright 2006-2007, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef QOCA_CONSTRAINT_SOLVER_LAYOUTER_H
#define QOCA_CONSTRAINT_SOLVER_LAYOUTER_H
#include "Layouter.h"
#include <List.h>
class QcLinInEqSolver;
class QcConstraint;
class QcConstraint;
namespace BPrivate {
namespace Layout {
class QocaConstraintSolverLayouter : public Layouter {
public:
QocaConstraintSolverLayouter(int32 elementCount,
int32 spacing);
virtual ~QocaConstraintSolverLayouter();
virtual void AddConstraints(int32 element, int32 length,
float min, float max, float preferred);
virtual void SetWeight(int32 element, float weight);
virtual float MinSize();
virtual float MaxSize();
virtual float PreferredSize();
virtual LayoutInfo* CreateLayoutInfo();
virtual void Layout(LayoutInfo* layoutInfo, float size);
virtual Layouter* CloneLayouter();
private:
class Set;
class Variable;
class Constraint;
class MinConstraint;
class MaxConstraint;
class MinMaxEntry;
class MinMaxMatrix;
class MyLayoutInfo;
friend class Constraint;
enum {
MIN_CONSTRAINT = 0,
MAX_CONSTRAINT = 1,
};
void _ValidateMinMax();
void _AddMinConstraint(int32 first, int32 last,
int32 value);
void _AddMaxConstraint(int32 first, int32 last,
int32 value);
int32 _ComputeMin();
int32 _ComputeMax();
bool _ComputeSolution(int32 size);
bool _FindIntegerSolution(int32 size);
bool _FindIntegerSolution(const Set& nonIntVariables,
const BList& minConstraints,
const BList& maxConstraints,
int32 sizeDiff);
Constraint* _CreateConstraint(int32 type, int32 first,
int32 last, int32 value);
void _SetConstraint(int32 type,
Constraint** constraints,
int32 element, int32 value, bool restrict);
void _SetConstraint(int32 type,
BList& constraints,
int32 first, int32 last, int32 value,
bool restrict);
int _IndexOfConstraint(BList& constraints,
int32 first, int32 last);
bool _AddSetSizeConstraint(int32 size);
void _AddConstraints();
void _AddConstraints(const BList& constraints);
void _RemoveSetSizeConstraint();
void _RemoveConstraints();
void _RemoveConstraint(Constraint* constraint);
void _GetInvolvedConstraints(
const BList& constraints,
const BList& variables,
BList& filteredConstraints);
void _GetViolatedConstraints(
const BList& constraints,
BList& violatedConstraints);
void _FilterVariablesByMaxConstraints(
const BList& variables,
const BList& constraints,
Set& filteredVars);
static int _CompareVariables(const void* a, const void* b);
static int _CompareConstraintsByLength(const void* a,
const void* b);
static int _CompareConstraintsBySatisfactionDistance(
const void* a, const void* b);
private:
int32 fElementCount;
float* fWeights;
Constraint** fBasicMinConstraints;
Constraint** fBasicMaxConstraints;
BList fComplexMinConstraints;
BList fComplexMaxConstraints;
Variable* fVariables;
Variable* fSizeVariable;
QcLinInEqSolver* fSolver;
QcConstraint* fSizeSumConstraint;
QcConstraint* fSetSizeConstraint;
bool fConstraintsAdded;
bool fSetSizeConstraintAdded;
int32 fSpacing;
int32 fMin;
int32 fMax;
bool fMinMaxValid;
MyLayoutInfo* fLayoutInfo;
};
} // namespace Layout
} // namespace BPrivate
using BPrivate::Layout::QocaConstraintSolverLayouter;
#endif // QOCA_CONSTRAINT_SOLVER_LAYOUTER_H

View File

@ -13,7 +13,6 @@ SubInclude HAIKU_TOP src libs libtelnet ;
SubInclude HAIKU_TOP src libs ncurses ;
SubInclude HAIKU_TOP src libs pdflib ;
SubInclude HAIKU_TOP src libs png ;
SubInclude HAIKU_TOP src libs qoca ;
SubInclude HAIKU_TOP src libs stdc++ ;
SubInclude HAIKU_TOP src libs termcap ;
SubInclude HAIKU_TOP src libs usb ;

View File

@ -1,17 +0,0 @@
2000-10-16 Peter Moulder <pmoulder@bowman.csse.monash.edu.au>
* QcConstraintRep.hh (isSatisfied): Compile in unconditionally.
2000-08-14 Peter Moulder <pmoulder@bowman.csse.monash.edu.au>
* QcBiMap.hh (class QcBiMap): Remove unused methods ChangeIndex, EraseByIdentifier.
* QcBiMapNotifier.hh (class QcBiMapNotifier): Remove unused method ChangeConstraint.
* QcSolver and all derived classes (EndAddConstraint): return a
bool indicating success.
2000-07-21 Peter Moulder <pmoulder@bowman.csse.monash.edu.au>
* QcFloat.hh (GetValue): New method.

View File

@ -1,61 +0,0 @@
SubDir HAIKU_TOP src libs qoca ;
# Don't compile qoca with debugging. Debug/non-debug versions are
# incompatible.
DEBUG = 0 ;
SetSubDirSupportedPlatforms haiku libbe_test ;
{
local defines = [ FDefines HAVE_RINT=1 QOCA_INTERNALS ] ;
SubDirCcFlags $(defines) ;
SubDirC++Flags $(defines) ;
}
SubDirSysHdrs [ FDirName $(SUBDIR) $(DOTDOT) ] ;
SharedLibrary libqoca.so :
QcCassSolver.cc
QcCompPivotSystem.cc
QcCompPivotTableau.cc
QcConstraintRep.cc
QcCoreTableau.cc
QcDelCoreTableau.cc
QcDelLinEqTableau.cc
QcDelLinInEqTableau.cc
QcDenseMatrix.cc
QcFixedFloatRep.cc
QcFloatRep.cc
QcIneqSolverBase.cc
QcLinEqSolver.cc
QcLinEqSystem.cc
QcLinEqTableau.cc
QcLinInEqSolver.cc
QcLinInEqSystem.cc
QcLinInEqTableau.cc
QcLinPoly.cc
QcLinEqColStateVector.cc
QcLinEqRowStateVector.cc
QcLinInEqColStateVector.cc
QcLinInEqRowColStateVector.cc
QcNlpSolver.cc
QcNomadicFloatRep.cc
QcOrigRowStateVector.cc
QcQuasiRowColStateVector.cc
QcQuasiRowStateVector.cc
QcSolver.cc
QcSparseMatrix.cc
QcVarStow.cc
QcVariableBiMap.cc
QcUtility.cc
:
$(TARGET_LIBSTDC++)
;
# also install in app_server test environment
if ( $(TARGET_PLATFORM) = libbe_test ) {
HaikuInstall install-test-apps : $(HAIKU_APP_TEST_LIB_DIR)
: libqoca.so
: tests!apps ;
}

View File

@ -1,25 +0,0 @@
#ifndef KeyIteratorHH
#define KeyIteratorHH
template <class Iterator, typename Key>
class KeyIterator
: public Iterator
{
public:
KeyIterator (Iterator i)
: Iterator (i)
{
}
Key const & operator* () const
{
return (*((Iterator const *) this))->first;
}
Key const * operator->() const
{
return &(*((Iterator const *) this))->first;
}
};
#endif /* !KeyIteratorHH */

View File

@ -1,138 +0,0 @@
$(srcdir)/Makefile.am: Makefile.am.m4
rm -f $(srcdir)/$(@F)
m4 -P $(srcdir)/$(<F) > $(srcdir)/$(@F)
# AFAIK, this has to be in srcdir (as opposed to bsrcdir).
##bsrcdir = $(srcdir)
bsrcdir = .
.ch.cc: $(CH2XX)
@rm -f $(bsrcdir)/$(*F).cc && if echo "$(CH2XX) -c $< > $(bsrcdir)/$(*F).cc" \
&& $(CH2XX) -c $< > $(bsrcdir)/$(*F).cc; \
then :; \
else echo "rm -f $(bsrcdir)/$(*F).cc; exit 1" \
&& rm -f $(bsrcdir)/$(*F).cc; exit 1; fi
.ch.hh: $(CH2XX)
@rm -f $(bsrcdir)/$(*F).hh && if echo "$(CH2XX) -i $< > $(bsrcdir)/$(*F).hh" \
&& $(CH2XX) -i $< > $(bsrcdir)/$(*F).hh; \
then :; \
else echo "rm -f $(bsrcdir)/$(*F).hh; exit 1" \
&& rm -f $(bsrcdir)/$(*F).hh; exit 1; fi
.ch.H: $(CH2XX)
@rm -f $(bsrcdir)/$(*F).H && if echo "$(CH2XX) -d $< > $(bsrcdir)/$(*F).H" \
&& $(CH2XX) -d $< > $(bsrcdir)/$(*F).H; \
then :; \
else echo "rm -f $(bsrcdir)/$(*F).H; exit 1" \
&& rm -f $(bsrcdir)/$(*F).H; exit 1; fi
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
DEP_FILES = .deps/QcCassSolver.P .deps/QcCompPivotSystem.P .deps/QcCompPivotTableau.P .deps/QcConstraintRep.P .deps/QcCoreTableau.P .deps/QcDelCoreTableau.P .deps/QcDelLinEqTableau.P .deps/QcDelLinInEqTableau.P .deps/QcDenseMatrix.P .deps/QcFixedFloatRep.P .deps/QcFloatRep.P .deps/QcIneqSolverBase.P .deps/QcLinEqSolver.P .deps/QcLinEqSystem.P .deps/QcLinEqTableau.P .deps/QcLinInEqSolver.P .deps/QcLinInEqSystem.P .deps/QcLinInEqTableau.P .deps/QcLinPoly.P .deps/QcLinEqColStateVector.P .deps/QcLinEqRowStateVector.P .deps/QcLinInEqColStateVector.P .deps/QcLinInEqRowColStateVector.P .deps/QcNlpSolver.P .deps/QcNomadicFloatRep.P .deps/QcOrigRowStateVector.P .deps/QcQuasiRowColStateVector.P .deps/QcQuasiRowStateVector.P .deps/QcSolver.P .deps/QcSparseMatrix.P .deps/QcVarStow.P .deps/QcVariableBiMap.P
-include $(DEP_FILES)
.cc.ii0:
@rm -f $(bsrcdir)/$(@F) && if echo "$(CXXCPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -Wp,-MD,.deps/$(*F).pp $< > $(bsrcdir)/$(@F)" \
&& $(CXXCPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -Wp,-MD,.deps/$(*F).pp $< > $(bsrcdir)/$(@F); \
then :; \
else echo "rm -f $(bsrcdir)/$(@F); exit 1" \
&& rm -f $(bsrcdir)/$(@F); exit 1; fi
@rm -f .deps/$(*F).P
@-sed 's/\.o/.ii0/g' < .deps/$(*F).pp > .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm .deps/$(*F).pp
CXXFLAGS = @CXXFLAGS@
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
libqoca_la_myOBJECTS = QcCassSolver.lo QcCompPivotSystem.lo QcCompPivotTableau.lo QcConstraintRep.lo QcCoreTableau.lo QcDelCoreTableau.lo QcDelLinEqTableau.lo QcDelLinInEqTableau.lo QcDenseMatrix.lo QcFixedFloatRep.lo QcFloatRep.lo QcIneqSolverBase.lo QcLinEqSolver.lo QcLinEqSystem.lo QcLinEqTableau.lo QcLinInEqSolver.lo QcLinInEqSystem.lo QcLinInEqTableau.lo QcLinPoly.lo QcLinEqColStateVector.lo QcLinEqRowStateVector.lo QcLinInEqColStateVector.lo QcLinInEqRowColStateVector.lo QcNlpSolver.lo QcNomadicFloatRep.lo QcOrigRowStateVector.lo QcQuasiRowColStateVector.lo QcQuasiRowStateVector.lo QcSolver.lo QcSparseMatrix.lo QcVarStow.lo QcVariableBiMap.lo
ii0_files = QcCassSolver.ii0 QcCompPivotSystem.ii0 QcCompPivotTableau.ii0 QcConstraintRep.ii0 QcCoreTableau.ii0 QcDelCoreTableau.ii0 QcDelLinEqTableau.ii0 QcDelLinInEqTableau.ii0 QcDenseMatrix.ii0 QcFixedFloatRep.ii0 QcFloatRep.ii0 QcIneqSolverBase.ii0 QcLinEqSolver.ii0 QcLinEqSystem.ii0 QcLinEqTableau.ii0 QcLinInEqSolver.ii0 QcLinInEqSystem.ii0 QcLinInEqTableau.ii0 QcLinPoly.ii0 QcLinEqColStateVector.ii0 QcLinEqRowStateVector.ii0 QcLinInEqColStateVector.ii0 QcLinInEqRowColStateVector.ii0 QcNlpSolver.ii0 QcNomadicFloatRep.ii0 QcOrigRowStateVector.ii0 QcQuasiRowColStateVector.ii0 QcQuasiRowStateVector.ii0 QcSolver.ii0 QcSparseMatrix.ii0 QcVarStow.ii0 QcVariableBiMap.ii0
libqoca.la: $(ii0_files) $(libqoca_la_myOBJECTS) $(libqoca_la_DEPENDENCIES)
$(CXXLINK) -rpath $(libdir) $(libqoca_la_LDFLAGS) $(libqoca_la_myOBJECTS) $(libqoca_la_LIBADD) $(LIBS)
.ii0.o:
@if test -f $@ && cmp -s $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii 2>/dev/null; then :; else \
echo "cp $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii" \
&& cp $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii && \
echo "$(CXXCOMPILE) -c $(bsrcdir)/$(*F).ii" \
&& $(CXXCOMPILE) -c $(bsrcdir)/$(*F).ii; \
fi
.ii0.lo:
@if test -f $@ && cmp -s $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii 2>/dev/null; then :; else \
echo "cp $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii" \
&& cp $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii && \
echo "$(LTCXXCOMPILE) -c $(bsrcdir)/$(*F).ii" \
&& $(LTCXXCOMPILE) -c $(bsrcdir)/$(*F).ii; \
fi
# Note that we must start off with no .deps files.
cc = cc
BUILT_SOURCES = arith.H QcAliasedBiMap.H QcAliasedBiMap.hh QcASetSolver.H QcASetSolver.hh QcASetSolver.$(cc) QcBiMap.H QcBiMap.hh QcFloatRep.H QcFloatRep.hh QcFloatRep.$(cc) QcFixedFloatRep.H QcFixedFloatRep.hh QcFixedFloatRep.$(cc) QcIneqSolverBase.H QcIneqSolverBase.hh QcIneqSolverBase.$(cc) QcLinEqColStateVector.H QcLinEqColStateVector.hh QcLinEqColStateVector.$(cc) QcLinEqRowStateVector.H QcLinEqRowStateVector.hh QcLinEqRowStateVector.$(cc) QcLinInEqColStateVector.H QcLinInEqColStateVector.hh QcLinInEqColStateVector.$(cc) QcLinInEqRowColStateVector.H QcLinInEqRowColStateVector.hh QcLinInEqRowColStateVector.$(cc) QcNlpSolver.H QcNlpSolver.hh QcNlpSolver.$(cc) QcNomadicFloatRep.H QcNomadicFloatRep.hh QcNomadicFloatRep.$(cc) QcNullIterator.H QcOrigRowStateVector.H QcOrigRowStateVector.hh QcOrigRowStateVector.$(cc) QcQuasiRowColStateVector.H QcQuasiRowColStateVector.hh QcQuasiRowColStateVector.$(cc) QcQuasiRowStateVector.H QcQuasiRowStateVector.hh QcQuasiRowStateVector.$(cc) QcSolver.H QcSolver.hh QcSolver.$(cc) QcVarStow.H QcVarStow.hh QcVarStow.$(cc) QcVariableBiMap.H QcVariableBiMap.hh QcVariableBiMap.$(cc)
SUFFIXES = .ch .cc .hh .H .ii0
lib_LTLIBRARIES = libqoca.la
# Version info is `CURRENT[:REVISION[:AGE]]': *see (libtool)Versioning,
# in the libtool info page.
libqoca_la_LDFLAGS = -version-info 0:0:0
libqoca_la_LIBADD = -lstdc++ $(lwn) $(lgmp)
# Package visibility is implemented in C++ as `#ifdef QOCA_INTERNALS'.
# N.B. This is only for methods; for vars, make the var itself private
# and provide package-visible inline access methods.
# N.B.2: Also be careful of the needs of inline functions.
INCLUDES = -DQOCA_INTERNALS -I.. -I$(top_srcdir)/cxx
# Things needed by user programs. User programs #include only Qc.h, but Qc.h
# #includes the rest of these.
pkginclude_HEADERS = arith.H KeyIterator.hh QcASetSolver.H QcAliasedBiMap.H QcAliasedBiMap.hh QcFloat.hh QcFixedFloat.hh QcConstraint.hh QcBasicnessVarIndexIterator.hh QcBiMap.H QcBiMap.hh QcCassSolver.hh QcLinEqSolver.hh QcLinInEqSolver.hh QcUtility.hh QcDefines.hh QcEnables.H QcFixedFloatRep.H QcFixedFloatRep.hh QcFloatRep.H QcFloatRep.hh QcCassConstraint.hh QcDelLinEqSystem.hh QcDesireValueStore.hh QcCompPivotSystem.hh QcCompPivotTableau.hh QcConstraintRep.hh QcDelLinEqTableau.hh QcDelLinInEqSystem.hh QcException.hh QcIneqSolverBase.H QcLinEqSystem.hh QcLinInEqSystem.hh QcLinPoly.hh QcBiMapNotifier.hh QcDelLinInEqTableau.hh QcLinEqTableau.hh QcLinInEqTableau.hh QcLinPolyTerm.hh QcSolver.H QcSolver.hh QcSparseCoeff.hh QcConstraintBiMap.hh QcDelCoreTableau.hh QcLinEqRowColStateVector.hh QcLinInEqRowColStateVector.H QcLinInEqRowColStateVector.hh QcRowAdaptor.hh QcTableau.hh QcVariableBiMap.H QcVariableBiMap.hh QcCoreTableau.hh QcDenseMatrix.hh QcLinEqColStateVector.H QcLinEqColStateVector.hh QcLinEqRowStateVector.H QcLinEqRowStateVector.hh QcLinInEqColStateVector.H QcLinInEqColStateVector.hh QcNullableConstraint.hh QcNullableElement.hh QcNullableFloat.hh QcQuasiRowColStateVector.H QcQuasiRowColStateVector.hh QcSparseMatrixColIterator.hh QcTableauRowIterator.hh QcLinEqColState.hh QcLinEqRowState.hh QcLinInEqColState.hh QcMatrix.hh QcNlpSolver.H QcNlpSolver.hh QcNomadicFloatRep.H QcNomadicFloatRep.hh QcOrigRowStateVector.H QcOrigRowStateVector.hh QcQuasiColStateVector.hh QcQuasiRowStateVector.H QcQuasiRowStateVector.hh QcSolvedFormMatrix.hh QcSparseMatrixIterator.hh QcSparseMatrixRowIterator.hh QcMatrixIterator.hh QcOrigRowState.hh QcQuasiColState.hh QcQuasiRowState.hh QcSparseMatrix.hh QcStateVector.hh QcIterator.hh QcSparseMatrixElement.hh QcState.hh QcUnsortedListSet.hh QcVarStow.H
dist_libqoca_sources = QcASetSolver.H QcASetSolver.hh QcASetSolver.$(cc) QcCassSolver.cc QcCompPivotSystem.cc QcCompPivotTableau.cc QcConstraintRep.cc QcCoreTableau.cc QcDelCoreTableau.cc QcDelLinEqTableau.cc QcDelLinInEqTableau.cc QcDenseMatrix.cc QcFloatRep.cc QcIneqSolverBase.H QcIneqSolverBase.hh QcIneqSolverBase.$(cc) QcLinEqSolver.cc QcLinEqSystem.cc QcLinEqTableau.cc QcLinInEqSolver.cc QcLinInEqSystem.cc QcLinInEqTableau.cc QcLinPoly.cc QcSolver.cc QcSparseMatrix.cc KeyIterator.hh QcAliasedBiMap.H QcAliasedBiMap.hh QcBasicnessVarIndexIterator.hh QcBasicVarIndexIterator.hh QcBiMap.H QcBiMap.hh QcBiMapNotifier.hh QcCassConstraint.hh QcCassSolver.hh QcCompPivotSystem.hh QcCompPivotTableau.hh QcConstraint.hh QcConstraintBiMap.hh QcConstraintIndexIterator.hh QcConstraintRep.hh QcCoreTableau.hh QcDefines.hh QcDelCoreTableau.hh QcDelLinEqSystem.hh QcDelLinEqTableau.hh QcDelLinInEqSystem.hh QcDelLinInEqTableau.hh QcDenseMatrix.hh QcDenseMatrixColIterator.hh QcDenseMatrixIterator.hh QcDenseMatrixRowIterator.hh QcDenseTableauColIterator.hh QcDenseTableauIterator.hh QcDenseTableauRowIterator.hh QcDesireValueStore.hh QcException.hh QcFixedFloat.hh QcFixedFloatRep.cc QcFixedFloatRep.hh QcFloat.hh QcFloatRep.hh QcIterator.hh QcLinEqColState.hh QcLinEqColStateVector.H QcLinEqColStateVector.hh QcLinEqColStateVector.$(cc) QcLinEqRowColStateVector.hh QcLinEqRowState.hh QcLinEqRowStateVector.H QcLinEqRowStateVector.hh QcLinEqRowStateVector.$(cc) QcLinEqSolver.hh QcLinEqSystem.hh QcLinEqTableau.hh QcLinInEqColState.hh QcLinInEqColStateVector.H QcLinInEqColStateVector.hh QcLinInEqColStateVector.$(cc) QcLinInEqRowColStateVector.H QcLinInEqRowColStateVector.hh QcLinInEqRowColStateVector.$(cc) QcLinInEqSolver.hh QcLinInEqSystem.hh QcLinInEqTableau.hh QcLinPoly.hh QcLinPolyTerm.hh QcMatrix.hh QcMatrixIterator.hh QcOrigRowState.hh QcNlpSolver.H QcNlpSolver.hh QcNlpSolver.$(cc) QcNomadicFloatRep.cc QcNomadicFloatRep.hh QcNullIterator.H QcNullableConstraint.hh QcNullableElement.hh QcNullableFloat.hh QcOrigRowStateVector.H QcOrigRowStateVector.hh QcOrigRowStateVector.cc QcParamVarIndexIterator.hh QcQuasiColState.hh QcQuasiColStateVector.hh QcQuasiRowColStateVector.H QcQuasiRowColStateVector.hh QcQuasiRowColStateVector.$(cc) QcRowAdaptor.hh QcQuasiRowStateVector.H QcQuasiRowStateVector.hh QcQuasiRowStateVector.cc QcQuasiRowState.hh QcSolvedFormMatrix.hh QcSolver.hh QcSparseCoeff.hh QcSparseMatrix.hh QcSparseMatrixColIterator.hh QcSparseMatrixElement.hh QcSparseMatrixIterator.hh QcSparseMatrixRowIterator.hh QcState.hh QcStateVector.hh QcStructVarIndexIterator.hh QcTableau.hh QcTableauColIterator.hh QcTableauRowIterator.hh QcUnsortedListSet.hh QcUtility.hh QcVarStow.H QcVarStow.hh QcVarStow.$(cc) QcVariableBiMap.H QcVariableBiMap.hh QcVariableBiMap.$(cc) QcVariableIndexIterator.hh arith.H
ch_files = QcAliasedBiMap.ch QcASetSolver.ch QcBiMap.ch QcFixedFloatRep.ch QcFloatRep.ch QcIneqSolverBase.ch QcLinEqColStateVector.ch QcLinEqRowStateVector.ch QcLinInEqColStateVector.ch QcLinInEqRowColStateVector.ch QcNlpSolver.ch QcNomadicFloatRep.ch QcNullIterator.ch QcOrigRowStateVector.ch QcQuasiRowColStateVector.ch QcQuasiRowStateVector.ch QcSolver.ch QcVariableBiMap.ch QcVarStow.ch arith.ch
libqoca_la_SOURCES =
# Rationale for emptiness: If it has any .cc files, then automake
# produces .cc.o rules, which stuffs things up (because make sometimes
# tries to use them directly instead of using the .ii0.o rule). If it
# had .ii0 files, then the .ii0 files would be put into distdir, which
# is wrong because .ii0 files contain system header file contents.
EXTRA_DIST = $(dist_libqoca_sources) Makefile.am.m4 $(ch_files)
CLEANFILES = *.ii *.ii0
DISTCLEANFILES = -r .deps
dist-hook:
@rm -f $(distdir)/Makefile.tmp
grep -v '^-include ' < $(distdir)/Makefile.in > $(distdir)/Makefile.tmp
mv $(distdir)/Makefile.tmp $(distdir)/Makefile.in

View File

@ -1,286 +0,0 @@
$(srcdir)/Makefile.am: Makefile.am.m4
rm -f $(srcdir)/$(@F)
m4 -P $(srcdir)/$(<F) > $(srcdir)/$(@F)
# AFAIK, this has to be in srcdir (as opposed to bsrcdir).
m4_changequote([[, ]])m4_dnl
m4_define([[m4_echodo]], [[echo "m4_patsubst([[$1]], [[["\\`]\|\$\$]], [[\\\&]])" \
&& $1]])
m4_define([[m4_outputas]],
[[@rm -f $2 && if m4_echodo([[$1 > $2]]); \
then :; \
else m4_echodo([[rm -f $2; exit 1]]); fi]])
##bsrcdir = $(srcdir)
bsrcdir = .
m4_define([[m4_ch2xx_rule]],
[[.ch.$2: $(CH2XX)
m4_outputas([[$(CH2XX) $1 $<]], [[$(bsrcdir)/$(*F).$2]])]])
m4_ch2xx_rule(-c, cc)
m4_ch2xx_rule(-i, hh)
m4_ch2xx_rule(-d, H)
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
m4_dnl Like: tr -s ' \t\n' ' '
m4_define([[m4u_white]], [[m4_patsubst([[$1]], [[[
]+]], [[ ]])]])
m4_define(m4_libqoca_la_OBJECTS, m4u_white([[
QcCassSolver.lo QcCompPivotSystem.lo QcCompPivotTableau.lo
QcConstraintRep.lo QcCoreTableau.lo QcDelCoreTableau.lo
QcDelLinEqTableau.lo QcDelLinInEqTableau.lo QcDenseMatrix.lo
QcFixedFloatRep.lo
QcFloatRep.lo
QcIneqSolverBase.lo
QcLinEqSolver.lo QcLinEqSystem.lo QcLinEqTableau.lo
QcLinInEqSolver.lo QcLinInEqSystem.lo QcLinInEqTableau.lo
QcLinPoly.lo
QcLinEqColStateVector.lo
QcLinEqRowStateVector.lo
QcLinInEqColStateVector.lo
QcLinInEqRowColStateVector.lo
QcNlpSolver.lo
QcNomadicFloatRep.lo
QcOrigRowStateVector.lo
QcQuasiRowColStateVector.lo
QcQuasiRowStateVector.lo
QcSolver.lo QcSparseMatrix.lo
QcVarStow.lo
QcVariableBiMap.lo]]))m4_dnl
DEP_FILES = m4_patsubst(m4_libqoca_la_OBJECTS, [[\(\w*\)\.lo]], [[.deps/\1.P]])
-include $(DEP_FILES)
.cc.ii0:
m4_outputas([[$(CXXCPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -Wp,-MD,.deps/$(*F).pp $<]],
[[$(bsrcdir)/$(@F)]])
@rm -f .deps/$(*F).P
@-sed 's/\.o/.ii0/g' < .deps/$(*F).pp > .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm .deps/$(*F).pp
CXXFLAGS = @CXXFLAGS@
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
libqoca_la_myOBJECTS = m4_libqoca_la_OBJECTS
ii0_files = m4_patsubst(m4_libqoca_la_OBJECTS, \.lo, .ii0)
libqoca.la: $(ii0_files) $(libqoca_la_myOBJECTS) $(libqoca_la_DEPENDENCIES)
$(CXXLINK) -rpath $(libdir) $(libqoca_la_LDFLAGS) $(libqoca_la_myOBJECTS) $(libqoca_la_LIBADD) $(LIBS)
m4_define([[m4_compile]],
[[.ii0.$1:
@if test -f [[$]]@ && cmp -s $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii 2>/dev/null; then :; else \
m4_echodo([[cp $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii]]) && \
m4_echodo([[$($2[[]]CXXCOMPILE) -c $(bsrcdir)/$(*F).ii]]); \
fi
]])m4_dnl
m4_compile(o,)
m4_compile(lo,LT)
# Note that we must start off with no .deps files.
m4_dnl Expand `foo' to `foo.H foo.hh foo.$(cc)'.
m4_define([[m4u_Hhc]], [[m4_patsubst(.H .hh .$(cc), \., $1.)]])
m4_define([[m4u_Hh]], [[m4_patsubst(.H .hh, \., $1.)]])
cc = cc
BUILT_SOURCES = m4u_white([[
arith.H
m4u_Hh(QcAliasedBiMap)
m4u_Hhc(QcASetSolver)
m4u_Hh(QcBiMap)
m4u_Hhc(QcFloatRep)
m4u_Hhc(QcFixedFloatRep)
m4u_Hhc(QcIneqSolverBase)
m4u_Hhc(QcLinEqColStateVector)
m4u_Hhc(QcLinEqRowStateVector)
m4u_Hhc(QcLinInEqColStateVector)
m4u_Hhc(QcLinInEqRowColStateVector)
m4u_Hhc(QcNlpSolver)
m4u_Hhc(QcNomadicFloatRep)
QcNullIterator.H
m4u_Hhc(QcOrigRowStateVector)
m4u_Hhc(QcQuasiRowColStateVector)
m4u_Hhc(QcQuasiRowStateVector)
m4u_Hhc(QcSolver)
m4u_Hhc(QcVarStow)
m4u_Hhc(QcVariableBiMap)
]])
m4_dnl m4_patsubst(m4_libqoca_la_OBJECTS, \.lo, .ii0)
SUFFIXES = .ch .cc .hh .H .ii0
lib_LTLIBRARIES = libqoca.la
# Version info is `CURRENT[:REVISION[:AGE]]': *see (libtool)Versioning,
# in the libtool info page.
libqoca_la_LDFLAGS = -version-info 0:0:0
libqoca_la_LIBADD = -lstdc++ $(lwn) $(lgmp)
# Package visibility is implemented in C++ as `#ifdef QOCA_INTERNALS'.
# N.B. This is only for methods; for vars, make the var itself private
# and provide package-visible inline access methods.
# N.B.2: Also be careful of the needs of inline functions.
INCLUDES = -DQOCA_INTERNALS -I.. -I$(top_srcdir)/cxx
# Things needed by user programs. User programs #include only Qc.h, but Qc.h
# #includes the rest of these.
pkginclude_HEADERS = m4u_white([[
arith.H KeyIterator.hh
QcASetSolver.H
m4u_Hh(QcAliasedBiMap)
QcFloat.hh QcFixedFloat.hh QcConstraint.hh
QcBasicnessVarIndexIterator.hh
m4u_Hh(QcBiMap)
QcCassSolver.hh QcLinEqSolver.hh QcLinInEqSolver.hh
QcUtility.hh QcDefines.hh
QcEnables.H
QcFixedFloatRep.H QcFixedFloatRep.hh
QcFloatRep.H QcFloatRep.hh
QcCassConstraint.hh QcDelLinEqSystem.hh QcDesireValueStore.hh
QcCompPivotSystem.hh QcCompPivotTableau.hh QcConstraintRep.hh
QcDelLinEqTableau.hh QcDelLinInEqSystem.hh QcException.hh
QcIneqSolverBase.H
QcLinEqSystem.hh QcLinInEqSystem.hh QcLinPoly.hh
QcBiMapNotifier.hh QcDelLinInEqTableau.hh QcLinEqTableau.hh
QcLinInEqTableau.hh QcLinPolyTerm.hh QcSolver.H QcSolver.hh
QcSparseCoeff.hh QcConstraintBiMap.hh QcDelCoreTableau.hh
QcLinEqRowColStateVector.hh
QcLinInEqRowColStateVector.H QcLinInEqRowColStateVector.hh
QcRowAdaptor.hh QcTableau.hh
m4u_Hh(QcVariableBiMap)
QcCoreTableau.hh QcDenseMatrix.hh
QcLinEqColStateVector.H QcLinEqColStateVector.hh
QcLinEqRowStateVector.H QcLinEqRowStateVector.hh
QcLinInEqColStateVector.H QcLinInEqColStateVector.hh
QcNullableConstraint.hh QcNullableElement.hh QcNullableFloat.hh
QcQuasiRowColStateVector.H QcQuasiRowColStateVector.hh
QcSparseMatrixColIterator.hh
QcTableauRowIterator.hh QcLinEqColState.hh QcLinEqRowState.hh
QcLinInEqColState.hh QcMatrix.hh
QcNlpSolver.H QcNlpSolver.hh
QcNomadicFloatRep.H QcNomadicFloatRep.hh
QcOrigRowStateVector.H QcOrigRowStateVector.hh
QcQuasiColStateVector.hh
QcQuasiRowStateVector.H QcQuasiRowStateVector.hh
QcSolvedFormMatrix.hh QcSparseMatrixIterator.hh
QcSparseMatrixRowIterator.hh QcMatrixIterator.hh
QcOrigRowState.hh QcQuasiColState.hh QcQuasiRowState.hh
QcSparseMatrix.hh QcStateVector.hh QcIterator.hh
QcSparseMatrixElement.hh QcState.hh QcUnsortedListSet.hh
QcVarStow.H
]])
dist_libqoca_sources = m4u_white([[
m4u_Hhc(QcASetSolver)
QcCassSolver.cc QcCompPivotSystem.cc QcCompPivotTableau.cc
QcConstraintRep.cc QcCoreTableau.cc QcDelCoreTableau.cc
QcDelLinEqTableau.cc QcDelLinInEqTableau.cc QcDenseMatrix.cc
QcFloatRep.cc
m4u_Hhc(QcIneqSolverBase)
QcLinEqSolver.cc QcLinEqSystem.cc QcLinEqTableau.cc
QcLinInEqSolver.cc QcLinInEqSystem.cc QcLinInEqTableau.cc
QcLinPoly.cc QcSolver.cc QcSparseMatrix.cc
KeyIterator.hh
m4u_Hh(QcAliasedBiMap)
QcBasicnessVarIndexIterator.hh
QcBasicVarIndexIterator.hh
m4u_Hh(QcBiMap)
QcBiMapNotifier.hh
QcCassConstraint.hh QcCassSolver.hh QcCompPivotSystem.hh
QcCompPivotTableau.hh QcConstraint.hh QcConstraintBiMap.hh
QcConstraintIndexIterator.hh QcConstraintRep.hh QcCoreTableau.hh
QcDefines.hh QcDelCoreTableau.hh QcDelLinEqSystem.hh QcDelLinEqTableau.hh
QcDelLinInEqSystem.hh QcDelLinInEqTableau.hh QcDenseMatrix.hh
QcDenseMatrixColIterator.hh QcDenseMatrixIterator.hh
QcDenseMatrixRowIterator.hh QcDenseTableauColIterator.hh
QcDenseTableauIterator.hh QcDenseTableauRowIterator.hh
QcDesireValueStore.hh QcException.hh QcFixedFloat.hh
QcFixedFloatRep.cc QcFixedFloatRep.hh
QcFloat.hh QcFloatRep.hh QcIterator.hh
QcLinEqColState.hh
m4u_Hhc(QcLinEqColStateVector)
QcLinEqRowColStateVector.hh
QcLinEqRowState.hh
m4u_Hhc(QcLinEqRowStateVector)
QcLinEqSolver.hh
QcLinEqSystem.hh QcLinEqTableau.hh QcLinInEqColState.hh
m4u_Hhc(QcLinInEqColStateVector)
m4u_Hhc(QcLinInEqRowColStateVector)
QcLinInEqSolver.hh QcLinInEqSystem.hh QcLinInEqTableau.hh QcLinPoly.hh
QcLinPolyTerm.hh QcMatrix.hh QcMatrixIterator.hh QcOrigRowState.hh
m4u_Hhc(QcNlpSolver)
QcNomadicFloatRep.cc QcNomadicFloatRep.hh
QcNullIterator.H
QcNullableConstraint.hh QcNullableElement.hh QcNullableFloat.hh
QcOrigRowStateVector.H QcOrigRowStateVector.hh QcOrigRowStateVector.cc
QcParamVarIndexIterator.hh QcQuasiColState.hh
QcQuasiColStateVector.hh
m4u_Hhc(QcQuasiRowColStateVector)
QcRowAdaptor.hh
QcQuasiRowStateVector.H QcQuasiRowStateVector.hh QcQuasiRowStateVector.cc
QcQuasiRowState.hh
QcSolvedFormMatrix.hh QcSolver.hh
QcSparseCoeff.hh QcSparseMatrix.hh QcSparseMatrixColIterator.hh
QcSparseMatrixElement.hh QcSparseMatrixIterator.hh
QcSparseMatrixRowIterator.hh QcState.hh QcStateVector.hh
QcStructVarIndexIterator.hh QcTableau.hh QcTableauColIterator.hh
QcTableauRowIterator.hh QcUnsortedListSet.hh QcUtility.hh
m4u_Hhc(QcVarStow)
m4u_Hhc(QcVariableBiMap)
QcVariableIndexIterator.hh
arith.H
]])
ch_files = m4u_white([[
QcAliasedBiMap.ch
QcASetSolver.ch
QcBiMap.ch
QcFixedFloatRep.ch QcFloatRep.ch
QcIneqSolverBase.ch
QcLinEqColStateVector.ch
QcLinEqRowStateVector.ch QcLinInEqColStateVector.ch
QcLinInEqRowColStateVector.ch
QcNlpSolver.ch
QcNomadicFloatRep.ch QcNullIterator.ch
QcOrigRowStateVector.ch QcQuasiRowColStateVector.ch
QcQuasiRowStateVector.ch QcSolver.ch
QcVariableBiMap.ch
QcVarStow.ch
arith.ch
]])
libqoca_la_SOURCES =
# Rationale for emptiness: If it has any .cc files, then automake
# produces .cc.o rules, which stuffs things up (because make sometimes
# tries to use them directly instead of using the .ii0.o rule). If it
# had .ii0 files, then the .ii0 files would be put into distdir, which
# is wrong because .ii0 files contain system header file contents.
EXTRA_DIST = $(dist_libqoca_sources) Makefile.am.m4 $(ch_files)
CLEANFILES = *.ii *.ii0
DISTCLEANFILES = -r .deps
dist-hook:
@rm -f $(distdir)/Makefile.tmp
grep -v '^-include ' < $(distdir)/Makefile.in > $(distdir)/Makefile.tmp
mv $(distdir)/Makefile.tmp $(distdir)/Makefile.in

View File

@ -1,455 +0,0 @@
# Makefile.in generated automatically by automake 1.4 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
AS = @AS@
CC = @CC@
CH2XX = @CH2XX@
CXX = @CXX@
CXXCPP = @CXXCPP@
DLLTOOL = @DLLTOOL@
DOCXX = @DOCXX@
JAVA = @JAVA@
JAVAC = @JAVAC@
JAVACDEFINES = @JAVACDEFINES@
JAVADOC = @JAVADOC@
JCOM = @JCOM@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
MAKEINFO = @MAKEINFO@
MINUSDEPEND = @MINUSDEPEND@
NLPSOLVER_COM = @NLPSOLVER_COM@
NLPSOLVER_HASH = @NLPSOLVER_HASH@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
QC_NDEBUG_COM = @QC_NDEBUG_COM@
RANLIB = @RANLIB@
VERSION = @VERSION@
lgmp = @lgmp@
lwn = @lwn@
# AFAIK, this has to be in srcdir (as opposed to bsrcdir).
bsrcdir = .
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
DEP_FILES = .deps/QcCassSolver.P .deps/QcCompPivotSystem.P .deps/QcCompPivotTableau.P .deps/QcConstraintRep.P .deps/QcCoreTableau.P .deps/QcDelCoreTableau.P .deps/QcDelLinEqTableau.P .deps/QcDelLinInEqTableau.P .deps/QcDenseMatrix.P .deps/QcFixedFloatRep.P .deps/QcFloatRep.P .deps/QcIneqSolverBase.P .deps/QcLinEqSolver.P .deps/QcLinEqSystem.P .deps/QcLinEqTableau.P .deps/QcLinInEqSolver.P .deps/QcLinInEqSystem.P .deps/QcLinInEqTableau.P .deps/QcLinPoly.P .deps/QcLinEqColStateVector.P .deps/QcLinEqRowStateVector.P .deps/QcLinInEqColStateVector.P .deps/QcLinInEqRowColStateVector.P .deps/QcNlpSolver.P .deps/QcNomadicFloatRep.P .deps/QcOrigRowStateVector.P .deps/QcQuasiRowColStateVector.P .deps/QcQuasiRowStateVector.P .deps/QcSolver.P .deps/QcSparseMatrix.P .deps/QcVarStow.P .deps/QcVariableBiMap.P
CXXFLAGS = @CXXFLAGS@
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
libqoca_la_myOBJECTS = QcCassSolver.lo QcCompPivotSystem.lo QcCompPivotTableau.lo QcConstraintRep.lo QcCoreTableau.lo QcDelCoreTableau.lo QcDelLinEqTableau.lo QcDelLinInEqTableau.lo QcDenseMatrix.lo QcFixedFloatRep.lo QcFloatRep.lo QcIneqSolverBase.lo QcLinEqSolver.lo QcLinEqSystem.lo QcLinEqTableau.lo QcLinInEqSolver.lo QcLinInEqSystem.lo QcLinInEqTableau.lo QcLinPoly.lo QcLinEqColStateVector.lo QcLinEqRowStateVector.lo QcLinInEqColStateVector.lo QcLinInEqRowColStateVector.lo QcNlpSolver.lo QcNomadicFloatRep.lo QcOrigRowStateVector.lo QcQuasiRowColStateVector.lo QcQuasiRowStateVector.lo QcSolver.lo QcSparseMatrix.lo QcVarStow.lo QcVariableBiMap.lo
ii0_files = QcCassSolver.ii0 QcCompPivotSystem.ii0 QcCompPivotTableau.ii0 QcConstraintRep.ii0 QcCoreTableau.ii0 QcDelCoreTableau.ii0 QcDelLinEqTableau.ii0 QcDelLinInEqTableau.ii0 QcDenseMatrix.ii0 QcFixedFloatRep.ii0 QcFloatRep.ii0 QcIneqSolverBase.ii0 QcLinEqSolver.ii0 QcLinEqSystem.ii0 QcLinEqTableau.ii0 QcLinInEqSolver.ii0 QcLinInEqSystem.ii0 QcLinInEqTableau.ii0 QcLinPoly.ii0 QcLinEqColStateVector.ii0 QcLinEqRowStateVector.ii0 QcLinInEqColStateVector.ii0 QcLinInEqRowColStateVector.ii0 QcNlpSolver.ii0 QcNomadicFloatRep.ii0 QcOrigRowStateVector.ii0 QcQuasiRowColStateVector.ii0 QcQuasiRowStateVector.ii0 QcSolver.ii0 QcSparseMatrix.ii0 QcVarStow.ii0 QcVariableBiMap.ii0
# Note that we must start off with no .deps files.
cc = cc
BUILT_SOURCES = arith.H QcAliasedBiMap.H QcAliasedBiMap.hh QcASetSolver.H QcASetSolver.hh QcASetSolver.$(cc) QcBiMap.H QcBiMap.hh QcFloatRep.H QcFloatRep.hh QcFloatRep.$(cc) QcFixedFloatRep.H QcFixedFloatRep.hh QcFixedFloatRep.$(cc) QcIneqSolverBase.H QcIneqSolverBase.hh QcIneqSolverBase.$(cc) QcLinEqColStateVector.H QcLinEqColStateVector.hh QcLinEqColStateVector.$(cc) QcLinEqRowStateVector.H QcLinEqRowStateVector.hh QcLinEqRowStateVector.$(cc) QcLinInEqColStateVector.H QcLinInEqColStateVector.hh QcLinInEqColStateVector.$(cc) QcLinInEqRowColStateVector.H QcLinInEqRowColStateVector.hh QcLinInEqRowColStateVector.$(cc) QcNlpSolver.H QcNlpSolver.hh QcNlpSolver.$(cc) QcNomadicFloatRep.H QcNomadicFloatRep.hh QcNomadicFloatRep.$(cc) QcNullIterator.H QcOrigRowStateVector.H QcOrigRowStateVector.hh QcOrigRowStateVector.$(cc) QcQuasiRowColStateVector.H QcQuasiRowColStateVector.hh QcQuasiRowColStateVector.$(cc) QcQuasiRowStateVector.H QcQuasiRowStateVector.hh QcQuasiRowStateVector.$(cc) QcSolver.H QcSolver.hh QcSolver.$(cc) QcVarStow.H QcVarStow.hh QcVarStow.$(cc) QcVariableBiMap.H QcVariableBiMap.hh QcVariableBiMap.$(cc)
SUFFIXES = .ch .cc .hh .H .ii0
lib_LTLIBRARIES = libqoca.la
# Version info is `CURRENT[:REVISION[:AGE]]': *see (libtool)Versioning,
# in the libtool info page.
libqoca_la_LDFLAGS = -version-info 0:0:0
libqoca_la_LIBADD = -lstdc++ $(lwn) $(lgmp)
# Package visibility is implemented in C++ as `#ifdef QOCA_INTERNALS'.
# N.B. This is only for methods; for vars, make the var itself private
# and provide package-visible inline access methods.
# N.B.2: Also be careful of the needs of inline functions.
INCLUDES = -DQOCA_INTERNALS -I.. -I$(top_srcdir)/cxx
# Things needed by user programs. User programs #include only Qc.h, but Qc.h
# #includes the rest of these.
pkginclude_HEADERS = arith.H KeyIterator.hh QcASetSolver.H QcAliasedBiMap.H QcAliasedBiMap.hh QcFloat.hh QcFixedFloat.hh QcConstraint.hh QcBasicnessVarIndexIterator.hh QcBiMap.H QcBiMap.hh QcCassSolver.hh QcLinEqSolver.hh QcLinInEqSolver.hh QcUtility.hh QcDefines.hh QcEnables.H QcFixedFloatRep.H QcFixedFloatRep.hh QcFloatRep.H QcFloatRep.hh QcCassConstraint.hh QcDelLinEqSystem.hh QcDesireValueStore.hh QcCompPivotSystem.hh QcCompPivotTableau.hh QcConstraintRep.hh QcDelLinEqTableau.hh QcDelLinInEqSystem.hh QcException.hh QcIneqSolverBase.H QcLinEqSystem.hh QcLinInEqSystem.hh QcLinPoly.hh QcBiMapNotifier.hh QcDelLinInEqTableau.hh QcLinEqTableau.hh QcLinInEqTableau.hh QcLinPolyTerm.hh QcSolver.H QcSolver.hh QcSparseCoeff.hh QcConstraintBiMap.hh QcDelCoreTableau.hh QcLinEqRowColStateVector.hh QcLinInEqRowColStateVector.H QcLinInEqRowColStateVector.hh QcRowAdaptor.hh QcTableau.hh QcVariableBiMap.H QcVariableBiMap.hh QcCoreTableau.hh QcDenseMatrix.hh QcLinEqColStateVector.H QcLinEqColStateVector.hh QcLinEqRowStateVector.H QcLinEqRowStateVector.hh QcLinInEqColStateVector.H QcLinInEqColStateVector.hh QcNullableConstraint.hh QcNullableElement.hh QcNullableFloat.hh QcQuasiRowColStateVector.H QcQuasiRowColStateVector.hh QcSparseMatrixColIterator.hh QcTableauRowIterator.hh QcLinEqColState.hh QcLinEqRowState.hh QcLinInEqColState.hh QcMatrix.hh QcNlpSolver.H QcNlpSolver.hh QcNomadicFloatRep.H QcNomadicFloatRep.hh QcOrigRowStateVector.H QcOrigRowStateVector.hh QcQuasiColStateVector.hh QcQuasiRowStateVector.H QcQuasiRowStateVector.hh QcSolvedFormMatrix.hh QcSparseMatrixIterator.hh QcSparseMatrixRowIterator.hh QcMatrixIterator.hh QcOrigRowState.hh QcQuasiColState.hh QcQuasiRowState.hh QcSparseMatrix.hh QcStateVector.hh QcIterator.hh QcSparseMatrixElement.hh QcState.hh QcUnsortedListSet.hh QcVarStow.H
dist_libqoca_sources = QcASetSolver.H QcASetSolver.hh QcASetSolver.$(cc) QcCassSolver.cc QcCompPivotSystem.cc QcCompPivotTableau.cc QcConstraintRep.cc QcCoreTableau.cc QcDelCoreTableau.cc QcDelLinEqTableau.cc QcDelLinInEqTableau.cc QcDenseMatrix.cc QcFloatRep.cc QcIneqSolverBase.H QcIneqSolverBase.hh QcIneqSolverBase.$(cc) QcLinEqSolver.cc QcLinEqSystem.cc QcLinEqTableau.cc QcLinInEqSolver.cc QcLinInEqSystem.cc QcLinInEqTableau.cc QcLinPoly.cc QcSolver.cc QcSparseMatrix.cc KeyIterator.hh QcAliasedBiMap.H QcAliasedBiMap.hh QcBasicnessVarIndexIterator.hh QcBasicVarIndexIterator.hh QcBiMap.H QcBiMap.hh QcBiMapNotifier.hh QcCassConstraint.hh QcCassSolver.hh QcCompPivotSystem.hh QcCompPivotTableau.hh QcConstraint.hh QcConstraintBiMap.hh QcConstraintIndexIterator.hh QcConstraintRep.hh QcCoreTableau.hh QcDefines.hh QcDelCoreTableau.hh QcDelLinEqSystem.hh QcDelLinEqTableau.hh QcDelLinInEqSystem.hh QcDelLinInEqTableau.hh QcDenseMatrix.hh QcDenseMatrixColIterator.hh QcDenseMatrixIterator.hh QcDenseMatrixRowIterator.hh QcDenseTableauColIterator.hh QcDenseTableauIterator.hh QcDenseTableauRowIterator.hh QcDesireValueStore.hh QcException.hh QcFixedFloat.hh QcFixedFloatRep.cc QcFixedFloatRep.hh QcFloat.hh QcFloatRep.hh QcIterator.hh QcLinEqColState.hh QcLinEqColStateVector.H QcLinEqColStateVector.hh QcLinEqColStateVector.$(cc) QcLinEqRowColStateVector.hh QcLinEqRowState.hh QcLinEqRowStateVector.H QcLinEqRowStateVector.hh QcLinEqRowStateVector.$(cc) QcLinEqSolver.hh QcLinEqSystem.hh QcLinEqTableau.hh QcLinInEqColState.hh QcLinInEqColStateVector.H QcLinInEqColStateVector.hh QcLinInEqColStateVector.$(cc) QcLinInEqRowColStateVector.H QcLinInEqRowColStateVector.hh QcLinInEqRowColStateVector.$(cc) QcLinInEqSolver.hh QcLinInEqSystem.hh QcLinInEqTableau.hh QcLinPoly.hh QcLinPolyTerm.hh QcMatrix.hh QcMatrixIterator.hh QcOrigRowState.hh QcNlpSolver.H QcNlpSolver.hh QcNlpSolver.$(cc) QcNomadicFloatRep.cc QcNomadicFloatRep.hh QcNullIterator.H QcNullableConstraint.hh QcNullableElement.hh QcNullableFloat.hh QcOrigRowStateVector.H QcOrigRowStateVector.hh QcOrigRowStateVector.cc QcParamVarIndexIterator.hh QcQuasiColState.hh QcQuasiColStateVector.hh QcQuasiRowColStateVector.H QcQuasiRowColStateVector.hh QcQuasiRowColStateVector.$(cc) QcRowAdaptor.hh QcQuasiRowStateVector.H QcQuasiRowStateVector.hh QcQuasiRowStateVector.cc QcQuasiRowState.hh QcSolvedFormMatrix.hh QcSolver.hh QcSparseCoeff.hh QcSparseMatrix.hh QcSparseMatrixColIterator.hh QcSparseMatrixElement.hh QcSparseMatrixIterator.hh QcSparseMatrixRowIterator.hh QcState.hh QcStateVector.hh QcStructVarIndexIterator.hh QcTableau.hh QcTableauColIterator.hh QcTableauRowIterator.hh QcUnsortedListSet.hh QcUtility.hh QcVarStow.H QcVarStow.hh QcVarStow.$(cc) QcVariableBiMap.H QcVariableBiMap.hh QcVariableBiMap.$(cc) QcVariableIndexIterator.hh arith.H
ch_files = QcAliasedBiMap.ch QcASetSolver.ch QcBiMap.ch QcFixedFloatRep.ch QcFloatRep.ch QcIneqSolverBase.ch QcLinEqColStateVector.ch QcLinEqRowStateVector.ch QcLinInEqColStateVector.ch QcLinInEqRowColStateVector.ch QcNlpSolver.ch QcNomadicFloatRep.ch QcNullIterator.ch QcOrigRowStateVector.ch QcQuasiRowColStateVector.ch QcQuasiRowStateVector.ch QcSolver.ch QcVariableBiMap.ch QcVarStow.ch arith.ch
libqoca_la_SOURCES =
# Rationale for emptiness: If it has any .cc files, then automake
# produces .cc.o rules, which stuffs things up (because make sometimes
# tries to use them directly instead of using the .ii0.o rule). If it
# had .ii0 files, then the .ii0 files would be put into distdir, which
# is wrong because .ii0 files contain system header file contents.
EXTRA_DIST = $(dist_libqoca_sources) Makefile.am.m4 $(ch_files)
CLEANFILES = *.ii *.ii0
DISTCLEANFILES = -r .deps
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_CLEAN_FILES = QcEnables.H
LTLIBRARIES = $(lib_LTLIBRARIES)
DEFS = @DEFS@ -I. -I$(srcdir)
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
libqoca_la_DEPENDENCIES =
libqoca_la_OBJECTS =
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
HEADERS = $(pkginclude_HEADERS)
DIST_COMMON = ChangeLog Makefile.am Makefile.in QcEnables.H.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar
GZIP_ENV = --best
SOURCES = $(libqoca_la_SOURCES)
OBJECTS = $(libqoca_la_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .H .S .c .cc .ch .hh .ii0 .lo .o .s
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps cxx/qoca/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
QcEnables.H: $(top_builddir)/config.status QcEnables.H.in
cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
mostlyclean-libLTLIBRARIES:
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
distclean-libLTLIBRARIES:
maintainer-clean-libLTLIBRARIES:
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(libdir)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
if test -f $$p; then \
echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \
$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \
else :; fi; \
done
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
list='$(lib_LTLIBRARIES)'; for p in $$list; do \
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
done
.c.o:
$(COMPILE) -c $<
.s.o:
$(COMPILE) -c $<
.S.o:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core *.core
clean-compile:
distclean-compile:
-rm -f *.tab.c
maintainer-clean-compile:
.c.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
.s.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
.S.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
maintainer-clean-libtool:
install-pkgincludeHEADERS: $(pkginclude_HEADERS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(pkgincludedir)
@list='$(pkginclude_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(pkgincludedir)/$$p"; \
$(INSTALL_DATA) $$d$$p $(DESTDIR)$(pkgincludedir)/$$p; \
done
uninstall-pkgincludeHEADERS:
@$(NORMAL_UNINSTALL)
list='$(pkginclude_HEADERS)'; for p in $$list; do \
rm -f $(DESTDIR)$(pkgincludedir)/$$p; \
done
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = cxx/qoca
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
$(MAKE) $(AM_MAKEFLAGS) top_distdir="$(top_distdir)" distdir="$(distdir)" dist-hook
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am: install-libLTLIBRARIES
install-exec: install-exec-am
install-data-am: install-pkgincludeHEADERS
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-libLTLIBRARIES uninstall-pkgincludeHEADERS
uninstall: uninstall-am
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(pkgincludedir)
mostlyclean-generic:
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
maintainer-clean-generic:
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
mostlyclean-am: mostlyclean-libLTLIBRARIES mostlyclean-compile \
mostlyclean-libtool mostlyclean-tags \
mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-libLTLIBRARIES clean-compile clean-libtool clean-tags \
clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-libLTLIBRARIES distclean-compile \
distclean-libtool distclean-tags distclean-generic \
clean-am
-rm -f libtool
distclean: distclean-am
maintainer-clean-am: maintainer-clean-libLTLIBRARIES \
maintainer-clean-compile maintainer-clean-libtool \
maintainer-clean-tags maintainer-clean-generic \
distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \
clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \
uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \
distclean-compile clean-compile maintainer-clean-compile \
mostlyclean-libtool distclean-libtool clean-libtool \
maintainer-clean-libtool uninstall-pkgincludeHEADERS \
install-pkgincludeHEADERS tags mostlyclean-tags distclean-tags \
clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \
check-am installcheck-am installcheck install-exec-am install-exec \
install-data-am install-data install-am install uninstall-am uninstall \
all-redirect all-am all installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
mostlyclean distclean maintainer-clean
$(srcdir)/Makefile.am: Makefile.am.m4
rm -f $(srcdir)/$(@F)
m4 -P $(srcdir)/$(<F) > $(srcdir)/$(@F)
.ch.cc: $(CH2XX)
@rm -f $(bsrcdir)/$(*F).cc && if echo "$(CH2XX) -c $< > $(bsrcdir)/$(*F).cc" \
&& $(CH2XX) -c $< > $(bsrcdir)/$(*F).cc; \
then :; \
else echo "rm -f $(bsrcdir)/$(*F).cc; exit 1" \
&& rm -f $(bsrcdir)/$(*F).cc; exit 1; fi
.ch.hh: $(CH2XX)
@rm -f $(bsrcdir)/$(*F).hh && if echo "$(CH2XX) -i $< > $(bsrcdir)/$(*F).hh" \
&& $(CH2XX) -i $< > $(bsrcdir)/$(*F).hh; \
then :; \
else echo "rm -f $(bsrcdir)/$(*F).hh; exit 1" \
&& rm -f $(bsrcdir)/$(*F).hh; exit 1; fi
.ch.H: $(CH2XX)
@rm -f $(bsrcdir)/$(*F).H && if echo "$(CH2XX) -d $< > $(bsrcdir)/$(*F).H" \
&& $(CH2XX) -d $< > $(bsrcdir)/$(*F).H; \
then :; \
else echo "rm -f $(bsrcdir)/$(*F).H; exit 1" \
&& rm -f $(bsrcdir)/$(*F).H; exit 1; fi
.cc.ii0:
@rm -f $(bsrcdir)/$(@F) && if echo "$(CXXCPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -Wp,-MD,.deps/$(*F).pp $< > $(bsrcdir)/$(@F)" \
&& $(CXXCPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -Wp,-MD,.deps/$(*F).pp $< > $(bsrcdir)/$(@F); \
then :; \
else echo "rm -f $(bsrcdir)/$(@F); exit 1" \
&& rm -f $(bsrcdir)/$(@F); exit 1; fi
@rm -f .deps/$(*F).P
@-sed 's/\.o/.ii0/g' < .deps/$(*F).pp > .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm .deps/$(*F).pp
libqoca.la: $(ii0_files) $(libqoca_la_myOBJECTS) $(libqoca_la_DEPENDENCIES)
$(CXXLINK) -rpath $(libdir) $(libqoca_la_LDFLAGS) $(libqoca_la_myOBJECTS) $(libqoca_la_LIBADD) $(LIBS)
.ii0.o:
@if test -f $@ && cmp -s $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii 2>/dev/null; then :; else \
echo "cp $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii" \
&& cp $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii && \
echo "$(CXXCOMPILE) -c $(bsrcdir)/$(*F).ii" \
&& $(CXXCOMPILE) -c $(bsrcdir)/$(*F).ii; \
fi
.ii0.lo:
@if test -f $@ && cmp -s $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii 2>/dev/null; then :; else \
echo "cp $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii" \
&& cp $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii && \
echo "$(LTCXXCOMPILE) -c $(bsrcdir)/$(*F).ii" \
&& $(LTCXXCOMPILE) -c $(bsrcdir)/$(*F).ii; \
fi
dist-hook:
@rm -f $(distdir)/Makefile.tmp
grep -v '^-include ' < $(distdir)/Makefile.in > $(distdir)/Makefile.tmp
mv $(distdir)/Makefile.tmp $(distdir)/Makefile.in
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -1,35 +0,0 @@
// Generated automatically from QcASetSolver.ch by /home/pmoulder/usr/local/bin/ch2xx.
#ifndef QcASetSolverDCL
#define QcASetSolverDCL
#line 1 "QcASetSolver.ch"
#include <qoca/QcSolver.H>
class QcASetSolver
: public QcSolver
{
public:
inline
QcASetSolver();
#line 15 "QcASetSolver.ch"
inline
QcASetSolver(unsigned hintNumConstraints, unsigned hintNumVariables);
#line 22 "QcASetSolver.ch"
virtual ~QcASetSolver()
{
}
};
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/
#endif /* !QcASetSolverDCL */

View File

@ -1,20 +0,0 @@
// Generated automatically from QcASetSolver.ch by /home/pmoulder/usr/local/bin/ch2xx.
#include "QcASetSolver.hh"
#line 1 "QcASetSolver.ch"
#include <qoca/QcSolver.hh>
#line 29 "QcASetSolver.ch"
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/

View File

@ -1,36 +0,0 @@
//o[d] #include <qoca/QcSolver.H>
//o[ci] #include <qoca/QcSolver.hh>
//ho class QcASetSolver
//ho : public QcSolver
//ho {
//ho public:
inline
QcASetSolver()
: QcSolver()
{
}
inline
QcASetSolver(unsigned hintNumConstraints, unsigned hintNumVariables)
: QcSolver()
{
}
//begin ho
virtual ~QcASetSolver()
{
}
//end ho
//ho };
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/

View File

@ -1,37 +0,0 @@
// Generated automatically from QcASetSolver.ch by /home/pmoulder/usr/local/bin/ch2xx.
#include "QcASetSolver.H"
#ifndef QcASetSolverIFN
#define QcASetSolverIFN
#line 1 "QcASetSolver.ch"
#include <qoca/QcSolver.hh>
inline
QcASetSolver::QcASetSolver()
: QcSolver()
{
}
inline
QcASetSolver::QcASetSolver(unsigned hintNumConstraints, unsigned hintNumVariables)
: QcSolver()
{
}
#line 29 "QcASetSolver.ch"
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/
#endif /* !QcASetSolverIFN */

View File

@ -1,72 +0,0 @@
// Generated automatically from QcAliasedBiMap.ch by /home/pmoulder/usr/local/bin/ch2xx.
#ifndef QcAliasedBiMapDCL
#define QcAliasedBiMapDCL
#line 1 "QcAliasedBiMap.ch"
#include <qoca/QcBiMap.H>
#line 11 "QcAliasedBiMap.ch"
#define TMPL template<class NullableT, class ExternalT, class PointedToT>
TMPL
class QcAliasedBiMap
: public QcBiMap<NullableT>
{
public:
QcAliasedBiMap() { }
inline void
Update(ExternalT const &ident, int index);
#line 33 "QcAliasedBiMap.ch"
inline void
Update(PointedToT *ident, int index);
#line 41 "QcAliasedBiMap.ch"
inline bool
IdentifierPresent(ExternalT const &ident) const;
#line 48 "QcAliasedBiMap.ch"
inline bool
IdentifierPtrPresent(PointedToT *ident) const;
#line 55 "QcAliasedBiMap.ch"
inline ExternalT &
Identifier(int index);
#line 67 "QcAliasedBiMap.ch"
inline ExternalT &
Identifier(char const *n);
#line 79 "QcAliasedBiMap.ch"
inline PointedToT *
getIdentifierPtr(int index);
#line 87 "QcAliasedBiMap.ch"
inline int
Index(ExternalT const &ident) const;
#line 94 "QcAliasedBiMap.ch"
inline int
Index(PointedToT *ident) const;
#line 101 "QcAliasedBiMap.ch"
inline int
safeIndex(ExternalT const &ident) const;
#line 108 "QcAliasedBiMap.ch"
inline int
safeIndex(PointedToT *ident) const;
#line 114 "QcAliasedBiMap.ch"
};
#undef TMPL
#undef A2E
#undef const_E2A
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/
#endif /* !QcAliasedBiMapDCL */

View File

@ -1,127 +0,0 @@
//begin o[d]
#include <qoca/QcBiMap.H>
//end o[d]
//begin o[i]
#include <qoca/QcBiMap.hh>
#define A2E(_nkey) *((ExternalT *)((void *)&(_nkey)))
#define const_E2A(_ekey) reinterpret_cast<NullableT const &>(_ekey)
//end o[i]
#define TMPL template<class NullableT, class ExternalT, class PointedToT>
//o[d] TMPL
//o[d] class QcAliasedBiMap
//o[d] : public QcBiMap<NullableT>
//o[d] {
//$class_prefix = QcAliasedBiMap<NullableT, ExternalT, PointedToT>::
//begin o[d]
public:
QcAliasedBiMap() { }
//end o[d]
//o[i] TMPL
inline void
Update(ExternalT const &ident, int index)
{
qcAssertPre( ident.pointer() != 0);
QcBiMap<NullableT>::Update(const_E2A(ident), index);
}
//o[i] TMPL
inline void
Update(PointedToT *ident, int index)
{
qcAssertPre( ident != 0);
QcBiMap<NullableT>::Update( NullableT( ident), index);
}
//o[i] TMPL
inline bool
IdentifierPresent(ExternalT const &ident) const
{
return QcBiMap<NullableT>::IdentifierPresent(const_E2A(ident));
}
//o[i] TMPL
inline bool
IdentifierPtrPresent(PointedToT *ident) const
{
return QcBiMap<NullableT>::IdentifierPresent( NullableT( ident));
}
//o[i] TMPL
inline ExternalT &
Identifier(int index)
{
NullableT &nid = QcBiMap<NullableT>::Identifier( index);
NullableT *nidp = &nid;
void *vp = nidp;
ExternalT *ep = (ExternalT *) vp;
ExternalT &eid = *ep;
return eid;
}
//o[i] TMPL
inline ExternalT &
Identifier(char const *n)
{
NullableT &nid = QcBiMap<NullableT>::Identifier( n);
NullableT *nidp = &nid;
void *vp = nidp;
ExternalT *ep = (ExternalT *) vp;
ExternalT &eid = *ep;
return eid;
}
//o[i] TMPL
inline PointedToT *
getIdentifierPtr(int index)
{
NullableT &nid = QcBiMap<NullableT>::Identifier( index);
return nid.pointer();
}
//o[i] TMPL
inline int
Index(ExternalT const &ident) const
{
return QcBiMap<NullableT>::Index(const_E2A(ident));
}
//o[i] TMPL
inline int
Index(PointedToT *ident) const
{
return QcBiMap<NullableT>::Index( NullableT( ident));
}
//o[i] TMPL
inline int
safeIndex(ExternalT const &ident) const
{
return QcBiMap<NullableT>::safeIndex(const_E2A(ident));
}
//o[i] TMPL
inline int
safeIndex(PointedToT *ident) const
{
return QcBiMap<NullableT>::safeIndex( NullableT( ident));
}
//o[d] };
#undef TMPL
#undef A2E
#undef const_E2A
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/

View File

@ -1,129 +0,0 @@
// Generated automatically from QcAliasedBiMap.ch by /home/pmoulder/usr/local/bin/ch2xx.
#include "QcAliasedBiMap.H"
#ifndef QcAliasedBiMapIFN
#define QcAliasedBiMapIFN
#line 1 "QcAliasedBiMap.ch"
#line 5 "QcAliasedBiMap.ch"
#include <qoca/QcBiMap.hh>
#define A2E(_nkey) *((ExternalT *)((void *)&(_nkey)))
#define const_E2A(_ekey) reinterpret_cast<NullableT const &>(_ekey)
#define TMPL template<class NullableT, class ExternalT, class PointedToT>
#line 24 "QcAliasedBiMap.ch"
TMPL
inline void
QcAliasedBiMap<NullableT, ExternalT, PointedToT>::Update(ExternalT const &ident, int index)
{
qcAssertPre( ident.pointer() != 0);
QcBiMap<NullableT>::Update(const_E2A(ident), index);
}
TMPL
inline void
QcAliasedBiMap<NullableT, ExternalT, PointedToT>::Update(PointedToT *ident, int index)
{
qcAssertPre( ident != 0);
QcBiMap<NullableT>::Update( NullableT( ident), index);
}
TMPL
inline bool
QcAliasedBiMap<NullableT, ExternalT, PointedToT>::IdentifierPresent(ExternalT const &ident) const
{
return QcBiMap<NullableT>::IdentifierPresent(const_E2A(ident));
}
TMPL
inline bool
QcAliasedBiMap<NullableT, ExternalT, PointedToT>::IdentifierPtrPresent(PointedToT *ident) const
{
return QcBiMap<NullableT>::IdentifierPresent( NullableT( ident));
}
TMPL
inline ExternalT &
QcAliasedBiMap<NullableT, ExternalT, PointedToT>::Identifier(int index)
{
NullableT &nid = QcBiMap<NullableT>::Identifier( index);
NullableT *nidp = &nid;
void *vp = nidp;
ExternalT *ep = (ExternalT *) vp;
ExternalT &eid = *ep;
return eid;
}
TMPL
inline ExternalT &
QcAliasedBiMap<NullableT, ExternalT, PointedToT>::Identifier(char const *n)
{
NullableT &nid = QcBiMap<NullableT>::Identifier( n);
NullableT *nidp = &nid;
void *vp = nidp;
ExternalT *ep = (ExternalT *) vp;
ExternalT &eid = *ep;
return eid;
}
TMPL
inline PointedToT *
QcAliasedBiMap<NullableT, ExternalT, PointedToT>::getIdentifierPtr(int index)
{
NullableT &nid = QcBiMap<NullableT>::Identifier( index);
return nid.pointer();
}
TMPL
inline int
QcAliasedBiMap<NullableT, ExternalT, PointedToT>::Index(ExternalT const &ident) const
{
return QcBiMap<NullableT>::Index(const_E2A(ident));
}
TMPL
inline int
QcAliasedBiMap<NullableT, ExternalT, PointedToT>::Index(PointedToT *ident) const
{
return QcBiMap<NullableT>::Index( NullableT( ident));
}
TMPL
inline int
QcAliasedBiMap<NullableT, ExternalT, PointedToT>::safeIndex(ExternalT const &ident) const
{
return QcBiMap<NullableT>::safeIndex(const_E2A(ident));
}
TMPL
inline int
QcAliasedBiMap<NullableT, ExternalT, PointedToT>::safeIndex(PointedToT *ident) const
{
return QcBiMap<NullableT>::safeIndex( NullableT( ident));
}
#undef TMPL
#undef A2E
#undef const_E2A
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/
#endif /* !QcAliasedBiMapIFN */

View File

@ -1,69 +0,0 @@
// $Id: QcBasicVarIndexIterator.hh,v 1.5 2000/11/29 01:58:42 pmoulder Exp $
//============================================================================//
// Written by Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcBasicVarIndexIteratorH
#define __QcBasicVarIndexIteratorH
#include <qoca/QcBasicnessVarIndexIterator.hh>
class QcBasicVarIndexIterator
: public QcBasicnessVarIndexIterator
{
public:
//------------------------------------------------------------------------//
// Constructor. //
//------------------------------------------------------------------------//
QcBasicVarIndexIterator( const QcLinEqTableau &tab)
: QcBasicnessVarIndexIterator( &tab.GetColState().fBasicHead)
{
}
void Reset()
{
QcBasicnessVarIndexIterator::Reset();
qcAssertPost( fCurrent->isBasic());
}
void Increment()
{
QcBasicnessVarIndexIterator::Increment();
qcAssertPost( fCurrent->isBasic());
}
/** @precondition <tt>!AtEnd()</tt>
@postcondition <tt>(int) ret</tt> &ge; 0
**/
unsigned getConstraintBasicIn() const
{
qcAssertPre (!AtEnd());
int ret = fCurrent->getConstraintBasicIn();
qcAssertPost (ret >= 0);
return (unsigned) ret;
}
};
#endif /* !__QcBasicVarIndexIteratorH */

View File

@ -1,86 +0,0 @@
// $Id: QcBasicnessVarIndexIterator.hh,v 1.1 2000/11/29 01:58:42 pmoulder Exp $
//============================================================================//
// Written by Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcBasicnessVarIndexIteratorH
#define __QcBasicnessVarIndexIteratorH
class QcBasicnessVarIndexIterator
{
public:
//------------------------------------------------------------------------//
// Constructor. //
//------------------------------------------------------------------------//
QcBasicnessVarIndexIterator (QcLinEqColState const *head);
//------------------------------------------------------------------------//
// Iteration functions. //
//------------------------------------------------------------------------//
bool AtEnd() const
{
return (fCurrent == fHead);
}
/** @precondition <tt>!AtEnd()</tt>
@postcondition <tt>(int) ret</tt> &ge; 0
**/
unsigned getIndex() const
{
qcAssertPre (!AtEnd());
unsigned ret = fCurrent->fIndex;
qcAssertPost ((int) ret >= 0);
return ret;
}
void Increment()
{
qcAssertPre (!AtEnd());
fCurrent = fCurrent->getNextBasicnessCol();
}
void Reset()
{
fCurrent = fHead->getNextBasicnessCol();
}
protected:
QcLinEqColState const *fCurrent;
private:
QcLinEqColState const *fHead;
};
inline
QcBasicnessVarIndexIterator::QcBasicnessVarIndexIterator (QcLinEqColState const *head)
: fHead (head)
{
Reset();
}
#endif /* !__QcBasicnessVarIndexIteratorH */

View File

@ -1,196 +0,0 @@
// Generated automatically from QcBiMap.ch by /home/pmoulder/usr/local/bin/ch2xx.
#ifndef QcBiMapDCL
#define QcBiMapDCL
#line 1 "QcBiMap.ch"
#include <iostream>
#include <map>
#include <vector>
#include "qoca/QcDefines.hh"
#include "qoca/KeyIterator.hh"
using namespace std;
/** Bi-directional one-to-one mapping between identifier class and non-negative
integers.
@invariant &forall;[ix &isin; indexes] ix &ge; 0
@invariant &forall;[id &isin; idents] index(id) &isin; indexes
@invariant &forall;[ix &isin; indexes] identifier(ix) &isin; idents
@invariant &neg;&exist;[i &ne; j] {i, j} &subeq; indexes &and; identifier(i) = identifier(j)
@invariant &neg;&exist;[i &ne; j] {i, j} &subeq; idents &and; index(i) = index(j)
@invariant &forall;[ix &isin; indexes] index(identifier(ix)) = ix
@invariant &forall;[id &isin; idents] identifier(index(id)) = id
**/
template<typename AKey>
class QcBiMap
{
public:
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcBiMap()
{ }
virtual ~QcBiMap() { }
#ifndef NDEBUG
inline void
assertInvar() const;
#line 63 "QcBiMap.ch"
inline void
assertDeepInvar() const;
#line 70 "QcBiMap.ch"
virtual inline void
vAssertDeepInvar() const;
#line 75 "QcBiMap.ch"
#endif
protected:
typedef std::map<AKey, int, less<AKey> > TIdentifierMap;
typedef std::vector<AKey> TIndexMap;
public:
typedef KeyIterator<typename TIdentifierMap::const_iterator, AKey> const_identifier_iterator;
//-----------------------------------------------------------------------//
// BiMap manipulation functions. //
//-----------------------------------------------------------------------//
/** Remove item with index <tt>index</tt>.
@precondition <tt>index</tt> is currently in this bimap.
**/
inline void
EraseByIndex(int index);
#line 107 "QcBiMap.ch"
/** Erase everything ready to start afresh. */
inline void
Restart();
#line 117 "QcBiMap.ch"
/** Swap the mappings around so that {ix1 &harr; id1, ix2 &harr; id2}
becomes {ix1 &harr; id2, ix2 &harr; id1}.
@precondition <tt>ix1</tt> and <tt>ix2</tt> are both present in this
bimap.
**/
inline void
SwapByIndex(int i1, int i2);
#line 147 "QcBiMap.ch"
/** Insert the mapping <tt>ident</tt> &harr; <tt>index</tt> into this
bimap.
@precondition <tt>index</tt> &ge; 0
@precondition Neither <tt>index</tt> nor <tt>ident</tt> is currently
in this bimap.
@postcondition <tt>identifier(index) == ident</tt>
@postcondition <tt>index(ident) == index</tt>
**/
inline void
Update(const AKey &ident, int index);
#line 184 "QcBiMap.ch"
//-----------------------------------------------------------------------//
// Query functions. //
//-----------------------------------------------------------------------//
/** Number of entries. */
unsigned GetSize() const
{ return fIdentifierMap.size(); }
bool IdentifierPresent(AKey const &ident) const
{ return (fIdentifierMap.find(ident) != fIdentifierMap.end()); }
const_identifier_iterator
getIdentifiers_begin() const
{
typename TIdentifierMap::const_iterator i = fIdentifierMap.begin();
return const_identifier_iterator (i);
}
const_identifier_iterator getIdentifiers_end() const
{ return const_identifier_iterator (fIdentifierMap.end()); }
inline AKey &
Identifier(int index);
#line 220 "QcBiMap.ch"
inline AKey &
Identifier(char const *n);
#line 237 "QcBiMap.ch"
/** Return the index associated with <tt>ident</tt>.
@precondition <tt>IdentifierPresent(ident)</tt>
@postcondition ret &ge; 0.
**/
inline int
Index(AKey const &ident) const;
#line 255 "QcBiMap.ch"
/** Return the index associated with <tt>ident</tt>,
or -1 if <tt>ident</tt> is not present.
@postcondition <tt>IdentifierPresent(ident)</tt> &hArr; (ret &ge; 0)
**/
inline int
safeIndex(AKey const &ident) const;
#line 273 "QcBiMap.ch"
//-----------------------------------------------------------------------//
// Utility functions. //
//-----------------------------------------------------------------------//
#ifndef qcNoStream
inline void
Print(ostream &os) const;
#line 294 "QcBiMap.ch"
#endif /* !qcNoStream */
protected:
TIdentifierMap fIdentifierMap; // AKey -> int
TIndexMap fIndexMap; // int -> AKey
};
#ifndef qcNoStream
template<class AKey>
ostream &operator<<(ostream &os, const QcBiMap<AKey> &bm)
{
bm.Print(os);
return os;
}
#endif /* !qcNoStream */
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/
#endif /* !QcBiMapDCL */

View File

@ -1,324 +0,0 @@
//begin o[d]
#include <iostream>
#include <map>
#include <vector>
#include "qoca/QcDefines.hh"
#include "qoca/KeyIterator.hh"
//end o[d]
/** Bi-directional one-to-one mapping between identifier class and non-negative
integers.
@invariant &forall;[ix &isin; indexes] ix &ge; 0
@invariant &forall;[id &isin; idents] index(id) &isin; indexes
@invariant &forall;[ix &isin; indexes] identifier(ix) &isin; idents
@invariant &neg;&exist;[i &ne; j] {i, j} &subeq; indexes &and; identifier(i) = identifier(j)
@invariant &neg;&exist;[i &ne; j] {i, j} &subeq; idents &and; index(i) = index(j)
@invariant &forall;[ix &isin; indexes] index(identifier(ix)) = ix
@invariant &forall;[id &isin; idents] identifier(index(id)) = id
**/
//o[ci] #define TMPL template<class AKey>
//o[d] template<class AKey>
//o[d] class QcBiMap
//o[d] {
//$class_prefix = QcBiMap<AKey>::
//begin o[d]
public:
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcBiMap()
{ }
virtual ~QcBiMap() { }
//end o[d]
#ifndef NDEBUG
//o[i] TMPL
inline void
assertInvar() const
{
for(int i = fIndexMap.size(); --i >= 0;)
{
fIndexMap[ i].assertInvar();
if(fIndexMap[ i].isDead())
continue;
typename TIdentifierMap::const_iterator f = fIdentifierMap.find(fIndexMap[i]);
qcAssertInvar( f != fIdentifierMap.end());
qcAssertInvar( f->second == i);
}
for(typename TIdentifierMap::const_iterator ii = fIdentifierMap.begin(); ii != fIdentifierMap.end(); ii++)
{
unsigned ix = ii->second;
qcAssertInvar( ix < fIndexMap.size());
qcAssertInvar( fIndexMap[ ix] == ii->first);
}
}
//o[i] TMPL
inline void
assertDeepInvar() const
{
assertInvar();
}
//o[i] TMPL
virtual inline void
vAssertDeepInvar() const
{
assertDeepInvar();
}
#endif
//begin o[d]
protected:
typedef map<AKey, int, less<AKey> > TIdentifierMap;
typedef vector<AKey> TIndexMap;
public:
typedef KeyIterator<typename TIdentifierMap::const_iterator, AKey> const_identifier_iterator;
//end o[d]
//-----------------------------------------------------------------------//
// BiMap manipulation functions. //
//-----------------------------------------------------------------------//
/** Remove item with index <tt>index</tt>.
@precondition <tt>index</tt> is currently in this bimap.
**/
//o[i] TMPL
inline void
EraseByIndex(int index)
{
qcAssertPre( unsigned( index) < fIndexMap.size());
AKey &ident = fIndexMap[ index];
qcAssertPre( ident.notDead());
fIdentifierMap.erase( ident);
qcAssertPost( ident.notDead());
ident.Decrease();
}
/** Erase everything ready to start afresh. */
//o[i] TMPL
inline void
Restart()
{
fIdentifierMap.clear();
fIndexMap.clear();
}
/** Swap the mappings around so that {ix1 &harr; id1, ix2 &harr; id2}
becomes {ix1 &harr; id2, ix2 &harr; id1}.
@precondition <tt>ix1</tt> and <tt>ix2</tt> are both present in this
bimap.
**/
//o[i] TMPL
inline void
SwapByIndex(int i1, int i2)
{
qcAssertPre( unsigned( i1) < fIndexMap.size());
qcAssertPre( unsigned( i2) < fIndexMap.size());
AKey ident1 = fIndexMap[ i1];
AKey ident2 = fIndexMap[ i2];
qcAssertPre( ident1.notDead());
qcAssertPre( ident2.notDead());
fIndexMap[ i1] = ident2;
fIndexMap[ i2] = ident1;
typename QcBiMap<AKey>::TIdentifierMap::iterator it1 = fIdentifierMap.find( ident1);
qcAssertPost( it1 != fIdentifierMap.end());
it1->second = i2;
typename QcBiMap<AKey>::TIdentifierMap::iterator it2 = fIdentifierMap.find( ident2);
qcAssertPost( it2 != fIdentifierMap.end());
it2->second = i1;
}
/** Insert the mapping <tt>ident</tt> &harr; <tt>index</tt> into this
bimap.
@precondition <tt>index</tt> &ge; 0
@precondition Neither <tt>index</tt> nor <tt>ident</tt> is currently
in this bimap.
@postcondition <tt>identifier(index) == ident</tt>
@postcondition <tt>index(ident) == index</tt>
**/
//o[i] TMPL
inline void
Update(const AKey &ident, int index)
{
if(index >= (int) fIndexMap.size())
fIndexMap.resize( (index * 2) + 1);
else
{
qcAssertPre( index >= 0);
qcAssertPre( fIndexMap[ index].isDead()); // index not present
}
// Insert index->ident mapping.
fIndexMap[ index] = ident;
// Insert ident->index mapping.
TIdentifierMap::value_type ins (ident, index);
typedef pair<TIdentifierMap::iterator, bool> insResultT;
dbgPre(insResultT insResult =)
fIdentifierMap.insert (ins);
qcAssertPre (insResult.second); // assert that ident wasn't present
qcAssertPost (Identifier (index) == ident);
qcAssertPost (safeIndex (ident) == index);
}
//-----------------------------------------------------------------------//
// Query functions. //
//-----------------------------------------------------------------------//
//begin o[d]
/** Number of entries. */
unsigned GetSize() const
{ return fIdentifierMap.size(); }
bool IdentifierPresent(AKey const &ident) const
{ return (fIdentifierMap.find(ident) != fIdentifierMap.end()); }
const_identifier_iterator
getIdentifiers_begin() const
{
typename TIdentifierMap::const_iterator i = fIdentifierMap.begin();
return const_identifier_iterator (i);
}
const_identifier_iterator getIdentifiers_end() const
{ return const_identifier_iterator (fIdentifierMap.end()); }
//end o[d]
//o[i] TMPL
inline AKey &
Identifier(int index)
{
qcAssertPre( unsigned( index) < fIndexMap.size());
qcAssertPre( fIndexMap[ index].notDead());
return fIndexMap[ index];
}
//o[i] TMPL
inline AKey &
Identifier(char const *n)
{
typename QcBiMap<AKey>::TIdentifierMap::iterator iIt = fIdentifierMap.begin();
while(iIt != fIdentifierMap.end())
{
AKey const &id = iIt->first;
if(strcmp( id.Name(), n) == 0)
return const_cast<AKey &>( id);
iIt++;
}
throw QcWarning("Identifier cannot be found");
}
/** Return the index associated with <tt>ident</tt>.
@precondition <tt>IdentifierPresent(ident)</tt>
@postcondition ret &ge; 0.
**/
//o[i] TMPL
inline int
Index(AKey const &ident) const
{
typename QcBiMap<AKey>::TIdentifierMap::const_iterator iIt = fIdentifierMap.find( ident);
qcAssertPre( iIt != fIdentifierMap.end());
unsigned ix = iIt->second;
qcAssertPost( (ix < fIndexMap.size())
&& (fIndexMap[ix] == ident));
return ix;
}
/** Return the index associated with <tt>ident</tt>,
or -1 if <tt>ident</tt> is not present.
@postcondition <tt>IdentifierPresent(ident)</tt> &hArr; (ret &ge; 0)
**/
//o[i] TMPL
inline int
safeIndex(AKey const &ident) const
{
QcBiMap<AKey>::TIdentifierMap::const_iterator iIt = fIdentifierMap.find( ident);
if(iIt == fIdentifierMap.end())
return -1;
int ix = iIt->second;
qcAssertPost( ix >= 0);
return ix;
}
//-----------------------------------------------------------------------//
// Utility functions. //
//-----------------------------------------------------------------------//
#ifndef qcNoStream
//o[i] TMPL
inline void
Print(ostream &os) const
{
os << "Map start:" << endl;
for (unsigned int i = 0; i < fIndexMap.size(); i++)
os << i << " -> " << fIndexMap[i] << endl;
os << "Reverse Map:" << endl;
QcBiMap<AKey>::TIdentifierMap::const_iterator itF;
for (itF = fIdentifierMap.begin(); itF != fIdentifierMap.end(); ++itF)
os << (*itF).first << " -> " << (*itF).second << endl;
os << "Map end." << endl;
}
#endif /* !qcNoStream */
//begin o[d]
protected:
TIdentifierMap fIdentifierMap; // AKey -> int
TIndexMap fIndexMap; // int -> AKey
//end o[d]
//o[d] };
//begin o[d]
#ifndef qcNoStream
template<class AKey>
ostream &operator<<(ostream &os, const QcBiMap<AKey> &bm)
{
bm.Print(os);
return os;
}
#endif /* !qcNoStream */
//end o[d]
//o[ci] #undef TMPL
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/

View File

@ -1,246 +0,0 @@
// Generated automatically from QcBiMap.ch by /home/pmoulder/usr/local/bin/ch2xx.
#include "QcBiMap.H"
#ifndef QcBiMapIFN
#define QcBiMapIFN
#line 1 "QcBiMap.ch"
#line 21 "QcBiMap.ch"
#define TMPL template<class AKey>
#if __GNUC__ >= 4
#define TYPENAMEDEF typename
#else
#define TYPENAMEDEF
#endif
#line 39 "QcBiMap.ch"
#ifndef NDEBUG
TMPL
inline void
QcBiMap<AKey>::assertInvar() const
{
for(int i = fIndexMap.size(); --i >= 0;)
{
fIndexMap[ i].assertInvar();
if(fIndexMap[ i].isDead())
continue;
TYPENAMEDEF TIdentifierMap::const_iterator f = fIdentifierMap.find(fIndexMap[i]);
qcAssertInvar( f != fIdentifierMap.end());
qcAssertInvar( f->second == i);
}
for(TYPENAMEDEF TIdentifierMap::const_iterator ii = fIdentifierMap.begin(); ii != fIdentifierMap.end(); ii++)
{
unsigned ix = ii->second;
qcAssertInvar( ix < fIndexMap.size());
qcAssertInvar( fIndexMap[ ix] == ii->first);
}
}
TMPL
inline void
QcBiMap<AKey>::assertDeepInvar() const
{
assertInvar();
}
TMPL
inline void
QcBiMap<AKey>::vAssertDeepInvar() const
{
assertDeepInvar();
}
#endif
#line 86 "QcBiMap.ch"
//-----------------------------------------------------------------------//
// BiMap manipulation functions. //
//-----------------------------------------------------------------------//
#line 93 "QcBiMap.ch"
TMPL
inline void
QcBiMap<AKey>::EraseByIndex(int index)
{
qcAssertPre( unsigned( index) < fIndexMap.size());
AKey &ident = fIndexMap[ index];
qcAssertPre( ident.notDead());
fIdentifierMap.erase( ident);
qcAssertPost( ident.notDead());
ident.Decrease();
}
TMPL
inline void
QcBiMap<AKey>::Restart()
{
fIdentifierMap.clear();
fIndexMap.clear();
}
#line 123 "QcBiMap.ch"
TMPL
inline void
QcBiMap<AKey>::SwapByIndex(int i1, int i2)
{
qcAssertPre( unsigned( i1) < fIndexMap.size());
qcAssertPre( unsigned( i2) < fIndexMap.size());
AKey ident1 = fIndexMap[ i1];
AKey ident2 = fIndexMap[ i2];
qcAssertPre( ident1.notDead());
qcAssertPre( ident2.notDead());
fIndexMap[ i1] = ident2;
fIndexMap[ i2] = ident1;
TYPENAMEDEF QcBiMap<AKey>::TIdentifierMap::iterator it1 = fIdentifierMap.find( ident1);
qcAssertPost( it1 != fIdentifierMap.end());
it1->second = i2;
TYPENAMEDEF QcBiMap<AKey>::TIdentifierMap::iterator it2 = fIdentifierMap.find( ident2);
qcAssertPost( it2 != fIdentifierMap.end());
it2->second = i1;
}
#line 156 "QcBiMap.ch"
TMPL
inline void
QcBiMap<AKey>::Update(const AKey &ident, int index)
{
if(index >= (int) fIndexMap.size())
fIndexMap.resize( (index * 2) + 1);
else
{
qcAssertPre( index >= 0);
qcAssertPre( fIndexMap[ index].isDead()); // index not present
}
// Insert index->ident mapping.
fIndexMap[ index] = ident;
// Insert ident->index mapping.
TYPENAMEDEF TIdentifierMap::value_type ins (ident, index);
typedef pair<TYPENAMEDEF TIdentifierMap::iterator, bool> insResultT;
dbgPre(insResultT insResult =)
fIdentifierMap.insert (ins);
qcAssertPre (insResult.second); // assert that ident wasn't present
qcAssertPost (Identifier (index) == ident);
qcAssertPost (safeIndex (ident) == index);
}
//-----------------------------------------------------------------------//
// Query functions. //
//-----------------------------------------------------------------------//
#line 209 "QcBiMap.ch"
TMPL
inline AKey &
QcBiMap<AKey>::Identifier(int index)
{
qcAssertPre( unsigned( index) < fIndexMap.size());
qcAssertPre( fIndexMap[ index].notDead());
return fIndexMap[ index];
}
TMPL
inline AKey &
QcBiMap<AKey>::Identifier(char const *n)
{
TYPENAMEDEF QcBiMap<AKey>::TIdentifierMap::iterator iIt = fIdentifierMap.begin();
while(iIt != fIdentifierMap.end())
{
AKey const &id = iIt->first;
if(strcmp( id.Name(), n) == 0)
return const_cast<AKey &>( id);
iIt++;
}
throw QcWarning("Identifier cannot be found");
}
#line 242 "QcBiMap.ch"
TMPL
inline int
QcBiMap<AKey>::Index(AKey const &ident) const
{
TYPENAMEDEF QcBiMap<AKey>::TIdentifierMap::const_iterator iIt = fIdentifierMap.find( ident);
qcAssertPre( iIt != fIdentifierMap.end());
unsigned ix = iIt->second;
qcAssertPost( (ix < fIndexMap.size())
&& (fIndexMap[ix] == ident));
return ix;
}
#line 260 "QcBiMap.ch"
TMPL
inline int
QcBiMap<AKey>::safeIndex(AKey const &ident) const
{
TYPENAMEDEF QcBiMap<AKey>::TIdentifierMap::const_iterator iIt = fIdentifierMap.find( ident);
if(iIt == fIdentifierMap.end())
return -1;
int ix = iIt->second;
qcAssertPost( ix >= 0);
return ix;
}
//-----------------------------------------------------------------------//
// Utility functions. //
//-----------------------------------------------------------------------//
#ifndef qcNoStream
TMPL
inline void
QcBiMap<AKey>::Print(ostream &os) const
{
os << "Map start:" << endl;
for (unsigned int i = 0; i < fIndexMap.size(); i++)
os << i << " -> " << fIndexMap[i] << endl;
os << "Reverse Map:" << endl;
TYPENAMEDEF QcBiMap<AKey>::TIdentifierMap::const_iterator itF;
for (itF = fIdentifierMap.begin(); itF != fIdentifierMap.end(); ++itF)
os << (*itF).first << " -> " << (*itF).second << endl;
os << "Map end." << endl;
}
#endif /* !qcNoStream */
#line 315 "QcBiMap.ch"
#undef TMPL
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/
#endif /* !QcBiMapIFN */

View File

@ -1,120 +0,0 @@
// $Id: QcBiMapNotifier.hh,v 1.6 2001/01/30 01:32:07 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcBiMapNotifierH
#define __QcBiMapNotifierH
#include "qoca/QcConstraintBiMap.hh"
#include "qoca/QcVariableBiMap.hh"
class QcBiMapNotifier
{
private:
QcConstraintBiMap fOCMap;
QcVariableBiMap fVMap;
public:
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcBiMapNotifier() {}
virtual ~QcBiMapNotifier() {}
#ifndef NDEBUG
void assertDeepInvar() const;
virtual void vAssertDeepInvar() const
{
assertDeepInvar();
}
#endif
//-----------------------------------------------------------------------//
// Query functions. //
//-----------------------------------------------------------------------//
QcConstraintBiMap &GetOCMap()
{ return fOCMap; }
QcVariableBiMap &GetVMap()
{ return fVMap; }
//-----------------------------------------------------------------------//
// Manipulation functions. //
//-----------------------------------------------------------------------//
virtual void DropConstraint(int ci);
virtual void DropVariable(int vi)
{ fVMap.EraseByIndex(vi); }
virtual void SwapVariables(int vi1, int vi2)
{ fVMap.SwapByIndex(vi1, vi2); }
virtual void Restart();
// Restart erases everything ready to start afresh.
//-----------------------------------------------------------------------//
// Utility functions. //
//-----------------------------------------------------------------------//
virtual void Print(ostream &os) const;
};
#ifndef NDEBUG
inline void QcBiMapNotifier::assertDeepInvar() const
{
fOCMap.assertDeepInvar();
fVMap.assertDeepInvar();
}
#endif
inline void QcBiMapNotifier::DropConstraint(int ci)
{
fOCMap.EraseByIndex(ci);
}
inline void QcBiMapNotifier::Print(ostream &os) const
{
os << "Variables:" << endl;
fVMap.Print(os);
os << endl << "Constraints:" << endl;
fOCMap.Print(os);
os << endl;
}
inline void QcBiMapNotifier::Restart()
{
fOCMap.Restart();
fVMap.Restart();
}
#ifndef qcNoStream
inline ostream& operator<<(ostream& os, const QcBiMapNotifier &n)
{
n.Print(os);
return os;
}
#endif
#endif

View File

@ -1,66 +0,0 @@
// $Id: QcCassConstraint.hh,v 1.3 2000/07/27 08:10:04 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcCassConstraintH
#define __QcCassConstraintH
class QcCassConstraint
{
public:
QcFloat fVariable;
QcConstraint fConstraint;
QcFloat fDvp;
QcFloat fDvm;
//-----------------------------------------------------------------------//
// Constructor //
//-----------------------------------------------------------------------//
QcCassConstraint(QcFloat &v, QcConstraint &c, QcFloat &dvp, QcFloat &dvm);
virtual ~QcCassConstraint() { }
//-----------------------------------------------------------------------//
// Utility functions //
//-----------------------------------------------------------------------//
virtual void Print(ostream &os) const;
};
inline QcCassConstraint::QcCassConstraint(QcFloat &v, QcConstraint &c,
QcFloat &dvp, QcFloat &dvm)
: fVariable(v), fConstraint(c), fDvp(dvp), fDvm(dvm)
{
}
inline void QcCassConstraint::Print(ostream &os) const
{
os << "CassConstraint("
<< fVariable << ","
<< fConstraint << ","
<< fDvp << ","
<< fDvm << ")";
}
#endif

View File

@ -1,368 +0,0 @@
// $Id: QcCassSolver.cc,v 1.14 2001/01/04 05:20:11 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include "qoca/QcDefines.hh"
#include "qoca/QcCassSolver.hh"
#include "qoca/QcStructVarIndexIterator.hh"
#include "qoca/QcVariableIndexIterator.hh"
QcCassSolver::~QcCassSolver()
{
// Deallocate memory allocated to Cassowary stay constraints.
TStayMap::iterator sIt = fStayMap.begin();
while (sIt != fStayMap.end()) {
delete (*sIt).second;
sIt++;
}
}
bool QcCassSolver::AddConstraint(QcConstraint &c)
{
const QcLinPoly &lp = c.LinPoly();
const QcLinPoly::TTermsVector &terms = lp.GetTerms();
// For each QcFloat, check if it has already been added as stay
// constraint.
for (unsigned int i = 0; i < terms.size(); i++) {
QcFloat &v = terms[i]->GetVariable();
if (!IsRegistered(v))
AddVar(v);
}
bool success = QcDelLinInEqSystem::AddConstraint(c);
if (success) {
#if qcCheckPost
addCheckedConstraint( c.pointer());
#endif
if (fAutoSolve)
Solve();
}
return success;
}
bool QcCassSolver::AddConstraint(QcConstraint &c, QcFloat &hint)
{
const QcLinPoly &lp = c.LinPoly();
const QcLinPoly::TTermsVector &terms = lp.GetTerms();
// For each QcFloat, check if it has already been added as stay
// constraint.
for (unsigned int i = 0; i < terms.size(); i++) {
QcFloat &v = terms[i]->GetVariable();
if (!IsRegistered(v))
AddVar(v);
}
bool success = QcDelLinInEqSystem::AddConstraint(c, hint);
if (success) {
#if qcCheckPost
addCheckedConstraint( c.pointer());
#endif
if (fAutoSolve)
Solve();
}
return success;
}
void QcCassSolver::AddEditVar(QcFloat &v)
{
QcSolver::AddEditVar(v);
TStayMap::iterator sIt = fStayMap.find(v);
if (sIt == fStayMap.end()) {
throw QcWarning(
"QcCassSolver::AddEditVar - adding an unregistered variable");
return;
}
QcCassConstraint *stay = (*sIt).second;
stay->fDvp.SetToEditWeight();
stay->fDvm.SetToEditWeight();
fEditMap.push_back(stay);
fEditVarsSetup = false;
}
void QcCassSolver::AddVar(QcFloat &v)
{
if (IsRegistered(v))
return;
QcDelLinInEqSystem::AddVar(v);
QcFloat dvp("", 0.0, v.StayWeight(), v.EditWeight(), true);
QcFloat dvm("", 0.0, v.StayWeight(), v.EditWeight(), true);
fVBiMap.Update(dvp, fTableau.AddError());
fVBiMap.Update(dvm, fTableau.AddError());
QcConstraint stay = ((-1 * v) + (1 * dvp) + (-1 * dvm)
== -v.DesireValue());
dbg(bool consistent_stay_constraint =)
QcDelLinInEqSystem::AddConstraint( stay);
assert( consistent_stay_constraint);
QcCassConstraint *cass = new QcCassConstraint( v, stay, dvp, dvm);
fStayMap[v] = cass;
fStaySeqMap.push_back( cass);
qcAssertExternalPost( IsRegistered( v));
}
void QcCassSolver::BeginAddConstraint()
{
throw QcWarning("Warning: QcCassSolver::BeginAddConstraint() not implemented yet");
}
void QcCassSolver::BeginEdit()
{
if (!fEditVarsSetup) {
if (fTableau.getNRestrictedRows() != 0) {
InitObjective();
SimplexII();
}
fEditVarsSetup = true;
}
}
bool QcCassSolver::EndAddConstraint()
{
throw QcWarning("Warning: QcCassSolver::EndAddConstraint() not implemented yet");
}
bool QcCassSolver::Reset()
{
cerr << "Warning: QcCassSolver::Reset() not implemented yet\n";
return false;
}
void QcCassSolver::EndEdit()
{
for (TEditMap::iterator eIt = fEditMap.begin();
eIt != fEditMap.end();
eIt++)
{
QcCassConstraint *edit = (*eIt);
edit->fDvp.SetToStayWeight();
edit->fDvm.SetToStayWeight();
}
fEditMap.clear();
// Call RestDesVal on things.
for (TStaySeqMap::iterator sIt = fStaySeqMap.begin();
sIt != fStaySeqMap.end();
sIt++)
{
QcCassConstraint *stay = (*sIt);
unsigned rowIx = fOCBiMap.Index( stay->fConstraint);
/* TODO: Do more work on keeping fTableau RHS in sync with user variable
goal value. Then we can make ChangeRHS conditional on the return value
of RestDesVal.
Also makes for better behaviour when user does suggestValue on a
non-edit-variable. */
stay->fVariable.RestDesVal();
fTableau.ChangeRHS( rowIx,
-stay->fVariable.DesireValue());
}
fEditVarsSetup = false;
QcSolver::EndEdit();
}
void QcCassSolver::InitObjective()
{
QcVariableIndexIterator vIt(fTableau);
while (!vIt.AtEnd()) {
if (fTableau.IsError(vIt.getIndex())) {
QcFloat &v = fVBiMap.Identifier(vIt.getIndex());
fTableau.SetObjValue(vIt.getIndex(), v.Weight());
} else
fTableau.SetObjValue(vIt.getIndex(), 0.0);
vIt.Increment();
}
#ifdef qcSafetyChecks
for (unsigned i = 0; i < fTableau.getNColumns(); i++)
if (fTableau.GetObjValue( i) != 0.0)
assert( fTableau.IsError( i));
#endif
fTableau.EliminateObjective();
}
void QcCassSolver::LoadDesValCache()
{
QcStructVarIndexIterator vIt (fTableau);
while (!vIt.AtEnd())
{
unsigned vi = vIt.getIndex();
if (!fTableau.IsSlack (vi))
fTableau.SetDesireValue (vi, fVBiMap.Identifier(vi).DesireValue());
vIt.Increment();
}
}
void QcCassSolver::Print(ostream &os) const
{
QcDelLinInEqSystem::Print(os);
os << "Stay constraints: ";
TStaySeqMap::const_iterator sIt = fStaySeqMap.begin();
while (sIt != fStaySeqMap.end()) {
(*sIt)->Print(os);
os << endl;
sIt++;
}
os << endl;
os << "Edit constraints: ";
TEditMap::const_iterator eIt = fEditMap.begin();
while (eIt != fEditMap.end()) {
(*eIt)->Print(os);
os << endl;
eIt++;
}
os << endl;
}
void QcCassSolver::RawSolve()
{
LoadDesValCache();
for (QcStructVarIndexIterator vIt (fTableau);
!vIt.AtEnd();
vIt.Increment())
{
unsigned vi = vIt.getIndex();
if (fTableau.IsSlack (vi))
continue;
QcFloat &v = fVBiMap.Identifier (vi);
if (fTableau.IsBasic (vi))
{
int ci = fTableau.IsBasicIn (vi);
assert (ci != QcTableau::fInvalidConstraintIndex);
v.SetValue (fTableau.GetRHS (ci));
}
else
v.SetVariable();
}
}
bool QcCassSolver::RemoveVar(QcFloat &v)
{
TStayMap::iterator sIt = fStayMap.find(v);
// If the variable to be deleted is not in the solver.
if (sIt == fStayMap.end()) {
throw QcWarning(
"QcCassSolver::RemoveVar - removing an unregistered variable");
return false;
}
QcCassConstraint *stay = (*sIt).second;
// Remove the stay constraint permanently since the associated variables
// is removed. Note that the error variables are not removed here, but
// through the LinInEqTableau class.
QcDelLinInEqSystem::RemoveConstraint(stay->fConstraint);
QcDelLinInEqSystem::RemoveVar(stay->fVariable);
// Remove the Cassowary constraint from the stay sequential map.
TStaySeqMap::iterator ssIt = fStaySeqMap.begin();
while (ssIt != fStaySeqMap.end()) {
if ((*ssIt) == stay) {
fStaySeqMap.erase(ssIt);
break;
}
ssIt++;
}
// Remove the Cassowary constraint from stay map.
delete stay;
fStayMap.erase(sIt);
return true;
}
void QcCassSolver::Resolve()
{
if (!fEditVarsSetup)
BeginEdit();
TEditMap::iterator eIt = fEditMap.begin();
while (eIt != fEditMap.end()) {
QcCassConstraint *edit = (*eIt);
fTableau.ChangeRHS(fOCBiMap.Index(edit->fConstraint),
-edit->fVariable.DesireValue());
eIt++;
}
DualSimplexII();
RawSolve();
#if qcCheckPost
checkSatisfied();
#endif
}
void QcCassSolver::Solve()
{
InitObjective();
SimplexII();
RawSolve();
TStaySeqMap::iterator sIt = fStaySeqMap.begin();
while (sIt != fStaySeqMap.end()) {
QcCassConstraint *stay = (*sIt);
fTableau.ChangeRHS(fOCBiMap.Index(stay->fConstraint),
-stay->fVariable.Value());
sIt++;
}
#if qcCheckPost
checkSatisfied();
#endif
}
void QcCassSolver::Restart()
{
QcDelLinInEqSystem::Restart();
fStayMap.clear();
fStaySeqMap.clear();
fEditMap.clear();
}

View File

@ -1,133 +0,0 @@
// $Id: QcCassSolver.hh,v 1.8 2001/01/04 05:20:11 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcCassSolverH
#define __QcCassSolverH
#include <map>
#include "qoca/QcDelLinInEqSystem.hh"
#include "qoca/QcCassConstraint.hh"
using namespace std;
class QcCassSolver : public QcDelLinInEqSystem
{
protected:
typedef map<QcFloat, QcCassConstraint *> TStayMap;
typedef vector<QcCassConstraint *> TEditMap;
typedef vector<QcCassConstraint *> TStaySeqMap;
TStayMap fStayMap;
TEditMap fEditMap;
TStaySeqMap fStaySeqMap;
// Corresponding data structure to fStayMap. This is used to speed
// things up when there is a need to iterate through all the stay
// constraints. Should not use fStayMap for iteration is not very
// efficient.
public:
//-----------------------------------------------------------------------//
// Constructors. //
//-----------------------------------------------------------------------//
QcCassSolver();
QcCassSolver(unsigned hintNumConstraints, unsigned hintNumVariables);
virtual ~QcCassSolver();
//-----------------------------------------------------------------------//
// Variable management methods //
//-----------------------------------------------------------------------//
virtual void AddVar(QcFloat &v);
virtual bool RemoveVar(QcFloat &v);
//-----------------------------------------------------------------------//
// Constraint management methods //
//-----------------------------------------------------------------------//
virtual bool AddConstraint(QcConstraint &c);
virtual bool AddConstraint(QcConstraint &c, QcFloat &hint);
virtual void BeginAddConstraint();
virtual bool EndAddConstraint();
virtual bool ChangeConstraint(QcConstraint &oldc, numT rhs);
virtual void InitObjective();
virtual bool RemoveConstraint(QcConstraint &c);
virtual bool Reset();
//-----------------------------------------------------------------------//
// High Level Edit Variable Interface for use by solver clients. //
//-----------------------------------------------------------------------//
virtual void AddEditVar(QcFloat &v);
virtual void EndEdit();
virtual void BeginEdit();
//-----------------------------------------------------------------------//
// Constraint Solving methods //
//-----------------------------------------------------------------------//
virtual void Solve();
virtual void Resolve();
void LoadDesValCache();
void RawSolve();
//-----------------------------------------------------------------------//
// Utility functions. //
//-----------------------------------------------------------------------//
virtual void Restart();
virtual void Print(ostream &os) const;
};
inline QcCassSolver::QcCassSolver()
: QcDelLinInEqSystem()
{
}
inline QcCassSolver::QcCassSolver(unsigned hintNumConstraints, unsigned hintNumVariables)
: QcDelLinInEqSystem(hintNumConstraints, hintNumVariables)
{
}
inline bool QcCassSolver::ChangeConstraint(QcConstraint &oldc, numT rhs)
{
bool success = QcDelLinInEqSystem::ChangeConstraint(oldc, rhs);
#if qcCheckPost
if (success)
changeCheckedConstraint( oldc.pointer(), rhs);
#endif
return success;
}
inline bool QcCassSolver::RemoveConstraint(QcConstraint &c)
{
bool success = QcDelLinInEqSystem::RemoveConstraint(c);
if (success) {
#if qcCheckPost
removeCheckedConstraint( c.pointer());
#endif
if (fAutoSolve)
Solve();
}
return success;
}
#endif /* !__QcCassSolverH */

View File

@ -1,335 +0,0 @@
// $Id: QcCompPivotSystem.cc,v 1.11 2001/01/31 04:53:11 pmoulder Exp $
//============================================================================//
// Written by Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include "qoca/QcDefines.hh"
#include "qoca/QcCompPivotSystem.hh"
#include "qoca/QcStructVarIndexIterator.hh"
#include "qoca/QcTableauColIterator.hh"
#include "qoca/QcTableauRowIterator.hh"
bool QcCompPivotSystem::ApplyHints(int cs)
{
bool pivoted = false;
if (cs < 0 || cs >= fTableau.GetRows() || fTableau.IsRedundant(cs))
throw QcWarning("ApplyHints called for invalid constraint",
cs, fTableau.GetRows() - 1);
else {
for (unsigned int i = 0; i < fTableau.fPivotHints.size() && !pivoted;
i++) {
int hint = fTableau.fPivotHints[i];
if (!fTableau.IsConstrained(hint))
pivoted = fTableau.Pivot(cs, hint);
}
}
return pivoted;
}
bool QcCompPivotSystem::CopyConstraint(QcConstraint &c, int bvi)
{
int ci = AddToTableau(c);
if (ci == QcTableau::fInvalidConstraintIndex)
return false;
else {
fOCBiMap.Update(c, ci);
fTableau.SetRowState(bvi, ci, QcLinEqRowState::fRegular);
}
return true;
}
bool QcCompPivotSystem::CopyInEq(QcConstraint &c)
{
int ci = AddToTableau(c);
if (ci == QcTableau::fInvalidConstraintIndex)
return false;
else {
fOCBiMap.Update(c, ci);
fTableau.SetRowState(fTableau.GetColumns() - 1, ci,
QcLinEqRowState::fRegular);
}
fEditVarsSetup = false;
return true;
}
void QcCompPivotSystem::EqRawSolve()
{
#ifdef qcSafetyChecks
if (!fTableau.IsBasicFeasibleSolved())
throw QcWarning(qcPlace,
"Tableau is not in basic feasible solved form");
#endif
QcStructVarIndexIterator vIt(fTableau);
while (!vIt.AtEnd())
{
unsigned vi = vIt.getIndex();
int ci = fTableau.IsBasicIn (vi);
if ((ci >= fTableau.GetBeginEq())
&& (ci != QcTableau::fInvalidConstraintIndex))
{
numT value = EvalBasicVar (vi);
QcFloat &v = fVBiMap.Identifier (vi);
v.SetValue (QcUtility::Zeroise (value));
}
vIt.Increment();
}
}
void QcCompPivotSystem::EqRawSolveComplex()
{
#ifdef qcSafetyChecks
if (!fTableau.IsBasicFeasibleSolved())
throw QcWarning(qcPlace,
"Tableau is not in basic feasible solved form");
#endif
QcStructVarIndexIterator vIt (fTableau);
while (!vIt.AtEnd())
{
unsigned vi = vIt.getIndex();
int ci = fTableau.IsBasicIn (vi);
if ((ci >= fTableau.GetBeginEq())
&& (ci != QcTableau::fInvalidConstraintIndex))
{
numT value = EvalBasicVarComplex (vi);
QcFloat v = fVBiMap.Identifier (vi);
v.SetValue (QcUtility::Zeroise (value));
}
vIt.Increment();
}
}
numT
QcCompPivotSystem::EvalBasicVar(unsigned vi)
{
qcAssertPre( IsBasic( fVBiMap.Identifier( vi)));
int ci = fTableau.IsBasicIn( vi);
assert( ci != QcTableau::fInvalidConstraintIndex);
numT value = fTableau.GetRHS(ci); // rhs sign is not critical here
for (QcTableauRowIterator varCoeffs( fTableau, ci);
!varCoeffs.AtEnd();
varCoeffs.Increment())
{
unsigned coeff_vi = varCoeffs.getIndex();
if ((coeff_vi != vi)
&& (fTableau.IsStructural( coeff_vi)))
{
QcFloatRep *vr = fVBiMap.getIdentifierPtr( coeff_vi);
value -= varCoeffs.getValue() * vr->Value();
}
}
return value;
}
numT QcCompPivotSystem::EvalBasicVarComplex(unsigned vi)
{
qcAssertPre( IsBasic( fVBiMap.Identifier( vi)));
int ci = fTableau.IsBasicIn( vi);
assert( ci != QcTableau::fInvalidConstraintIndex);
numT value = fTableau.GetComplexRHS( ci); // rhs sign is not critical here
for (QcTableauRowIterator varCoeffs( fTableau, ci);
!varCoeffs.AtEnd();
varCoeffs.Increment())
{
unsigned coeff_vi = varCoeffs.getIndex();
if ((coeff_vi != vi)
&& (fTableau.IsStructural( coeff_vi)))
{
QcFloatRep *vr = fVBiMap.getIdentifierPtr( coeff_vi);
value -= varCoeffs.GetValue() * vr->Value();
}
}
return value;
}
void QcCompPivotSystem::InEqRawSolve()
{
#ifdef qcSafetyChecks
if (!fTableau.IsBasicFeasibleSolved())
throw QcWarning(qcPlace,
"Tableau is not in basic feasible solved form");
#endif
QcStructVarIndexIterator vIt (fTableau);
while (!vIt.AtEnd())
{
unsigned vi = vIt.getIndex();
int ci = fTableau.IsBasicIn (vi);
/* TODO: What happens if GetBeginEq < 0?
Should `!= fInvalidConstraintIndex' be tested first? */
if (ci < fTableau.GetBeginEq())
{
QcFloat &v = fVBiMap.Identifier (vi);
if (ci != QcTableau::fInvalidConstraintIndex)
{
numT value = fTableau.GetRHS (ci);
v.SetValue (QcUtility::Zeroise (value));
}
else
v.SetVariable();
}
vIt.Increment();
}
}
void QcCompPivotSystem::InEqRawSolveComplex()
{
#ifdef qcSafetyChecks
if (!fTableau.IsBasicFeasibleSolved())
throw QcWarning(qcPlace,
"Tableau is not in basic feasible solved form");
#endif
QcStructVarIndexIterator vIt (fTableau);
while (!vIt.AtEnd())
{
unsigned vi = vIt.getIndex();
int ci = fTableau.IsBasicIn (vi);
if (ci < fTableau.GetBeginEq())
{
QcFloat &v = fVBiMap.Identifier (vi);
if (ci != QcTableau::fInvalidConstraintIndex)
{
numT value = fTableau.GetComplexRHS (ci);
v.SetValue (QcUtility::Zeroise (value));
}
else
v.SetVariable();
}
vIt.Increment();
}
}
int QcCompPivotSystem::SelectExitVar (unsigned vi)
{
qcAssertPre( vi < fTableau.getNColumns());
int ei = QcTableau::fInvalidConstraintIndex;
numT minval = DBL_MAX;
int bi = fTableau.GetColumns(); // Bland Index
#ifdef qcSafetyChecks
qcAssert(!fTableau.IsBasic(vi) && fTableau.IsConstrained(vi));
#endif
for (QcTableauColIterator colCoeffs( fTableau, vi);
!colCoeffs.AtEnd();
colCoeffs.Increment())
if(colCoeffs.GetIndex() < fTableau.GetBeginEq())
{
qcAssert( fTableau.GetBasicVar( colCoeffs.GetIndex()) != (int) vi);
if (fTableau.IsRestricted( colCoeffs.GetIndex()))
{
numT rhs = fTableau.GetRHS( colCoeffs.GetIndex());
if (CannotIncrease( colCoeffs.GetValue(), rhs))
{
numT coeff = rhs / colCoeffs.GetValue();
if ((coeff < minval)
|| ((coeff == minval)
&& (fTableau.GetBasicVar(colCoeffs.GetIndex()) < bi)))
{
minval = coeff;
ei = colCoeffs.GetIndex();
bi = fTableau.GetBasicVar( ei);
qcAssert( !QcUtility::IsNegative( minval));
}
}
}
}
#ifdef qcSafetyChecks
qcAssert( fTableau.IsBasicFeasibleSolved());
if (ei < 0)
throw QcWarning("SelectExitVar: No suitable variable");
#endif
return ei;
}
int QcCompPivotSystem::SelectExitVarComplex (int vi)
{
int ei = QcTableau::fInvalidConstraintIndex;
numT minval = DBL_MAX;
int bi = fTableau.GetColumns(); // Bland Index
#ifdef qcSafetyChecks
qcAssert(!fTableau.IsBasic(vi) && fTableau.IsConstrained(vi));
#endif
for (QcTableauColIterator colCoeffs( fTableau, vi);
!colCoeffs.AtEnd();
colCoeffs.Increment())
if(colCoeffs.GetIndex() < fTableau.GetBeginEq())
{
unsigned const coeff_ix = colCoeffs.getIndex();
qcAssert (fTableau.GetBasicVar (coeff_ix) != vi);
if (fTableau.IsRestricted (coeff_ix))
{
numT rhs = fTableau.GetComplexRHS (coeff_ix);
if (CannotIncrease (colCoeffs.getValue(), rhs))
{
numT coeff = rhs / colCoeffs.getValue();
if ((coeff < minval)
|| ((coeff == minval)
&& (fTableau.GetBasicVar (coeff_ix)
< bi)))
{
minval = coeff;
ei = coeff_ix;
bi = fTableau.GetBasicVar (ei);
qcAssert (!QcUtility::IsNegative (minval));
}
}
}
}
#ifdef qcSafetyChecks
/* fixme: the following assertion can fail (in the test suite), with fTableau
solved but not basic feasible. */
qcAssert (fTableau.IsBasicFeasibleSolved());
if (ei < 0)
throw QcWarning("SelectExitVar: No suitable variable");
#endif
return ei;
}

View File

@ -1,98 +0,0 @@
// $Id: QcCompPivotSystem.hh,v 1.7 2000/12/12 01:29:00 pmoulder Exp $
//============================================================================//
// Written by Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcCompPivotSystemH
#define __QcCompPivotSystemH
#include "qoca/QcLinInEqSystem.hh"
#include "qoca/QcCompPivotTableau.hh"
class QcCompPivotSystem : public QcLinInEqSystem
{
protected:
QcCompPivotTableau &fTableau;
public:
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcCompPivotSystem();
QcCompPivotSystem(int hintRows, int hintCols);
QcCompPivotSystem(QcCompPivotTableau &tab);
//-----------------------------------------------------------------------//
// Variable management methods //
//-----------------------------------------------------------------------//
void AddSlack(QcFloat &v)
{ fVBiMap.Update(v, fTableau.AddSlack()); }
//-----------------------------------------------------------------------//
// Constraint management methods //
//-----------------------------------------------------------------------//
virtual bool ApplyHints(int cs);
// This is a convenience function to pivot an independent new
// solved form constraint according to the PivotHints.
virtual bool CopyInEq(QcConstraint &c);
virtual bool CopyConstraint(QcConstraint &c, int bvi);
// Extracts the various components and enters them in the sub-tableau
// as well as updating the bimapnotifier for the sub-tableau
// if successful.
virtual void EqRawSolve();
virtual void EqRawSolveComplex();
numT EvalBasicVar(unsigned vi);
numT EvalBasicVarComplex(unsigned vi);
virtual void InEqRawSolve();
virtual void InEqRawSolveComplex();
virtual int SelectExitVar (unsigned vi);
// see superclass for doc
virtual int SelectExitVarComplex(int vi);
// Select the pivot row for pivot variable vi (slack parameter)
// maintaining Basic Feasible Solved Form.
// Returns fInvalidConstraintIndex if no such pivot is possible.
// This version implement's Bland's anticycling rule.
};
inline QcCompPivotSystem::QcCompPivotSystem()
: QcLinInEqSystem(*new QcCompPivotTableau(0, 0, fNotifier)),
fTableau((QcCompPivotTableau &)QcLinInEqSystem::fTableau)
{
}
inline QcCompPivotSystem::QcCompPivotSystem(int hintRows, int hintCols)
: QcLinInEqSystem(*new QcCompPivotTableau(hintRows, hintCols, fNotifier)),
fTableau((QcCompPivotTableau &)QcLinInEqSystem::fTableau)
{
}
inline QcCompPivotSystem::QcCompPivotSystem(QcCompPivotTableau &tab)
: QcLinInEqSystem(tab),
fTableau(tab)
{
}
#endif

View File

@ -1,239 +0,0 @@
// $Id: QcCompPivotTableau.cc,v 1.12 2001/01/31 07:37:13 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include "qoca/QcDefines.hh"
#include "qoca/QcCompPivotTableau.hh"
#include "qoca/QcConstraintIndexIterator.hh"
#include "qoca/QcTableauColIterator.hh"
#include "qoca/QcDenseTableauColIterator.hh"
int QcCompPivotTableau::AddArtificial(numT coeff)
{
int vi = IncreaseColumns();
SetColCondition(vi, QcLinInEqColState::fArtificial);
SetConstrained(vi, true);
QcConstraintIndexIterator cIt(*this);
while (!cIt.AtEnd()) {
fCoreTableau->fSF.SetValue (cIt.getIndex(), vi, coeff);
cIt.Increment();
}
fAI = vi;
return vi;
}
int QcCompPivotTableau::AddDesValVar(void)
{
int vi = IncreaseColumns();
SetColCondition(vi, QcLinInEqColState::fDesire);
SetConstrained(vi, false);
return vi;
}
numT QcCompPivotTableau::GetComplexRHS(int ci) const
{
numT crhs = QcLinInEqTableau::GetRHS(ci);
for (unsigned vi = 0; (int) vi < GetColumns(); vi++) {
if (IsDesire(vi))
crhs -= GetValue(ci, vi) * GetDesireValue(vi);
}
return QcUtility::Zeroise(crhs);
}
void QcCompPivotTableau::Print(ostream &os) const
{
QcLinInEqTableau::Print(os);
os << "Complex RHS:" << endl;
int rows = GetRows();
for (int i = 0; i < rows; i++)
os << "CRHS[" << i << "] = " << GetComplexRHS(i) << endl;
os << "Begin Eq: " << fBeginEq << endl;
}
void QcCompPivotTableau::Restart(void)
{
QcLinInEqTableau::Restart();
fAI = QcTableau::fInvalidVariableIndex;
fBeginEq = QcTableau::fInvalidConstraintIndex;
}
bool QcCompPivotTableau::RestrictedPivot(unsigned ci, unsigned vi)
{
qcAssertPre( ci < getNRows());
qcAssertPre( vi < getNColumns());
qcAssertPre( !fCoreTableau->GetMRowDeleted( ci));
qcAssertPre( !IsRedundant( ci));
qcAssertPre( GetRowCondition( ci) != QcLinEqRowState::fInvalid);
numT p = GetValue( ci, vi); // GetValue returns the raw coefficient
if (QcUtility::IsZero( p)) // so this test is required.
return false;
// If ci is regular then remove it from the basis.
if (GetRowCondition( ci) == QcLinEqRowState::fRegular)
Unsolve(ci);
// Note that fARowIndex[ci] can be left as qcInvalidCIndex,
// hence check below.
// From this point, until the pivot is completed,
// the conditions MRowIndex(fARowIndex(ci))==ci and
// ARowIndex(MRowIndex(ci2))==ci2 may not hold. Since it is
// Pivot that causes a row to become regular, and these conditions
// do not hold for regular rows, this is a consequence of the
// change of state. We could introduce another row state for this
// phase, but that seems a bit over the top. Just check that all
// tableau methods that Pivot calls from here on do not assume the
// conditions. I.E. don't call: DecreaseRows, Eliminate, RemoveEq,
// CompactRows, Restore, or AddRow. And of course if IsSolved is
// called with checks enabled it may report an assert violation.
// From this point the pivot must succeed.
// So can now wipe fARowIndex and fMRowIndex
if (GetARowIndex(ci) != QcTableau::fInvalidConstraintIndex)
{
SetMRowIndex( GetARowIndex( ci), QcTableau::fInvalidConstraintIndex);
SetARowIndex( ci, QcTableau::fInvalidConstraintIndex);
}
#ifdef qcSafetyChecks
qcAssert(GetARowIndex(ci) == QcTableau::fInvalidConstraintIndex);
qcAssert(GetRowCondition(ci) == QcLinEqRowState::fNormalised);
qcAssert(GetBasicVar(ci) == QcTableau::fInvalidVariableIndex);
qcAssert(IsBasicIn(vi) == QcTableau::fInvalidConstraintIndex);
#endif
// Scale the pivot row so pivot coeff is 1.0
fCoreTableau->fSF.ScaleRow( ci, recip( p));
// FractionRow may be used here rather than ScaleRow(ci,recip(p))
// so that we don't introduce rounding errors at the cost of
// efficiency (FractionRow uses division so is less efficient).
#ifdef qcUseSafeIterator
// Eliminate the new basic variable from all the other rows.
for (QcDenseTableauColIterator varCoeffs( *this, vi);
!varCoeffs.AtEnd();
varCoeffs.Increment())
{
/* Process only regular rows. Redundant and deleted rows would not
be affected in any case. Undetermined rows are not in solved
form so should not be included. By checking here we can allow
rows to be added without requiring an immediate pivot and also
enable a full resolve by setting all the rows to normalised and
fM to identity. */
if (varCoeffs.GetIndex() >= fBeginEq)
break;
if ((GetRowCondition( varCoeffs.getIndex()) == QcLinEqRowState::fRegular)
|| ((GetRowCondition( varCoeffs.getIndex()) == QcLinEqRowState::fNormalised)
&& (varCoeffs.getIndex() != ci)))
{
// Excludes (varCoeffs.fIndex == ci) since
// (GetRowCondition(ci) != QcLinEqRowState::fRegular).
fCoreTableau->fSF.AddScaledRow( varCoeffs.getIndex(), ci,
-varCoeffs.getValue());
}
}
#else /* !qcUseSafeIterator */
// Eliminate the new basic variable from all the other rows.
{
vector<QcSparseCoeff> coeffCache;
for(QcTableauColIterator varCoeffs( *this, vi);
!varCoeffs.AtEnd();
varCoeffs.Increment())
{
unsigned coeff_ix = varCoeffs.getIndex();
/* Process only regular rows. Redundant and deleted rows would
not be affected in any case. Undetermined rows are not
in solved form so should not be included. By checking here
we can allow rows to be added without requiring an
immediate pivot and also enable a full resolve by
setting all the rows to normalised and fM to identity. */
if((int( coeff_ix) < fBeginEq)
&& (GetRowCondition( coeff_ix) == QcLinEqRowState::fRegular
|| (GetRowCondition( coeff_ix) == QcLinEqRowState::fNormalised
&& (coeff_ix != ci))))
/* Excludes (coeff_ix == ci) since
* (GetRowCondition(ci) != QcLinEqRowState::fRegular).
*/
coeffCache.push_back( QcSparseCoeff( varCoeffs.getValue(),
coeff_ix));
}
for (vector<QcSparseCoeff>::iterator cIt = coeffCache.begin();
cIt != coeffCache.end();
cIt++)
{
QcSparseCoeff &coeff = (*cIt);
unsigned const coeff_ix = coeff.getIndex();
fCoreTableau->fSF.AddScaledRow( coeff_ix, ci,
-coeff.getValue());
}
}
#endif
SetBasic(vi, true);
SetBasicIn(vi, ci);
SetBasicVar(ci, vi);
SetRowCondition(ci, QcLinEqRowState::fRegular);
return true;
}
void QcCompPivotTableau::SetArtificial(numT coeff)
{
QcConstraintIndexIterator cIt(*this);
while (!cIt.AtEnd()) {
fCoreTableau->fSF.SetValue (cIt.getIndex(), fAI, coeff);
cIt.Increment();
}
}
void QcCompPivotTableau::SetRowState(int bvi, int ci, int rs)
{
// Need to reverse the sign of all the row coefficients if the coefficients
// for the variable to make basic is -1.0.
if (QcUtility::IsNegative(GetValue(ci, bvi)))
fCoreTableau->fSF.NegateRow( ci);
SetBasic(bvi, true);
SetBasicIn(bvi, ci);
SetBasicVar(ci, bvi);
SetRowCondition(ci, rs);
}

View File

@ -1,108 +0,0 @@
// $Id: QcCompPivotTableau.hh,v 1.7 2000/12/15 01:20:05 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcCompPivotTableauH
#define __QcCompPivotTableauH
#include "qoca/QcLinInEqTableau.hh"
class QcCompPivotTableau : public QcLinInEqTableau
{
protected:
int fAI;
int fBeginEq;
//------------------------------------------------------------------------//
// Constructor. //
//------------------------------------------------------------------------//
public:
QcCompPivotTableau(int hintRows, int hintCols, QcBiMapNotifier &n);
//------------------------------------------------------------------------//
// Query functions. //
//------------------------------------------------------------------------//
/** @postcondition <tt>(ret == fInvalidConstraintIndex)
|| ((unsigned) ret</tt> &le; <tt>getNRows()</tt>)
**/
int GetBeginEq() const
{
qcAssertPost ((fBeginEq == fInvalidConstraintIndex)
|| ((unsigned) fBeginEq <= getNRows()));
return fBeginEq;
}
numT GetComplexRHS(int ci) const;
//------------------------------------------------------------------------//
// Manipulation functions. //
//------------------------------------------------------------------------//
virtual int AddArtificial(numT coeff);
virtual int AddDesValVar();
virtual void Restart();
// Erase everything ready to start afresh.
/** The parameters indicate a solved form coeff. Pivot can only be applied to
a normalised or regular constraint.
<p><tt>getValue(ci, vi)</tt> is allowed to be zero, in which case does
nothing and returns false.
<p>This pivot function only work on restricted rows which ends on
fBeginEq.
@precondition <tt>ci &lt; getNRows()</tt>
@precondition <tt>vi &lt; getNColumns()</tt>
@precondition <tt>!IsRedundant(ci)</tt>
**/
bool RestrictedPivot(unsigned ci, unsigned vi);
/** In each constraint, set the coefficient of the artificial variable to
<tt>coeff</tt>. */
void SetArtificial(numT coeff);
void SetBeginEq()
{ fBeginEq = GetRows(); }
void SetRowState(int bvi, int ci, int rs);
//------------------------------------------------------------------------//
// Utility functions. //
//------------------------------------------------------------------------//
virtual void Print(ostream &os) const;
};
inline QcCompPivotTableau::QcCompPivotTableau(int hintRows, int hintCols,
QcBiMapNotifier &n)
: QcLinInEqTableau(*new QcCoreTableau(hintRows, hintCols,
*new QcLinInEqRowColStateVector()),
n),
fAI(fInvalidVariableIndex),
fBeginEq(fInvalidConstraintIndex)
{
}
#endif

View File

@ -1,322 +0,0 @@
// $Id: QcConstraint.hh,v 1.11 2001/01/10 05:01:33 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcConstriantH
#define __QcConstriantH
#include "qoca/QcDefines.hh"
#include "qoca/QcConstraintRep.hh"
#include "qoca/QcLinPoly.hh"
/** This class provides the only mechanism to create constraints and the
constructors and the constructors return a handle. See
<tt>QcNullableElement</tt> for comments on assignment semantics etc.
**/
class QcConstraint
{
public:
friend class QcNullableElement<QcConstraintRep,QcConstraint>;
//-----------------------------------------------------------------------//
// Constructors //
//-----------------------------------------------------------------------//
QcConstraint(QcConstraintRep &r);
QcConstraint(QcConstraintRep *p);
QcConstraint();
QcConstraint(const char *name);
QcConstraint(const char *name, const QcLinPoly &p);
QcConstraint(const char *name, const QcLinPoly &p, QcConstraintRep::TOp op);
QcConstraint(const char *name, const QcLinPoly &p, QcConstraintRep::TOp op,
numT rhs);
QcConstraint(QcConstraint const &other);
QcConstraint(QcNullableElement<QcConstraintRep,QcConstraint> const &other);
~QcConstraint()
{ Decrease(); }
void assertInvar() const
{
qcAssertInvar(fRep != NULL);
fRep->assertInvar();
}
//-----------------------------------------------------------------------//
// Data structure access functions //
//-----------------------------------------------------------------------//
QcConstraintRep const *pointer() const
{ return fRep; }
QcConstraintRep *pointer()
{ return fRep; }
#if 0
const QcConstraintRep &Rep() const
{ return *fRep; }
#endif
//-----------------------------------------------------------------------//
// Query functions //
//-----------------------------------------------------------------------//
long Counter() const
{ return fRep->Counter(); }
const char *Name() const
{ return fRep->Name(); }
QcConstraintRep::TId Id() const
{ return fRep->Id(); }
const QcLinPoly& LinPoly() const
{ return fRep->LinPoly(); }
QcConstraintRep::TOp Operator() const
{ return fRep->Operator(); }
QcConstraintRep::TOp getRelation() const
{ return fRep->Operator(); }
numT RHS() const
{ return fRep->RHS(); }
numT getRHS() const
{ return fRep->RHS(); }
bool hasVar (QcFloatRep const *v) const
{ return fRep->LinPoly().hasVar (v); }
unsigned getNVars() const
{ return fRep->LinPoly().getNTerms(); }
QcFloat const &getVar (unsigned i) const
{ return fRep->LinPoly().GetTerm (i).GetVariable(); }
int getVarId (unsigned i) const
{ return getVar(i).Id(); }
bool operator <(const QcConstraint &other) const
{ return *fRep < *other.fRep; }
bool operator ==(const QcConstraint &other) const
{ return (fRep == other.fRep); }
bool operator !=(const QcConstraint &other) const
{ return (fRep != other.fRep); }
//-----------------------------------------------------------------------//
// Set and Get member functions //
//-----------------------------------------------------------------------//
void SetLinPoly(QcLinPoly &p)
{ fRep->SetLinPoly(p); }
void SetRHS(numT rhs)
{ fRep->SetRHS(rhs); }
void SetOperator(QcConstraintRep::TOp op)
{ fRep->SetOperator(op); }
void SetName(char const * const n)
{ fRep->SetName(n); }
void makeEq(QcLinPoly *p, numT rhs)
{
fRep->SetLinPoly(*p);
fRep->SetOperator(QcConstraintRep::coEQ);
fRep->SetRHS(rhs);
}
void makeLe(QcLinPoly *p, numT rhs)
{
fRep->SetLinPoly(*p);
fRep->SetOperator(QcConstraintRep::coLE);
fRep->SetRHS(rhs);
}
void makeGe(QcLinPoly *p, numT rhs)
{
fRep->SetLinPoly(*p);
fRep->SetOperator(QcConstraintRep::coGE);
fRep->SetRHS(rhs);
}
void Decrease();
// Called when number of references decreases.
bool FreeName()
// Deallocates old name string.
{ return fRep->FreeName(); }
void Increase() const
// Call when number of references increases.
{ fRep->Increase(); }
QcConstraint &operator=(const QcConstraint &other);
// N.B. checked self assignment, x = x ok
/** Returns true iff this constraint is satisfied or
<tt>QcUtility.isZero(LHS - RHS)</tt>. The current implementation
ignores the possibility of NaN or infinity problems. */
bool isSatisfied() const
{ return fRep->isSatisfied(); }
//------------------------------------------------------------------------//
// Utility functions //
//------------------------------------------------------------------------//
void Print(ostream &os) const
{ fRep->Print(os); }
bool isDead() const
{ return fRep == 0; }
protected:
QcConstraintRep *fRep;
};
inline QcConstraint::QcConstraint(QcConstraintRep &r)
: fRep(&r)
{
}
inline QcConstraint::QcConstraint (QcConstraintRep *p)
: fRep (p)
{
}
inline QcConstraint::QcConstraint()
: fRep(new QcConstraintRep())
{
}
inline QcConstraint::QcConstraint(const char *name)
: fRep(new QcConstraintRep(name))
{
}
inline QcConstraint::QcConstraint(const char *name, const QcLinPoly &p)
: fRep(new QcConstraintRep(name, p))
{
}
inline QcConstraint::QcConstraint(const char *name, const QcLinPoly &p,
QcConstraintRep::TOp op)
: fRep(new QcConstraintRep(name, p, op))
{
}
inline QcConstraint::QcConstraint(const char *name, const QcLinPoly &p,
QcConstraintRep::TOp op, numT rhs)
: fRep(new QcConstraintRep(name, p, op, rhs))
{
}
inline QcConstraint::QcConstraint(const QcConstraint &other)
: fRep(other.fRep)
{
Increase();
}
inline QcConstraint::QcConstraint(QcNullableElement<QcConstraintRep,QcConstraint> const &other)
: fRep(other.fRep)
{
Increase();
}
#ifndef qcSafetyChecks
inline void QcConstraint::Decrease()
{
fRep->Decrease();
if (fRep->Counter() == 0)
delete fRep;
fRep = 0;
}
#else
inline void QcConstraint::Decrease()
{
fRep->Decrease();
if (fRep->Counter() < 0)
throw QcWarning(
"QcConstraint::Decrease: invalid count (already free?)");
else if (fRep->Counter() == 0) {
if (fRep->Magic() == qcConstraintMagic1 && FreeName()) {
delete fRep;
} else
throw QcWarning(
"QcConstraint::Decrease detected constraint corruption");
}
fRep = 0;
}
#endif
inline QcConstraint &QcConstraint::operator=(const QcConstraint &other)
{
other.fRep->Increase();
Decrease();
fRep = other.fRep;
return *this;
}
#ifndef QOCA_NO_FANCY_OPERATORS
inline QcConstraint operator ==(const QcLinPoly &lhs, numT rhs)
{
return QcConstraint("", lhs, QcConstraintRep::coEQ, rhs);
}
inline QcConstraint operator <=(const QcLinPoly &lhs, numT rhs)
{
return QcConstraint("", lhs, QcConstraintRep::coLE, rhs);
}
inline QcConstraint operator >=(const QcLinPoly &lhs, numT rhs)
{
return QcConstraint("", lhs, QcConstraintRep::coGE, rhs);
}
inline QcConstraint operator ==(const QcLinPolyTerm &lhs, numT rhs)
{
return QcConstraint("", QcLinPoly(lhs), QcConstraintRep::coEQ, rhs);
}
inline QcConstraint operator <=(const QcLinPolyTerm &lhs, numT rhs)
{
return QcConstraint("", QcLinPoly(lhs), QcConstraintRep::coLE, rhs);
}
inline QcConstraint operator >=(const QcLinPolyTerm &lhs, numT rhs)
{
return QcConstraint("", QcLinPoly(lhs), QcConstraintRep::coGE, rhs);
}
#endif /* QOCA_NO_FANCY_OPERATORS */
#ifndef qcNoStream
inline ostream &operator<<(ostream &os, const QcConstraint &c)
{
c.Print(os);
return os;
}
#endif
#endif /* !__QcConstriantH */

View File

@ -1,35 +0,0 @@
// $Id: QcConstraintBiMap.hh,v 1.4 2000/12/11 07:44:13 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcConstraintBiMapH
#define __QcConstraintBiMapH
#include "qoca/QcAliasedBiMap.hh"
#include "qoca/QcNullableConstraint.hh"
typedef QcAliasedBiMap<QcNullableConstraint, QcConstraint, QcConstraintRep> QcConstraintBiMap;
#endif /* !__QcConstraintBiMapH */

View File

@ -1,76 +0,0 @@
// $Id: QcConstraintIndexIterator.hh,v 1.5 2000/11/29 01:58:42 pmoulder Exp $
//============================================================================//
// Written by Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcConstraintIndexIteratorH
#define __QcConstraintIndexIteratorH
class QcConstraintIndexIterator
{
public:
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcConstraintIndexIterator (const QcLinEqTableau &tab);
bool AtEnd() const
{ return (fCurrent == 0); }
unsigned getIndex() const
{
qcAssertPre (!AtEnd());
unsigned ret = fCurrent->fIndex;
qcAssertPost ((int) ret >= 0);
return ret;
}
void Increment();
void Reset();
private:
QcQuasiRowStateVector const &fRowState;
QcQuasiRowState const *fCurrent;
};
inline
QcConstraintIndexIterator::QcConstraintIndexIterator (const QcLinEqTableau &tab)
: fRowState(tab.GetRowState())
{
Reset();
}
inline void QcConstraintIndexIterator::Increment()
{
qcAssertPre (!AtEnd());
fCurrent = fCurrent->getNextUndeletedRow();
}
inline void QcConstraintIndexIterator::Reset()
{
fCurrent = fRowState.fRowList;
}
#endif

View File

@ -1,129 +0,0 @@
// $Id: QcConstraintRep.cc,v 1.7 2000/12/06 05:32:56 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include "qoca/QcDefines.hh"
#include "qoca/QcConstraintRep.hh"
QcConstraintRep::TId QcConstraintRep::fNextValidId = 1;
const QcConstraintRep::TId QcConstraintRep::fInvalidId = 0;
bool QcConstraintRep::FreeName()
{
bool ok = true;
if (fName != 0) { // check for magic4
char const *magic2 = qcConstraintMagic2;
for (int i = 0; i < qcConstraintMagic2Len; i++)
ok &= (fName[i] == magic2[i]);
if (ok) {
delete[] fName;
fName = 0;
}
}
return ok;
}
void QcConstraintRep::Initialize(const char *n, const QcLinPoly &lp, TOp op)
{
fMagic = qcConstraintMagic1;
fLinPoly = lp;
qcAssertExternalPre(VALID_OP(op));
fOperator = op;
Reset();
fName = 0;
SetName(n);
}
#if qcCheckInternalInvar
void QcConstraintRep::assertInvar() const
{
qcAssertInvar(fMagic == qcConstraintMagic1);
qcAssertInvar(fCounter >= 0);
qcAssertInvar(fId > 0);
fLinPoly.assertInvar();
qcAssertInvar(VALID_OP(fOperator));
qcAssertInvar(fName == 0 || memcmp(fName, qcConstraintMagic2, qcConstraintMagic2Len) == 0);
}
#endif
void QcConstraintRep::Print(ostream &os) const
{
if (fName != 0)
os << Name();
os << "#" << fId
<< "(" << fLinPoly << ", ";
switch (fOperator) {
case coEQ: os << "=="; break;
//case coLT: os << "<"; break;
case coLE: os << "<="; break;
//case coGT: os << ">"; break;
case coGE: os << ">="; break;
}
os << ", " << fRHS << ")";
}
void QcConstraintRep::SetName(const char *n)
// Set name sets the field fRep->Name to point to a heap allocated
// string with a hidden magic number field at the front.
// The magic number is qcConstraintMagic2 without the '\0' terminator.
// N.B. Although <strings.h> is pretty standard, for portability
// we try to avoid using it here as we have no other need for it.
{
int len = 0;
char const *magic2 = qcConstraintMagic2;
// find length of source string
while (n[len] != '\0')
len++;
qcAssertPost(n[len] == '\0');
#ifdef qcSafetyChecks
if (len > 1000)
throw QcWarning("QcConstraintRep::SetName name over 1000 chars long");
#endif
if (!FreeName()) { // Deallocate existing name string
// If FreeName fails, leave old string and allocate a new one
throw QcWarning("QcConstraintRep::SetName: failed to free old name string");
}
fName = new char[len + qcConstraintMagic2Len + 1];
// allocate for magic+string
for (int i = 0; i < qcConstraintMagic2Len; i++)
fName[i] = magic2[i];
for (int i = 0; i <= len; i++)
fName[i + qcConstraintMagic2Len] = n[i];
qcAssertPost(fName[len + qcConstraintMagic2Len] == '\0');
}

View File

@ -1,347 +0,0 @@
// $Id: QcConstraintRep.hh,v 1.9 2001/01/04 05:20:11 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcConstriantRepH
#define __QcConstriantRepH
#include "qoca/QcDefines.hh"
#include "qoca/QcLinPoly.hh"
#define qcConstraintMagic1 45919
#define qcConstraintMagic2 "Qoca constraint:"
#define qcConstraintMagic2Len 16
// The length of qcConstraintMagic2 without the terminal '\0'
class QcConstraintRep
{
public:
typedef long TId;
// It is intended that this be signed. Negative values are not
// allocated and are reserved for future (unknown) usage. The value 0
// is reserved as an invalid identifier.
enum TOp {
coEQ, // ==
coLE, // <=
coGE // >=
};
enum deprecated_TOp_vals {
coLT = coLE, // < (implemented as <=)
coGT = coGE // > (implemented as >=)
};
/** The highest valid operator number. */
static const int coLastOp = coGE;
public:
//-----------------------------------------------------------------------//
// Constructors //
//-----------------------------------------------------------------------//
QcConstraintRep();
QcConstraintRep(const QcLinPoly &lp);
QcConstraintRep(const QcLinPoly &lp, const TOp op);
QcConstraintRep(const QcLinPoly &lp, const TOp op, numT rhs);
QcConstraintRep(const char *name);
QcConstraintRep(const char *name, const QcLinPoly &lp);
QcConstraintRep(const char *name, const QcLinPoly &lp, TOp op);
QcConstraintRep(const char *name, const QcLinPoly &lp, TOp op, numT rhs);
virtual ~QcConstraintRep()
{ delete [] fName; }
//-----------------------------------------------------------------------//
// Data Structure access functions. //
//-----------------------------------------------------------------------//
const QcLinPoly &LinPoly() const
{ return fLinPoly; }
//-----------------------------------------------------------------------//
// Query functions. //
//-----------------------------------------------------------------------//
long Counter() const
{ return fCounter; }
TId Id() const
{ return fId; }
TOp Operator() const
{ return fOperator; }
TOp getRelation() const
{ return fOperator; }
bool hasVar (QcFloatRep const *v) const
{ return LinPoly().hasVar (v); }
unsigned getNVars() const
{ return LinPoly().getNTerms(); }
QcFloat const &getVar (unsigned i) const
{ return LinPoly().GetTerm (i).GetVariable(); }
QcFloatRep *getVarPtr( unsigned i)
{
return LinPoly().GetTerm( i).getVariable();
}
#if 0
QcFloat &getVar (unsigned i)
{ return LinPoly().GetTerm (i).GetVariable(); }
#endif
int getVarId (unsigned i) const
{ return getVar(i).Id(); }
numT RHS() const
{ return fRHS; }
long Magic() const
{ return fMagic; }
const char *Name() const;
bool operator<(const QcConstraintRep &other) const
// The comparisons are for when QcConstraintRep is used as an
// identifier and compares instances not structure.
// General pointer inequality comparisons are not reliable
// (see the C++ ARM section 5.9), fId is provided for this.
/* [pjm:] Another reason for comparing ids rather than pointers is for
weighted constraints, where we generate a new constraint object
with the same id. The ids need to be the same so that
changeRHS,removeConstraint work. See
QcSolver::AddConstraint(QcConstraint c, numT weight) for where
these half-copies are created. */
{ return (fId < other.fId); }
#if 0
bool operator==(const QcConstraintRep &other) const
{ return (fId == other.fId); }
bool operator!=(const QcConstraintRep &other) const
{ return (fId != other.fId); }
#endif
void assertInvar() const;
//-----------------------------------------------------------------------//
// Manipulation functions //
//-----------------------------------------------------------------------//
virtual void SetLinPoly(QcLinPoly &p)
{ fLinPoly = p; }
virtual void SetRHS(numT rhs)
{ fRHS = rhs; }
virtual void SetOperator(TOp op)
{ fOperator = op; }
virtual void SetName(const char *n);
void Decrease()
// Called when number of references decreases
{
fCounter--;
qcAssertPre(fCounter >= 0);
}
void Drop()
{
Decrease();
if (fCounter != 0)
return;
dbg(assertInvar());
delete this;
}
bool FreeName();
// Deallocates old name string checking magic4.
// Returns success indicator.
void Increase()
// Call when number of references increases
{ fCounter++; }
void Reset(); // Set variables to defaults
/** Returns true iff this constraint is satisfied or
<tt>QcUtility.isZero(LHS - RHS)</tt>. The current implementation
ignores the possibility of NaN or infinity problems. */
bool isSatisfied() const;
//-----------------------------------------------------------------------//
// Utility functions //
//-----------------------------------------------------------------------//
virtual void Print(ostream &os) const;
protected:
static TId fNextValidId;
static const TId fInvalidId;
// InvalidId is currently set to 0.
// All negative values are reserved for future use.
void Initialize(const char *n, const QcLinPoly& lp, const TOp op);
// Allocate the representation record, set indicated values, set
// other representation variables to default values and call Reset.
private:
long fMagic; // To detect corruption.
long fCounter; // Reference count.
TId fId; // Used as index key and for operator <.
QcLinPoly fLinPoly; // The constraint variable coeffs.
TOp fOperator; // The relation.
numT fRHS; // The RHS value.
char *fName; // 0 or a heap allocated string with hidden
// prefix.
};
#ifdef QOCA_INTERNALS
# if defined(qcCheckPre) || defined(qcCheckPost)
# define VALID_OP(_op) ((_op) >= 0 && (_op) <= coLastOp)
# endif
#endif
inline QcConstraintRep::QcConstraintRep()
: fRHS( 0)
{
Initialize("", QcLinPoly(), coEQ);
}
inline QcConstraintRep::QcConstraintRep(const QcLinPoly &lp)
: fRHS( 0)
{
Initialize("", lp, coEQ);
}
inline QcConstraintRep::QcConstraintRep(const QcLinPoly &lp, TOp op)
: fRHS( 0)
{
Initialize("", lp, op);
}
inline QcConstraintRep::QcConstraintRep(const QcLinPoly &lp, TOp op, numT rhs)
: fRHS( rhs)
{
Initialize("", lp, op);
}
inline QcConstraintRep::QcConstraintRep(char const *name)
: fRHS( 0)
{
Initialize(name, QcLinPoly(), coEQ);
}
inline QcConstraintRep::QcConstraintRep(const char *name, const QcLinPoly &lp)
: fRHS( 0)
{
Initialize(name, lp, coEQ);
}
inline QcConstraintRep::QcConstraintRep(char const *name, const QcLinPoly &lp,
TOp op)
: fRHS( 0)
{
Initialize(name, lp, op);
}
inline QcConstraintRep::QcConstraintRep(const char *name, const QcLinPoly &lp,
TOp op, numT rhs)
: fRHS( rhs)
{
Initialize(name, lp, op);
}
inline const char *QcConstraintRep::Name() const
{
if (fName == 0)
return 0;
return (fName + qcConstraintMagic2Len);
}
inline void QcConstraintRep::Reset()
{
fCounter = 1;
fId = fNextValidId++;
qcAssertInvar(fNextValidId > 0);
}
/** Returns true iff this constraint is satisfied or
<tt>QcUtility.isZero(LHS - RHS)</tt>. The current implementation
ignores the possibility of NaN or infinity problems. */
inline bool QcConstraintRep::isSatisfied() const
{
numT x = fLinPoly.getValue() - fRHS;
if (QcUtility::IsZero (x))
return true;
switch (fOperator) {
case coEQ:
return false;
case coLE:
return x < 0;
case coGE:
return x > 0;
}
qcDurchfall("fOp " + fOperator);
abort();
}
#if !qcCheckInternalInvar
inline void QcConstraintRep::assertInvar() const
{ }
#endif
#ifndef qcNoStream
inline ostream &operator<<(ostream &os, const QcConstraintRep &r)
{
r.Print(os);
return os;
}
#endif
struct QcConstraintRep_hash
{
size_t operator()(QcConstraintRep const *c) const
{
return (size_t) c->Id();
}
};
struct QcConstraintRep_equal
{
size_t operator()(QcConstraintRep const *c1,
QcConstraintRep const *c2) const
{
return c1->Id() == c2->Id();
}
};
#endif /* !__QcConstriantRepH */

View File

@ -1,251 +0,0 @@
// $Id: QcCoreTableau.cc,v 1.12 2001/01/30 01:32:07 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include "qoca/QcDefines.hh"
#include "qoca/QcCoreTableau.hh"
#include "qoca/QcRowAdaptor.hh"
unsigned QcCoreTableau::AddRow(QcRowAdaptor &varCoeffs, numT rhs)
{
unsigned r = 0; // Row of fA, col of fM, int for original constraint
int quasiRow; // Row of fM, int for solved form constraint
// Look for a deleted row or create a new row if one not found
while (r < fRows && !GetARowDeleted(r))
r++;
if (r == fRows) {
dbg(unsigned r1 =)
IncreaseRows();
assert( r == r1);
quasiRow = GetMRowIndex(r);
qcAssert( quasiRow == (int) r); // Currently IncreaseRows ensures this
} else {
quasiRow = GetMRowIndex(r);
SetARowDeleted(r, false);
SetMRowDeleted(quasiRow, false);
}
qcAssert(GetRawRHS(r) == 0.0);
// Load the new values into the fA matrix and RHS
SetRawRHS(r, rhs);
fSF.SetRHS(quasiRow, rhs);
while (!varCoeffs.AtEnd()) {
qcAssert(varCoeffs.getIndex() < fColumns);
#ifdef qcSafetyChecks
if (QcUtility::IsZero( varCoeffs.getValue()))
throw QcWarning(qcPlace, "AddRow: Zero coeff supplied");
#endif
fSF.SetValue(quasiRow, varCoeffs.getIndex(), varCoeffs.getValue());
varCoeffs.Increment();
}
return r;
}
#ifndef NDEBUG
void
QcCoreTableau::assertInvar() const
{
// A few important basic checks
assert( fAllocRows >= fRows &&
fAllocColumns >= fColumns);
// Check matrices and vectors are the right size
assert( (fRowColState.fRowState->GetSize() == fRows)
&& (fOrigRowState.GetSize() == fRows));
// Now check a few integrity constraints for row state data
for (unsigned r = 0; r < fRows; r++)
{
// First consider r as indexing rows of fM
{
int rARowIx = GetARowIndex( r);
assert( (rARowIx == QcTableau::fInvalidConstraintIndex)
|| ((unsigned) rARowIx < fRows));
if (GetMRowDeleted( r))
{
assert( (r == (unsigned) GetMRowIndex( rARowIx))
&& GetARowDeleted( rARowIx));
}
}
// Now consider r as indexing rows of fA (and hence columns of fM)
{
int rMRowIx = GetMRowIndex( r);
assert( (rMRowIx == QcTableau::fInvalidConstraintIndex)
|| ((unsigned) rMRowIx < fRows));
if (GetARowDeleted( r))
{
assert( (r == (unsigned) GetARowIndex( rMRowIx))
&& GetMRowDeleted( rMRowIx));
}
}
}
}
#endif
int QcCoreTableau::DeleteRow(unsigned ci)
{
int quasiRow = GetMRowIndex(ci);
qcAssert(GetARowIndex(quasiRow) == (int) ci);
SetMRowDeleted(quasiRow, true);
SetARowDeleted(ci, true);
fSF.ZeroRow(quasiRow);
SetRawRHS(ci, 0.0);
return quasiRow;
}
unsigned QcCoreTableau::IncreaseColumns()
{
qcAssert(fColumns <= fAllocColumns);
if (fColumns == fAllocColumns) {
fAllocColumns += (fAllocColumns == 0) ? 1 : fAllocColumns;
fSF.Reserve(fAllocRows, fAllocColumns);
fRowColState.fColState->Reserve(fAllocColumns);
}
fColumns++;
fSF.Resize(fRows, fColumns);
fRowColState.fColState->Resize(fColumns);
// Set the default data values for the newly added column.
fSF.ZeroColumn(fColumns - 1);
return fColumns - 1;
}
unsigned QcCoreTableau::IncreaseRows() // Add an extra row
{
assert( fRows <= fAllocRows);
if (fRows == fAllocRows) {
fAllocRows += (fAllocRows == 0) ? 1 : fAllocRows;
fSF.Reserve(fAllocRows, fAllocColumns);
fRowColState.fRowState->Reserve(fAllocRows);
fOrigRowState.Reserve(fAllocRows);
}
fRows++;
fSF.Resize(fRows, fColumns);
fRowColState.fRowState->Resize(fRows);
fOrigRowState.Resize(fRows);
// Set the default data values for the newly added row.
fSF.ZeroRow(fRows - 1);
return fRows - 1;
}
void QcCoreTableau::Initialize(unsigned hintRows, unsigned hintCols)
{
qcAssertPre ((int) hintRows >= 0);
qcAssertPre ((int) hintCols >= 0);
fAllocRows = hintRows;
fAllocColumns = hintCols;
fSF.Reserve(hintRows, hintCols);
fRowColState.Reserve(hintRows, hintCols);
fOrigRowState.Reserve(hintRows);
fRows = 0;
fColumns = 0;
}
void QcCoreTableau::Print(ostream &os) const
{
os << "QcCoreTableau with " << fRows << " rows and "
<< fColumns << " cols." << endl;
os << "==========================================================" << endl;
os << "Raw RHS: ";
for (unsigned i = 0; i < fRows; i++)
os << "\t" << GetRawRHS(i);
os << endl;
os << "Deleted rows of fM are: ";
for (unsigned i = 0; i < fRows; i++)
if (GetMRowDeleted(i))
os << "\t" << i;
os << endl;
os << "Deleted rows of fA are: ";
for (unsigned i = 0; i < fRows; i++)
if (GetARowDeleted(i))
os << "\t" << i;
os << endl << "Quasi RowState: ";
fRowColState.fRowState->Print(os);
fOrigRowState.Print(os);
}
void QcCoreTableau::Restart()
{
fRows = 0;
fColumns = 0;
fSF.Restart();
fRowColState.Restart();
fOrigRowState.Resize(0);
}
void QcCoreTableau::Restore()
{
unsigned co; // original constraint index (row of fA)
unsigned cs; // solved form constraint index (row of fM)
// Reset constraint state information
for (cs = 0, co = 0; cs < fRows; cs++, co++) {
// Find next undeleted constraint
while (cs < fRows && GetMRowDeleted(cs))
++cs;
while (co < fRows && GetARowDeleted(co))
++co;
if (co < fRows) {
qcAssert(cs < fRows);
qcAssert(!GetARowDeleted(co));
qcAssert(!GetMRowDeleted(cs));
fSF.ZeroRow(cs);
fSF.SetRHS(cs, fOrigRowState.GetRHS(co));
SetMRowIndex(co, cs);
SetARowIndex(cs, co);
// N.B. We permit Reset to change the co<->cs relationship for
// a previously invalid constraint. As long as they
// are empty it doesn't matter which are used.
} else
break;
}
// Fix row and column linked lists.
fRowColState.fRowState->FixLinkage();
fRowColState.fColState->FixLinkage();
dbg(assertInvar());
}

View File

@ -1,278 +0,0 @@
// $Id: QcCoreTableau.hh,v 1.13 2001/01/30 01:32:07 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//----------------------------------------------------------------------------//
#ifndef __QcCoreTableauH
#define __QcCoreTableauH
#include "qoca/QcSolvedFormMatrix.hh"
#include "qoca/QcQuasiRowColStateVector.hh"
#include "qoca/QcOrigRowStateVector.hh"
#include "qoca/QcUtility.hh"
class QcRowAdaptor;
/** At this level it is important to understand the relationship between rows
and columns of fM and fA in the quasi representation. Each solved form
constraint coefficient is represented in a decomposed form. Rows of fM
correspond to constraints and a CIndex constraint iterator Index field
indicates which row of fM this is. For each constraint there is a row of fA
and both a row and a column of fM. However, once a constraint has been
assigned a basic variable (via Pivot), there is no association between the
corresponding row of fM and any particular row of fA. The constraint coeff
(ci,vi) is the dot product of a row of fM and a column of fA (ignoring
deleted entries). The column is given by vi directly. The row of fM is
ci->MRowIndex. The QuasiRowState structure provides information about rows
of fA as well as rows of fM. For example ARowDeleted.
ARowDeleted(ci) means row ci of fA, row MRowIndex(ci) of fM and column ci of
fM corrrespond to a deleted constraint. ARowDeleted(ci) &rArr;
MRowDeleted(MRowIndex(ci)).
**/
class QcCoreTableau
{
public:
/** Solved form. */
QcSolvedFormMatrix fSF;
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcCoreTableau( QcQuasiRowColStateVector &rcs);
QcCoreTableau( unsigned hintRows, unsigned hintCols,
QcQuasiRowColStateVector &rcs);
virtual ~QcCoreTableau() { }
#ifndef NDEBUG
void assertInvar() const;
void assertDeepInvar() const
{
assertInvar();
fSF.assertDeepInvar();
}
virtual void vAssertDeepInvar() const
{
assertDeepInvar();
}
#endif
//-----------------------------------------------------------------------//
// Query functions. //
//-----------------------------------------------------------------------//
/** Get RHS for solved form constraint <tt>ci</tt>.
If <tt>GetMRowDeleted(ci))</tt> then return 0.
@precondition <tt>ci &lt; getNRows()</tt>
**/
virtual numT GetRHS(unsigned ci) const;
/** Get coefficient for variable vi in constraint ci.
If <tt>GetMRowDeleted(ci))</tt> then return 0.
<P>(One reason that GetRHS and GetValue work for deleted constraints
(returning 0) is to satisfy the RowCol interface.)
@precondition <tt>ci &lt; getNRows()</tt>
@precondition <tt>vi &lt; getNColumns()</tt>
**/
virtual numT GetValue(unsigned ci, unsigned vi) const;
unsigned GetAllocRows() const
{ return fAllocRows; }
unsigned GetAllocCols() const
{ return fAllocColumns; }
unsigned GetColumns() const
{ return fColumns; }
bool GetARowDeleted(unsigned ci) const
{ return fOrigRowState.GetARowDeleted(ci); }
int GetARowIndex(unsigned ci) const
{ return fRowColState.fRowState->GetARowIndex(ci); }
bool GetMRowDeleted(unsigned ci) const
{ return fRowColState.fRowState->GetMRowDeleted(ci); }
int GetMRowIndex(unsigned ci) const
{ return fOrigRowState.GetMRowIndex(ci); }
numT GetRawRHS(unsigned ci) const // The orginal constraint RHS
{ return fOrigRowState.GetRHS(ci); } // Don't confuse this with GetRHS
QcQuasiRowColStateVector &GetRowColState() const
{ return fRowColState; }
unsigned GetRows() const
{ return fRows; }
bool IsValidOCIndex(int ci) const
{ return ((unsigned) ci < fRows && !GetARowDeleted(ci)); }
bool IsValidCIndex(int ci) const
{ return ((unsigned) ci < fRows && !GetMRowDeleted(ci)); }
bool IsValidVIndex(int vi) const
{ return ((unsigned) vi < fColumns); }
//-----------------------------------------------------------------------//
// Manipulation functions. //
//-----------------------------------------------------------------------//
/** Add a new row, allocating any new columns indicated.
@return The new row index.
**/
virtual unsigned AddRow(QcRowAdaptor &varCoeffs, numT rhs);
virtual void AddScaledRow(unsigned destRow, unsigned srcRow, numT factor)
{ fSF.AddScaledRow(destRow, srcRow, factor); }
virtual void ChangeRHS(unsigned ci, numT rhs)
// Change the RHS of the constraint ci.
{ SetRawRHS(ci, rhs); }
virtual int DeleteRow(unsigned ci);
// Deletes a row given an original constraint index by setting all
// the coefficients to zero and marking the row as deleted.
// Derived classes use this method to delete constraints
// which are found to be inconsistant after a successful AddEq
// (i.e. unable to successfully pivot).
virtual unsigned IncreaseColumns(); // Creates a new non-basic variable
virtual unsigned IncreaseRows(); // Creates a new redundant constraint
virtual void Initialize(unsigned hintRows, unsigned hintCols);
// Call this after construction.
#if 0
virtual void LinkRow(unsigned ci)
// Add row ci to the row list.
{ fRowColState.fRowState->LinkRow(ci); }
#endif
/** Force the RHS of row <tt>ci</tt> to be non-negative, by negating the
row iff its RHS was negative.
@precondition <tt>ci &lt; getNRows()</tt>
**/
virtual void Normalize(unsigned ci);
virtual void Restart(); // Erase everything ready to start afresh.
virtual void Restore();
// The tableau is reinitialised as if all the original constraints
// had been added to a fresh tableau using AddEq but with no
// Elimination or Pivoting having been done.
virtual void ScaleRow(unsigned row, numT factor)
{ fSF.ScaleRow(row, factor); }
virtual void CopyColumn(unsigned destCol, unsigned srcCol)
{ fSF.CopyColumn(destCol, srcCol); }
void SetARowDeleted(unsigned ci, bool d)
{ fOrigRowState.SetARowDeleted(ci, d); }
void SetARowIndex(unsigned ci, int i)
{ fRowColState.fRowState->SetARowIndex(ci, i); }
void SetMRowDeleted(unsigned ci, bool d)
{ fRowColState.fRowState->SetMRowDeleted(ci, d); }
void SetMRowIndex(unsigned ci, int i)
{ fOrigRowState.SetMRowIndex(ci, i); }
void SetRawRHS(unsigned ci, numT rhs) // The orginal constraint RHS
{ fOrigRowState.SetRHS(ci, rhs); }
//-----------------------------------------------------------------------//
// Utility functions. //
//-----------------------------------------------------------------------//
virtual void Print(ostream &os) const;
protected:
QcQuasiRowColStateVector &fRowColState;
QcOrigRowStateVector fOrigRowState; // 0..fRow-1
unsigned fRows;
unsigned fColumns;
unsigned fAllocRows;
unsigned fAllocColumns;
};
inline QcCoreTableau::QcCoreTableau(QcQuasiRowColStateVector &rcs)
: fRowColState(rcs)
{
}
inline QcCoreTableau::QcCoreTableau(unsigned hintRows, unsigned hintCols,
QcQuasiRowColStateVector &rcs)
: fRowColState(rcs)
{
Initialize(hintRows, hintCols);
}
inline numT QcCoreTableau::GetRHS(unsigned ci) const
{
qcAssertPre (ci < fRows);
if (GetMRowDeleted(ci))
return 0.0;
return fSF.GetRHS(ci);
}
inline numT QcCoreTableau::GetValue(unsigned ci, unsigned vi) const
{
qcAssertPre (ci < fRows);
qcAssertPre (vi < fColumns);
if (GetMRowDeleted(ci))
return 0.0;
return fSF.GetValue(ci, vi);
}
inline void QcCoreTableau::Normalize(unsigned ci)
{
if (QcUtility::IsNegative(GetRHS(ci)))
fSF.NegateRow( ci);
}
#ifndef qcNoStream
inline ostream &operator<<(ostream &os, const QcCoreTableau &t)
{
t.Print(os);
return os;
}
#endif
#endif

View File

@ -1,191 +0,0 @@
// $Id: QcDefines.hh,v 1.16 2001/01/31 07:37:13 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcDefinesH
#define __QcDefinesH
#define qcQuantum 64
#define qcHashTableInitCapacity 256
#define qcVectorInitCapacity 256
#define qcMatrixInitRowCapacity 256
#define qcMatrixInitColCapacity 256
#define qcTableauInitRowCapacity 256
#define qcTableauInitColCapacity 256
#define qcMaxLoopCycles 10000
#define qcOneMegaBytes 1048576
#define qcOneKiloBytes 1024
#ifdef USE_RATIONALS
# define NUMT_IS_PJM_MPQ 1
#else
# define NUMT_IS_DOUBLE 1
#endif
#include <qoca/arith.H>
#define qcCheckInput 1
/* Simply #defining qcOneDirectionalSparseMatrix (i.e. use
singly-linked lists for the sparse matrices) without any other
changes is probably a bad idea, due to removal costs. However,
using one directional linked lists for the row iterating linked
lists is just about feasible, since usually we reach the element by
traversing the row linked lists anyway, so we should already have a
pointer to the previous element as an auto variable.
Alternatively, don't immediately unlink things. (In this case, do
consider whether it's safe to unlink from one list without
unlinking from the other.) */
//#define qcOneDirectionalSparseMatrix
//#define qcDenseQuasiInverse
// Note: currently still crashes if defined.
//#define qcSafetyChecks 1
/* qcUseSafeIterator is of limited use; consider removing the code used ifdef
qcUseSafeIterator. Use it if you don't trust the sparse iterators. However,
note that it doesn't actually test the correctness of the sparse iterator, it
just uses a dense one instead. Note that if sparse iterators are erroneous,
then the program will probably still go wrong. */
//#define qcUseSafeIterator
#ifndef NDEBUG
# define qcCheckPre 1
# define qcCheckPost 1
# define qcCheckInternalPre 1
# define qcCheckInternalPost 1
#endif
#define qcRealTableauCoeff
#define qcRealTableauRHS
#define qcUseExceptions
#ifdef qcUseExceptions
# include "qoca/QcException.hh"
#endif
#define qcInvalidInt -1
// Used in QcBimap.h and must be the value used for invalid
// int and int for this reason.
#define FUNCTION_H
// STL function.h creates problems due to dumb template operators.
#include <float.h>
#if qcCheckInternalPre || qcCheckInternalPost
# define qcCheckInternalInvar 1
#endif
#ifndef NDEBUG
# define qcBoundsChecks 1
#endif
#ifdef qcSafetyChecks
# define qcBoundsChecks 1
# define QcAssertions 1
#endif
#if defined(qcSafetyChecks) || qcCheckPre || qcCheckPost || qcCheckInternalPre || qcCheckInternalPost
# include <assert.h>
#endif
#ifdef NDEBUG
# define dbg(_expr)
#else
# define dbg(_expr) _expr
#endif
#define showplace() do { cout << "DBG: " << __FILE__ << ':' << __LINE__ << endl; } while(false)
#define qcPlace __FILE__,__LINE__
#ifdef QcAssertions
//# define qcAssert(i) ((i)? 0: (throw QcWarning(qcPlace, "Assertion failed"), 0))
# define qcAssert(i) assert(i)
#else
# define qcAssert(i)
#endif
#if qcCheckPre
/* TODO: We could prepend a "Pre..." / "Post..." string. */
# define qcAssertExternalPre(_p) assert(_p)
# define qcAssertPre(_p) assert(_p)
# define qcAssertExpensivePre(_p) assert(_p)
# define dbgPre(_expr) _expr
#else
# define qcAssertExternalPre(_p) do { } while(0)
# define qcAssertPre(_p) do { } while(0)
# define dbgPre(_expr)
#endif
#if qcCheckPost
# define qcAssertExternalPost(_p) assert(_p)
# define qcAssertPost(_p) assert(_p)
# define dbgPost(_expr) _expr
#else
# define qcAssertExternalPost(_p) do { } while(0)
# define qcAssertPost(_p) do { } while(0)
# define dbgPost(_expr)
#endif
#if qcCheckInternalPre
# define qcDurchfall(_s) assert(0 && "Durchfall on " _s)
#else
# define qcDurchfall(_s) do { } while(0)
#endif
#if qcCheckInternalInvar
# define qcAssertInvar(_p) assert(_p)
#else
# define qcAssertInvar(_p) do { } while(0)
#endif
#ifndef UNUSED
# define UNUSED(_var) ((void) (_var))
#endif
#define CAST(_newtype, _expr) \
(\
assert (dynamic_cast<_newtype> (_expr) != 0), \
(_newtype) (_expr) \
)
#ifndef qcNoStream
# include <iostream>
using namespace std;
#endif
/* TODO: Maybe use autoconf to detect this. (OTOH, I imagine that
most such primitive environments would be non-Un*x anyway.) */
#ifdef qcDefineBool
# include <bool.h> // Use this while using STL and no built in bool
#endif
// This is needed if we use the STL provided with Borland C++
#ifdef __BCPLUSPLUS__
# define RWSTD_NO_NAMESPACE
#endif
#endif

View File

@ -1,452 +0,0 @@
// $Id: QcDelCoreTableau.cc,v 1.16 2001/01/31 10:03:35 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include "qoca/QcDefines.hh"
#include "qoca/QcSparseMatrixRowIterator.hh"
#include "qoca/QcDenseMatrixColIterator.hh"
#include "qoca/QcDelCoreTableau.hh"
#include "qoca/QcRowAdaptor.hh"
unsigned QcDelCoreTableau::AddRow(QcRowAdaptor &varCoeffs, numT rhs)
{
unsigned r = 0; // Row of fA, col of fM, int for original constraint
int quasiRow; // Row of fM, int for solved form constraint
// Look for a deleted row or create a new row if one not found
while (r < fRows && !GetARowDeleted(r))
r++;
if (r == fRows) {
r = IncreaseRows();
quasiRow = GetMRowIndex(r);
qcAssert(quasiRow == (int) r); // Currently IncreaseRows ensures this
} else {
quasiRow = GetMRowIndex(r);
fM.SetValue(quasiRow, r, 1.0);
SetARowDeleted(r, false);
SetMRowDeleted(quasiRow, false);
}
#ifdef qcSafetyChecks
for (unsigned j = 0; j < fColumns; j++)
qcAssert(fA.GetValue(r, j) == 0);
qcAssert(GetRawRHS(r) == 0.0);
for (unsigned i = 0; i < fRows; i++) {
if (i != r)
qcAssert(fM.GetValue(quasiRow, i) == 0.0); // quasiRow of fM
if ((int) i != quasiRow)
qcAssert(fM.GetValue(i, r) == 0.0); // column r of fM
}
qcAssert(fM.GetValue(quasiRow, r) == 1);
#endif
// Load the new values into the fA matrix and RHS
SetRawRHS(r, rhs);
fSF.SetRHS(quasiRow, rhs);
while (!varCoeffs.AtEnd()) {
assert( varCoeffs.getIndex() < fColumns);
#ifdef qcSafetyChecks
if (QcUtility::IsZero( varCoeffs.getValue()))
throw QcWarning(qcPlace, "AddRow: Zero coeff supplied");
#endif
fA.SetValue(r, varCoeffs.getIndex(), varCoeffs.getValue());
fSF.SetValue(quasiRow, varCoeffs.getIndex(), varCoeffs.getValue());
varCoeffs.Increment();
}
return r;
}
void QcDelCoreTableau::ChangeRHS(unsigned ci, numT rhs)
{
#ifdef qcRealTableauRHS
numT diff = rhs - GetRawRHS( ci);
if(!QcUtility::IsZero( diff))
{
# ifdef qcDenseQuasiInverse
QcDenseMatrixColIterator colIt( fM, ci);
# else
QcSparseMatrixColIterator colIt( fM, ci);
# endif
assert( GetRows() == fM.getNRows());
for(; !colIt.AtEnd(); colIt.Increment())
{
unsigned i = colIt.getIndex();
if(!GetMRowDeleted( i))
fSF.IncreaseRHS( i, colIt.getValue() * diff);
}
}
#endif
QcCoreTableau::ChangeRHS( ci, rhs);
}
void QcDelCoreTableau::DecreaseColumns(QcBiMapNotifier &note)
// Get rid of last column provided the variable is not used.
{
qcAssert(fColumns > 0);
qcAssert(IsFree(fColumns - 1));
fColumns--;
fA.Resize(fRows, fColumns);
fRowColState.fColState->Resize(fColumns);
note.DropVariable(fColumns);
fSF.Resize(fRows, fColumns);
}
void QcDelCoreTableau::DecreaseRows(QcBiMapNotifier &note)
// Get rid of the last row - provided it is a deleted row for
// both original and solved form constraint.
// N.B. The deleted solved form and original constaint need
// not correspond to each other.
{
qcAssert(fRows > 0);
qcAssert(GetARowDeleted(fRows - 1));
qcAssert(GetMRowDeleted(fRows - 1));
int AIndex = GetARowIndex(fRows - 1);
int MIndex = GetMRowIndex(fRows - 1);
// If the last (deleted) original and solved form constraints
// don't correspond then swap the indices around so there will
// be no invalid indices after this routine finishes.
if (AIndex != (int) fRows - 1) {
qcAssert(MIndex != (int) fRows - 1);
SetMRowIndex(AIndex, MIndex);
SetARowIndex(MIndex, AIndex);
}
fRows--;
fM.Resize(fRows, fRows);
fA.Resize(fRows, fColumns);
fSF.Resize(fRows, fColumns);
fRowColState.fRowState->Resize(fRows);
fOrigRowState.Resize(fRows);
note.DropConstraint(fRows);
}
numT QcDelCoreTableau::GetRHSVirtual(unsigned ci) const
// See note for GetValue member
{
qcAssertPre (ci < fRows);
if (GetMRowDeleted(ci))
return 0.0;
numT sum = 0.0;
for (unsigned i = 0; i < fRows; i++)
sum += fM.GetValue(ci, i) * GetRawRHS(i);
return QcUtility::Zeroise(sum);
}
numT QcDelCoreTableau::GetValueVirtual(unsigned ci, unsigned vi) const
{
qcAssertPre( ci < fRows);
qcAssertPre( vi < fColumns);
numT sum( 0);
if (GetMRowDeleted( ci))
return sum;
for (QcSparseMatrixColIterator varcol( fA, vi);
!varcol.AtEnd();
varcol.Increment())
{
sum += (fM.GetValue( ci, varcol.getIndex())
* varcol.getValue());
}
return QcUtility::Zeroise(sum);
}
unsigned QcDelCoreTableau::IncreaseColumns()
// Add and extra column
{
qcAssert(fColumns <= fAllocColumns);
if (fColumns == fAllocColumns) {
fAllocColumns += (fAllocColumns == 0) ? 8 : fAllocColumns;
fA.Reserve(fAllocRows, fAllocColumns);
fSF.Reserve(fAllocRows, fAllocColumns);
fRowColState.fColState->Reserve(fAllocColumns);
}
fColumns++;
fA.Resize(fRows, fColumns);
fRowColState.fColState->Resize(fColumns);
fSF.Resize(fRows, fColumns);
// Set the default data values for the newly added column
fA.ZeroColumn(fColumns - 1);
fSF.ZeroColumn(fColumns - 1);
return fColumns - 1;
}
unsigned QcDelCoreTableau::IncreaseRows()
// Add an extra row
{
qcAssert(fRows <= fAllocRows);
if (fRows == fAllocRows) {
fAllocRows += (fAllocRows == 0) ? 8 : fAllocRows;
fA.Reserve(fAllocRows, fAllocColumns);
fM.Reserve(fAllocRows, fAllocRows);
fSF.Reserve(fAllocRows, fAllocColumns);
fRowColState.fRowState->Reserve(fAllocRows);
fOrigRowState.Reserve(fAllocRows);
}
fRows++; // logically, these 3 lines are where the
fA.Resize(fRows, fColumns); // number of rows increases, the optimiser
fM.Resize(fRows, fRows); // should cache the (fRows-1) that follow.
fSF.Resize(fRows, fColumns);
fRowColState.fRowState->Resize(fRows);
fOrigRowState.Resize(fRows);
// Set the default data values for the newly added row
fA.ZeroRow(fRows - 1);
fM.ZeroRow(fRows - 1);
fM.ZeroColumn(fRows - 1);
fM.SetValue(fRows - 1, fRows - 1, 1.0);
fSF.ZeroRow(fRows - 1);
return fRows - 1;
}
bool QcDelCoreTableau::IsValidSolvedForm() const
{
/* effic: Use iterators. */
for (unsigned i = 0; i < fRows; i++)
{
for (unsigned j = 0; j < fColumns; j++)
{
// TODO: Should be numRefT.
numT val_ij( GetValue( i, j));
numT virt_val_ij( GetValueVirtual( i, j));
if (QcUtility::IsZero( val_ij)
? !QcUtility::IsZero( virt_val_ij)
: !QcUtility::IsVaguelyZero( virt_val_ij - val_ij))
return false;
}
numT rhs_i( GetRHS( i));
numT virt_rhs_i( GetRHSVirtual( i));
if (QcUtility::IsZero( rhs_i)
? !QcUtility::IsZero( virt_rhs_i)
: !QcUtility::IsVaguelyZero( virt_rhs_i - rhs_i))
return false;
}
return true;
}
void QcDelCoreTableau::Print(ostream &os) const
{
os << "QcDelCoreTableau with " << fRows << " rows and ";
os << fColumns << " cols." << endl;
os << "==========================================================" << endl;
os << "Quasi Inverse Matrix:" << endl << fM << endl;
os << "Constraint Matrix:" << endl << fA << endl;
os << "Raw RHS: ";
for (unsigned i = 0; i < fRows; i++)
os << "\t" << GetRawRHS(i);
os << endl;
os << "Deleted rows of fM are: ";
for (unsigned i = 0; i < fRows; i++)
if (GetMRowDeleted(i))
os << "\t" << i;
os << endl;
os << "Deleted rows of fA are: ";
for (unsigned i = 0; i < fRows; i++)
if (GetARowDeleted(i))
os << "\t" << i;
os << endl << "Quasi RowState: ";
fRowColState.fRowState->Print(os);
os << "Quasi OrigRowState: ";
fOrigRowState.Print(os);
}
void QcDelCoreTableau::PivotQuasiInverse(unsigned row, unsigned col)
{
#ifdef qcRealTableauCoeff
numT p = fM.GetValue(row, col);
qcAssertPre( !QcUtility::IsZero(p));
ScaleRow( row, recip( p));
# ifdef qcDenseQuasiInverse
for (QcDenseMatrixColIterator colCoeffs( fM, col);
!colCoeffs.AtEnd();
colCoeffs.Increment())
{
if (colCoeffs.getIndex() != row)
AddScaledRow( colCoeffs.getIndex(), row, -colCoeffs.getValue());
}
# elif defined(qcUseSafeIterator)
for (unsigned i = 0; i < fM.GetRows(); i++)
{
if (i != (unsigned) row)
AddScaledRow( i, row, -fM.GetValue( i, col));
}
# else
/* Sparse column iterators are not guaranteed to be sane if the underlying
matrix gets modified (here by AddScaledRow), so we cache the column
coefficients in advance. */
{
vector<QcSparseCoeff> coeffCache;
for (QcSparseMatrixColIterator colIt( fM, col);
!colIt.AtEnd();
colIt.Increment())
{
unsigned i = colIt.getIndex();
if(i != row)
coeffCache.push_back( QcSparseCoeff( colIt.getValue(), i));
}
for (vector<QcSparseCoeff>::iterator colIt = coeffCache.begin();
colIt != coeffCache.end();
colIt++)
AddScaledRow( colIt->getIndex(), row, -colIt->getValue());
}
# endif
#else /* !qcRealTableauCoeff */
fM.Pivot( row, col);
#endif
}
void QcDelCoreTableau::Restart()
{
fRows = 0;
fColumns = 0;
fM.Resize(0, 0);
fA.Resize(0, 0);
fSF.Restart();
fRowColState.Restart();
fOrigRowState.Resize(0);
}
void QcDelCoreTableau::Restore()
{
unsigned co; // original constraint index (row of fA)
unsigned cs; // solved form constraint index (row of fM)
// Reset constraint state information
for (cs = 0, co = 0; cs < fRows; cs++, co++)
{
// Find next undeleted constraint
while (cs < fRows && GetMRowDeleted(cs))
++cs;
while (co < fRows && GetARowDeleted(co))
++co;
if (co < fRows)
{
qcAssert( cs < fRows);
qcAssert( !GetARowDeleted( co));
qcAssert( !GetMRowDeleted( cs));
fM.ZeroRow( cs);
fM.ZeroColumn( co);
fM.SetValue( cs, co, 1.0);
fSF.CopyCoeffRow( cs, fA, co);
fSF.SetRHS( cs, fOrigRowState.GetRHS( co));
SetMRowIndex( co, cs);
SetARowIndex( cs, co);
// N.B. We permit Reset to change the co<->cs relationship for
// a previously invalid constraint. As long as they
// are empty it doesn't matter which are used.
}
else
break;
}
// Fix row and column linked lists.
fRowColState.fRowState->FixLinkage();
fRowColState.fColState->FixLinkage();
dbg(assertInvar());
}
void QcDelCoreTableau::TransitiveClosure(vector<unsigned int> &vars) const
{
/* effic: Should use a todo set. Using a todo set is probably O(n), whereas
the current method is probably O(n**2). */
bool checkAgain = true;
if (fColumns == 0 || fRows == 0)
return;
QcSparseMatrixColIterator varCol(fA, 0);
QcSparseMatrixRowIterator varRow(fA, 0);
static vector<bool> fScatchFlags;
fScatchFlags.resize(fColumns);
for (unsigned int i = 0; i < fScatchFlags.size(); i++)
fScatchFlags[i] = false;
for (unsigned int i = 0; i < vars.size(); i++)
fScatchFlags[vars[i]] = true;
while (checkAgain)
{
checkAgain = false;
for (unsigned int i = 0; i < fScatchFlags.size(); i++)
{
if (fScatchFlags[i])
{
for (varCol.SetToBeginOf( i);
!varCol.AtEnd();
varCol.Increment())
{
for (varRow.SetToBeginOf( varCol.GetIndex());
!varRow.AtEnd();
varRow.Increment())
{
if (!fScatchFlags[varRow.GetIndex()])
{
fScatchFlags[varRow.GetIndex()] = true;
vars.push_back( varRow.GetIndex());
checkAgain = true;
}
}
}
}
}
}
}

View File

@ -1,252 +0,0 @@
// $Id: QcDelCoreTableau.hh,v 1.9 2001/01/30 01:32:07 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//----------------------------------------------------------------------------//
// MRowIndex and ARowIndex record associations between rows of fA and fM //
// which are used when a constraint is deleted or not yet in the basis (means //
// the fM[*,Index] is a unit vector, element fM[MRowIndex,Index] is 1.0 and //
// and the other elements are zero). MRowIndex is the row of fM //
// corresponding to column fM[*,Index] of fM and row fA[Index,*] of fA. //
// ARowIndex is the row of fA corresponding to row fM[Index,*]. Unused //
// entries in ARowIndex and MRowIndex are set to -1. Hence MRowIndex and //
// ARowIndex are used to represent inverse indexing functions on a partial //
// domain. //
// EXCEPTION: this rule is currently violated by Pivot. //
// //
// QcDelCoreTableau and QcCoreTableau are only ever used as part of a //
// tableau, but it is not a tableau itself. Deriving a tableau from it //
// requires the use of multiple inheritance. Currently we are trying to //
// avoid multiple inheritance due to the increased risk running into compiler //
// bugs and to facilitate conversion to Java. //
//============================================================================//
#ifndef __QcDelCoreTableauH
#define __QcDelCoreTableauH
#include "qoca/QcCoreTableau.hh"
#include "qoca/QcDenseMatrix.hh"
#include "qoca/QcBiMapNotifier.hh"
#include "qoca/QcSparseMatrixColIterator.hh"
#include "qoca/QcQuasiRowColStateVector.hh"
#include "qoca/QcSparseCoeff.hh"
class QcDelCoreTableau : public QcCoreTableau
{
public:
#ifdef qcDenseQuasiInverse
QcDenseMatrix fM; // fRows x fRows
#else
QcSparseMatrix fM; // fRows x fRows
#endif
QcSparseMatrix fA; // fRows x fCols
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcDelCoreTableau(QcQuasiRowColStateVector &rcs) : QcCoreTableau(rcs) {}
QcDelCoreTableau(unsigned hintRows, unsigned hintCols, QcQuasiRowColStateVector &rcs)
: QcCoreTableau(rcs)
{ Initialize(hintRows, hintCols); }
#ifndef NDEBUG
void assertInvar() const;
void assertDeepInvar() const;
virtual void vAssertDeepInvar() const
{
assertDeepInvar();
}
#endif
//-----------------------------------------------------------------------//
// Enquiry methods. //
//-----------------------------------------------------------------------//
virtual numT GetRHS(unsigned ci) const;
// Get RHS for solved form constraint ci.
virtual numT GetRHSVirtual(unsigned ci) const;
virtual numT GetValue(unsigned ci, unsigned vi) const;
// Get coefficient for variable vi in constraint ci.
// GetVal and GetRHS can be used to access the coefficients
// of deleted constraints (zero is returned). This behaviour is
// required to satisfy the RowCol interface amongst other reasons.
/** Returns (fM &times fA)[ci, vi], i.e.&nbsp;\sum_i&nbsp;fM[ci, i] &times;
fA[i, vi]. As with <tt>GetValue</tt>, deleted rows are treated like
zeroes.
@precondition <tt>ci &lt; fRows</tt>
@precondition <tt>ci &lt; fColumns</tt>
@postcondition <tt>isZeroized( ret)</tt>
**/
virtual numT GetValueVirtual(unsigned ci, unsigned vi) const;
bool IsFree(unsigned vi) const
// Indicates if a particular variable is in use (i.e. has a
// non-zero coefficient in any solved form (or original) constraint.
{ return QcSparseMatrixColIterator(fA, vi).AtEnd(); }
bool IsValidSolvedForm() const;
// For debugging purposes to ensure that the real solved form is
// consistant with the virtual solved form.
//-----------------------------------------------------------------------//
// Manipulation functions. //
//-----------------------------------------------------------------------//
virtual unsigned AddRow(QcRowAdaptor &varCoeffs, numT rhs);
// Add a new row, allocating any new columns indicated.
// The new row index is returned.
virtual void AddScaledRow(unsigned destRow, unsigned srcRow, numT factor);
virtual void ChangeRHS(unsigned ci, numT rhs);
// Change the RHS of the constraint ci.
virtual void DecreaseColumns(QcBiMapNotifier &note);
// Get rid of the last (empty) column.
virtual void DecreaseRows(QcBiMapNotifier &note);
// Get rid of the last (deleted) row.
virtual int DeleteRow(unsigned ci);
// Deletes a row given an original constraint index by setting all
// the coefficients to zero and marking the row as deleted.
// Derived classes use this method to delete constraints
// which are found to be inconsistant after a successful AddEq
// (i.e. unable to successfully pivot) and also used to remove a
// constraint after is has been removed from the basis.
virtual unsigned IncreaseColumns();
// Creates a new non-basic variable.
virtual unsigned IncreaseRows();
// Creates a new redundant constraint.
virtual void Initialize(unsigned hintRows, unsigned hintCols);
// Call this after construction
virtual void Normalize(unsigned ci);
// Normalize the corresponding row fM and fSF if the rhs is negative.
// This makes rhs positive.
virtual void PivotQuasiInverse(unsigned row, unsigned col);
// Pivot on the quasi inverse matrix.
virtual void Restart(); // Erase everything ready to start afresh.
virtual void Restore();
// The tableau is reinitialised as if all the original constraints
// had been added to a fresh tableau using AddEq but with no
// Elimination or Pivoting having been done.
virtual void ScaleRow(unsigned row, numT factor);
virtual void CopyColumn(unsigned destCol, unsigned srcCol);
void TransitiveClosure(vector<unsigned int> &vars) const;
// Compute the transitive closure of a set of variables, using the
// relation "belong to the same original constraint".
//-----------------------------------------------------------------------//
// Utility functions. //
//-----------------------------------------------------------------------//
virtual void Print(ostream &os) const;
};
inline void QcDelCoreTableau::AddScaledRow(unsigned destRow, unsigned srcRow,
numT factor)
{
QcCoreTableau::AddScaledRow(destRow, srcRow, factor);
fM.AddScaledRow(destRow, srcRow, factor);
}
#ifndef NDEBUG
inline void
QcDelCoreTableau::assertInvar() const
{
assert( (fA.GetRows() == fRows)
&& (fA.GetColumns() == fColumns)
&& (fM.GetRows() == fRows)
&& (fM.GetColumns() == fRows));
}
inline void
QcDelCoreTableau::assertDeepInvar() const
{
QcCoreTableau::assertDeepInvar();
fA.assertDeepInvar();
fM.assertDeepInvar();
}
#endif
inline int QcDelCoreTableau::DeleteRow(unsigned ci)
{
int quasiRow = QcCoreTableau::DeleteRow(ci);
fM.ZeroColumn(ci);
fM.ZeroRow(quasiRow);
fA.ZeroRow(ci);
return quasiRow;
}
inline numT QcDelCoreTableau::GetRHS(unsigned ci) const
{
#ifdef qcRealTableauRHS
return QcCoreTableau::GetRHS(ci);
#else
return GetRHSVirtual(ci);
#endif
}
inline numT QcDelCoreTableau::GetValue(unsigned ci, unsigned vi) const
{
#ifdef qcRealTableauCoeff
return QcCoreTableau::GetValue(ci, vi);
#else
return GetValueVirtual(ci, vi);
#endif
}
inline void QcDelCoreTableau::Initialize(unsigned hintRows, unsigned hintCols)
{
QcCoreTableau::Initialize(hintRows, hintCols);
fM.Reserve(hintRows, hintRows);
fA.Reserve(hintRows, hintCols);
}
inline void QcDelCoreTableau::Normalize(unsigned ci)
{
if (QcUtility::IsNegative(GetRHS(ci))) {
fM.NegateRow(ci);
fSF.NegateRow(ci);
}
}
inline void QcDelCoreTableau::ScaleRow(unsigned row, numT factor)
{
QcCoreTableau::ScaleRow(row, factor);
fM.ScaleRow(row, factor);
}
inline void QcDelCoreTableau::CopyColumn(unsigned destCol, unsigned srcCol)
{
QcCoreTableau::CopyColumn( destCol, srcCol);
fA.CopyColumn( destCol, srcCol);
}
#ifndef qcNoStream
inline ostream &operator<<(ostream &os, const QcDelCoreTableau &t)
{
t.Print(os);
return os;
}
#endif
#endif

View File

@ -1,109 +0,0 @@
// $Id: QcDelLinEqSystem.hh,v 1.6 2001/01/30 01:32:07 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcDelLinEqSystemH
#define __QcDelLinEqSystemH
#include "qoca/QcLinEqSystem.hh"
#include "qoca/QcDelLinEqTableau.hh"
/** Version of QcLinEqSystem that allows <tt>removeConstraint</tt>.
<p>Note that this interface needs to be read in conjuction with that of
<tt>QcSolver</tt>.
**/
class QcDelLinEqSystem : public QcLinEqSystem
{
public:
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcDelLinEqSystem();
QcDelLinEqSystem(unsigned hintRows, unsigned hintCols);
QcDelLinEqSystem(QcLinEqTableau &tab);
//-----------------------------------------------------------------------//
// Variable management methods (see QcSolver.java for descriptions) //
//-----------------------------------------------------------------------//
virtual bool RemoveVar(QcFloat &v);
//-----------------------------------------------------------------------//
// Enquiry functions for variables //
//-----------------------------------------------------------------------//
virtual bool IsFree(QcFloat const &v) const
{ return fTableau.IsFree(fVBiMap.Index(v)); }
//-----------------------------------------------------------------------//
// High Level Edit Variable Interface for use by solver clients. //
// The methods addEditVar and endEdit are more efficient than the ones //
// inherited from Solver since variable weights have no effect on //
// QcLinEqSystem::Resolve. //
//-----------------------------------------------------------------------//
virtual void TransitiveClosure(vector<unsigned int> &vars)
{ fTableau.TransitiveClosure(vars); }
//-----------------------------------------------------------------------//
// Constraint management methods //
//-----------------------------------------------------------------------//
virtual bool RemoveConstraint(QcConstraint &c);
};
inline QcDelLinEqSystem::QcDelLinEqSystem()
: QcLinEqSystem(*new QcDelLinEqTableau(0, 0, fNotifier))
{
}
inline QcDelLinEqSystem::QcDelLinEqSystem(unsigned hintRows, unsigned hintCols)
: QcLinEqSystem(*new QcDelLinEqTableau(hintRows, hintCols, fNotifier))
{
}
inline QcDelLinEqSystem::QcDelLinEqSystem(QcLinEqTableau &tab)
: QcLinEqSystem(tab)
{
}
inline bool QcDelLinEqSystem::RemoveVar(QcFloat &v)
{
int ix = fVBiMap.safeIndex(v);
if (ix >= 0)
return fTableau.RemoveVarix( ix);
else
return false;
}
inline bool QcDelLinEqSystem::RemoveConstraint(QcConstraint &c)
{
int ix = fOCBiMap.safeIndex(c);
if (ix < 0)
return false;
fTableau.RemoveEq(ix);
fEditVarsSetup = false;
return true;
}
#endif

View File

@ -1,174 +0,0 @@
// $Id: QcDelLinEqTableau.cc,v 1.9 2001/01/31 07:37:13 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include <cmath>
#include "qoca/QcDefines.hh"
#include "qoca/QcDelLinEqTableau.hh"
#ifdef qcDenseQuasiInverse
# include <qoca/QcDenseMatrixColIterator.hh>
#else
# include <qoca/QcSparseMatrixColIterator.hh>
#endif
numT QcDelLinEqTableau::GetValueVirtual(int ci, int vi) const
{
// Short cut evaluations
switch (GetRowCondition(ci)) {
case QcLinEqRowState::fRedundant:
return 0.0;
case QcLinEqRowState::fNormalised:
if (IsBasic(vi))
return 0.0;
break;
case QcLinEqRowState::fRegular:
if (IsBasic(vi)) {
if (vi == GetBasicVar(ci))
return numT( 1u);
else
return 0.0;
}
break;
case QcLinEqRowState::fInvalid:
break;
}
return CAST(QcDelCoreTableau *, fCoreTableau)->GetValueVirtual(ci,vi);
}
int QcDelLinEqTableau::RemoveEq(unsigned ci)
{
numT max = 0.0; // Maximal absolute value of coeff
int maxIndex = QcTableau::fInvalidConstraintIndex;
bool foundRedund = false;
int pivotRow;
#ifndef NDEBUG
if ((int) ci < 0 || (int) ci >= GetRows() || fCoreTableau->GetARowDeleted(ci)) {
throw QcWarning(qcPlace,
"RemoveEq: invalid original constraint index", ci, GetRows() - 1);
return QcTableau::fInvalidConstraintIndex;
} else if (fCoreTableau->GetMRowIndex(ci) != QcTableau::fInvalidConstraintIndex) {
qcAssert(IsUndetermined(fCoreTableau->GetMRowIndex(ci)));
throw QcWarning(qcPlace, "RemoveEq for undetermined constraint");
return QcTableau::fInvalidConstraintIndex;
} else if (!IsSolved())
throw QcWarning(qcPlace,
"RemoveEq called when tableau not in solved form");
#endif
// First look for a suitable redundant constraint, meanwhile
// keep track of the maximal size quasiColCoeff.
#ifdef qcDenseQuasiInverse
QcDenseMatrixColIterator quasiColCoeffs(
CAST(QcDelCoreTableau *, fCoreTableau)->fM, ci);
#else
QcSparseMatrixColIterator quasiColCoeffs(
CAST(QcDelCoreTableau *, fCoreTableau)->fM, ci);
#endif
while (!quasiColCoeffs.AtEnd()) { // N.B. This loop contains a break
qcAssert(!QcUtility::IsZero(quasiColCoeffs.getValue()));
if (IsRedundant(quasiColCoeffs.getIndex())) {
foundRedund = true;
break;
} else {
#ifdef qcSafetyChecks
qcAssert(GetBasicVar(quasiColCoeffs.GetIndex())
!= QcTableau::fInvalidVariableIndex);
if (GetRowCondition(quasiColCoeffs.GetIndex())
== QcLinEqRowState::fNormalised)
throw QcWarning(qcPlace,
"RemoveEq called with normalised constraint");
else
qcAssert(GetRowCondition(quasiColCoeffs.GetIndex())
== QcLinEqRowState::fRegular);
#endif
numT absValue = fabs (quasiColCoeffs.getValue());
if (absValue > max)
{
max = absValue;
maxIndex = quasiColCoeffs.getIndex();
}
// Note that the ratio used in IPL 55 (1995) page 112 is
// directly related to the inverse of max since the RHS
// value is constant and we take the absolute value of max.
}
quasiColCoeffs.Increment();
}
#ifdef qcSafetyChecks
if (foundRedund)
qcAssert(IsRedundant(quasiColCoeffs.GetIndex()));
else
qcAssert(max != 0.0 && maxIndex != QcTableau::fInvalidConstraintIndex);
#endif
// Best to abort rather than use an invalid index
if (!foundRedund && maxIndex == QcTableau::fInvalidConstraintIndex)
return QcTableau::fInvalidConstraintIndex;
// delete selected row from fM, column ci from fM, row ci from fA
if (foundRedund) {
pivotRow = quasiColCoeffs.GetIndex();
SetRowCondition(pivotRow, QcLinEqRowState::fNormalised);
} else
pivotRow = maxIndex;
CAST(QcDelCoreTableau *, fCoreTableau)->PivotQuasiInverse(pivotRow, ci);
if (!foundRedund)
Unsolve(pivotRow); // removes pivotRow from the basis
// The situation now simulates that of a newly added row after
// Eliminate has been called, but before a Pivot.
SetMRowIndex(ci, pivotRow);
SetARowIndex(pivotRow, ci);
DeleteRow(ci);
fNotifier.DropConstraint(ci);
return pivotRow;
}
bool QcDelLinEqTableau::RemoveVarix(unsigned vi)
{
if (!IsFree(vi))
return false;
qcAssert(!IsBasic(vi));
qcAssert(IsBasicIn(vi) == QcTableau::fInvalidConstraintIndex);
unsigned lastColumn = getNColumns() - 1;
if (vi != lastColumn) { // Swap column vi with last column
fCoreTableau->CopyColumn( vi, lastColumn);
fRowColState->SwapColumns( vi, lastColumn);
fNotifier.SwapVariables( vi, lastColumn);
}
qcAssert(!IsBasic( lastColumn));
qcAssert(IsBasicIn( lastColumn) == QcTableau::fInvalidConstraintIndex);
DecreaseColumns(fNotifier);
return true;
}

View File

@ -1,128 +0,0 @@
// $Id: QcDelLinEqTableau.hh,v 1.9 2001/01/30 01:32:07 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcDelLinEqTableauH
#define __QcDelLinEqTableauH
#include "qoca/QcLinEqTableau.hh"
class QcDelLinEqTableau : public QcLinEqTableau
{
public:
//-----------------------------------------------------------------------//
// Constructors. //
//-----------------------------------------------------------------------//
QcDelLinEqTableau(unsigned hintRows, unsigned hintCols, QcBiMapNotifier &n);
QcDelLinEqTableau(QcCoreTableau &tab, QcBiMapNotifier &n);
//-----------------------------------------------------------------------//
// Query functions. //
//-----------------------------------------------------------------------//
virtual bool IsFree(unsigned vi) const
// Indicates if a particular variable is in use (i.e. has a
// non-zero coefficient in any solved form (or original) constraint.
{ return CAST(QcDelCoreTableau *, fCoreTableau)->IsFree(vi); }
numT GetRHSVirtual(int ci) const
{ return CAST(QcDelCoreTableau *, fCoreTableau)->GetRHSVirtual(ci); }
numT GetValueVirtual(int ci, int vi) const;
// This is the similar to getValue except that it will always obtain
// value from computation of the quasi-inverse and orignial constraint
// coefficients. Whereas getValue obtain value directly from the
// solved form if the real tableau is used.
bool IsValidSolvedForm() const
// For debugging purposes to ensure that the real solved form is
// consistant with the virtual solved form.
{ return CAST(QcDelCoreTableau *, fCoreTableau)->IsValidSolvedForm(); }
//-----------------------------------------------------------------------//
// Manipulation functions. //
//-----------------------------------------------------------------------//
virtual void DecreaseRows(QcBiMapNotifier &note)
// Get rid of the last (deleted) row
{ CAST(QcDelCoreTableau *, fCoreTableau)->DecreaseRows(note); }
virtual void DecreaseColumns(QcBiMapNotifier &note)
// Get rid of the last (empty) column
{ CAST(QcDelCoreTableau *, fCoreTableau)->DecreaseColumns(note); }
virtual int RemoveEq(unsigned ci);
// RemoveEq removes an original constraint with index ci from
// the solved form without disturbing the solution. This requires
// removal of one of the solved form constraints. The index of
// the removed solved form constraint is returned or InvalidCIndex
// if there is a serious error (e.g. ci invalid). For the current
// implementation: after a row is removed the CIndex values for
// particular rows are unchanged.
// The notifier is told to drop the constraint index.
virtual bool RemoveVarix(unsigned vi);
// Removes a free variable from the tableau, returns false if not free.
//-----------------------------------------------------------------------//
// Utility function. //
//-----------------------------------------------------------------------//
virtual void Print(ostream &os) const;
virtual void TransitiveClosure(vector<unsigned int> &vars)
{ CAST(QcDelCoreTableau *, fCoreTableau)->TransitiveClosure(vars); }
protected:
//-----------------------------------------------------------------------//
// Constructors. //
//-----------------------------------------------------------------------//
QcDelLinEqTableau(QcBiMapNotifier &n);
};
inline QcDelLinEqTableau::QcDelLinEqTableau(unsigned hintRows, unsigned hintCols,
QcBiMapNotifier &n)
: QcLinEqTableau(*new QcDelCoreTableau(hintRows, hintCols,
*new QcLinEqRowColStateVector()),
n)
{
}
inline QcDelLinEqTableau::QcDelLinEqTableau(QcCoreTableau &tab, QcBiMapNotifier &n)
: QcLinEqTableau(tab, n)
{
}
inline QcDelLinEqTableau::QcDelLinEqTableau(QcBiMapNotifier &n)
: QcLinEqTableau(n)
{
}
inline void QcDelLinEqTableau::Print(ostream &os) const
{
QcLinEqTableau::Print(os);
fCoreTableau->Print(os);
os << endl << "Consistant: "
<< (IsValidSolvedForm() ? "yes" : "no") << endl;
}
#endif /* !__QcDelLinEqTableauH */

View File

@ -1,80 +0,0 @@
// $Id: QcDelLinInEqSystem.hh,v 1.4 2000/11/23 06:44:20 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcDelLinInEqSystemH
#define __QcDelLinInEqSystemH
#include "qoca/QcLinInEqSystem.hh"
#include "qoca/QcDelLinInEqTableau.hh"
class QcDelLinInEqSystem : public QcLinInEqSystem
{
public:
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcDelLinInEqSystem();
QcDelLinInEqSystem(unsigned hintRows, unsigned hintCols);
//-----------------------------------------------------------------------//
// Variable management methods (see solver.h for descriptions) //
//-----------------------------------------------------------------------//
virtual bool RemoveVar(QcFloat &v)
{ return QcDelLinEqSystem::RemoveVar(v); }
//-----------------------------------------------------------------------//
// Constraint management methods //
//-----------------------------------------------------------------------//
virtual bool RemoveConstraint(QcConstraint &c);
};
inline QcDelLinInEqSystem::QcDelLinInEqSystem()
: QcLinInEqSystem(*new QcDelLinInEqTableau(0, 0, fNotifier))
{
}
inline QcDelLinInEqSystem::QcDelLinInEqSystem(unsigned hintRows, unsigned hintCols)
: QcLinInEqSystem(*new QcDelLinInEqTableau(hintRows, hintCols, fNotifier))
{
}
inline bool QcDelLinInEqSystem::RemoveConstraint(QcConstraint &c)
{
bool present = fOCBiMap.IdentifierPresent(c);
if (present)
fTableau.RemoveEq(fOCBiMap.Index(c));
#ifdef qcSafetyChecks
else
throw QcWarning(
"QcDelLinEqSystem::RemoveConstraint: invalid QcConstraint");
#endif
fEditVarsSetup = false;
return present;
}
#endif

View File

@ -1,177 +0,0 @@
// $Id: QcDelLinInEqTableau.cc,v 1.9 2001/01/30 01:32:07 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include "qoca/QcDefines.hh"
#include "qoca/QcDelLinInEqTableau.hh"
#include "qoca/QcSparseMatrixRowIterator.hh"
#include "qoca/QcDenseMatrixColIterator.hh"
int QcDelLinInEqTableau::AddGtEq(QcRowAdaptor &varCoeffs, numT rhs)
{
int r = AddEq(varCoeffs, rhs);
// Add new slack variable with coeff -1.0
unsigned vi = NewVariable();
SetColCondition(vi, QcLinInEqColState::fSlack |
QcLinInEqColState::fStructural);
SetConstrained(vi, true);
CAST(QcDelCoreTableau *, fCoreTableau)->fA.SetValue(r, vi, -1.0);
fCoreTableau->fSF.SetValue(GetMRowIndex(r), vi, -1.0);
return r;
}
int QcDelLinInEqTableau::AddLtEq(QcRowAdaptor &varCoeffs, numT rhs)
{
int r = AddEq(varCoeffs, rhs);
// Add new slack variable with coeff 1.0
unsigned vi = NewVariable();
SetColCondition(vi, QcLinInEqColState::fSlack |
QcLinInEqColState::fStructural);
SetConstrained(vi, true);
CAST(QcDelCoreTableau *, fCoreTableau)->fA.SetValue(r, vi, 1.0);
fCoreTableau->fSF.SetValue(GetMRowIndex(r), vi, 1.0);
return r;
}
int QcDelLinInEqTableau::RemoveEq(unsigned ci)
{
numT min = INT_MAX; // Maximal absolute value of coeff
int minIndex = QcTableau::fInvalidConstraintIndex;
bool foundRedund = false;
int pivotRow;
if ((int) ci < 0 || (int) ci >= GetRows() || fCoreTableau->GetARowDeleted(ci)) {
throw QcWarning(qcPlace,
"RemoveEq: invalid original constraint index", ci, GetRows() - 1);
return QcTableau::fInvalidConstraintIndex;
} else if (fCoreTableau->GetMRowIndex(ci) != QcTableau::fInvalidConstraintIndex) {
qcAssert(IsUndetermined(fCoreTableau->GetMRowIndex(ci)));
throw QcWarning(qcPlace, "RemoveEq for undetermined constraint");
return QcTableau::fInvalidConstraintIndex;
}
#ifdef qcSafetyChecks
else if (!IsSolved())
throw QcWarning(qcPlace,
"RemoveEq called when tableau not in solved form");
#endif
// First look for a suitable redundant constraint, meanwhile
// keep track of the maximal size quasiColCoeff.
#ifdef qcDenseQuasiInverse
QcDenseMatrixColIterator quasiColCoeffs(
CAST(QcDelCoreTableau *, fCoreTableau)->fM, ci);
#else
QcSparseMatrixColIterator quasiColCoeffs(
CAST(QcDelCoreTableau *, fCoreTableau)->fM, ci);
#endif
while (!quasiColCoeffs.AtEnd()) { // N.B. This loop contains a break
qcAssert(!QcUtility::IsZero(quasiColCoeffs.GetValue()));
if (IsRedundant(quasiColCoeffs.GetIndex())) {
foundRedund = true;
break;
} else {
qcAssert(GetBasicVar(quasiColCoeffs.GetIndex()) !=
QcTableau::fInvalidVariableIndex);
#ifdef qcSafetyChecks
if (GetRowCondition(quasiColCoeffs.GetIndex()) ==
QcLinEqRowState::fNormalised)
throw QcWarning(qcPlace,
"RemoveEq called with normalised constraint");
else
qcAssert(GetRowCondition(quasiColCoeffs.GetIndex()) ==
QcLinEqRowState::fRegular);
#endif
numT ratio = fabs(GetRHS(quasiColCoeffs.getIndex()) /
quasiColCoeffs.getValue());
if (ratio < min) {
min = ratio;
minIndex = quasiColCoeffs.getIndex();
}
// Note that the ratio used in IPL 55 (1995) page 112 is
// directly related to the inverse of max since the RHS
// value is constant and we take the absolute value of max.
}
quasiColCoeffs.Increment();
}
#ifdef qcSafetyChecks
if (foundRedund)
qcAssert(IsRedundant(quasiColCoeffs.getIndex()));
else
qcAssert(minIndex != QcTableau::fInvalidConstraintIndex);
#endif
// Best to abort rather than use an invalid index
if (!foundRedund && minIndex == QcTableau::fInvalidConstraintIndex)
return QcTableau::fInvalidConstraintIndex;
// delete selected row from fM, column ci from fM, row ci from fA
if (foundRedund) {
pivotRow = quasiColCoeffs.GetIndex();
SetRowCondition(pivotRow, QcLinEqRowState::fNormalised);
} else
pivotRow = minIndex;
CAST(QcDelCoreTableau *, fCoreTableau)->PivotQuasiInverse(pivotRow, ci);
if (!foundRedund)
Unsolve(pivotRow); // removes pivotRow from the basis
// The situation now simulates that of a newly added row after
// Eliminate has been called, but before a Pivot.
SetMRowIndex(ci, pivotRow);
SetARowIndex(pivotRow, ci);
// Removing the original constraint from the constraint matrix. First must
// remove any associated slack variables.
deque<unsigned int> slackList;
QcSparseMatrixRowIterator var(CAST(QcDelCoreTableau *, fCoreTableau)->fA, ci);
while (!var.AtEnd()) {
// It is very important to put index to the front because larger index
// should be deleted first so to avoid invaliding the index of the rest
// of the slack variables.
if (IsSlack(var.GetIndex()))
slackList.push_front(var.GetIndex());
var.Increment();
}
DeleteRow(ci);
fNotifier.DropConstraint(ci);
// Remove the slack variables if there are any.
for (deque<unsigned int>::iterator slack = slackList.begin();
slack != slackList.end(); ++slack)
RemoveVarix(*slack);
return pivotRow;
}

View File

@ -1,78 +0,0 @@
// $Id: QcDelLinInEqTableau.hh,v 1.8 2001/01/30 01:32:07 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcDelLinInEqTableauH
#define __QcDelLinInEqTableauH
#include "qoca/QcLinInEqTableau.hh"
#include "qoca/QcLinInEqRowColStateVector.hh"
class QcDelLinInEqTableau : public QcLinInEqTableau
{
public:
//-----------------------------------------------------------------------//
// Constructors. //
//-----------------------------------------------------------------------//
QcDelLinInEqTableau(unsigned hintRows, unsigned hintCols, QcBiMapNotifier &n);
QcDelLinInEqTableau(QcCoreTableau &tab, QcBiMapNotifier &n);
//-----------------------------------------------------------------------//
// Manipulation functions. //
//-----------------------------------------------------------------------//
virtual int AddGtEq(QcRowAdaptor &varCoeffs, numT rhs);
// Similar to addLtEq, only uses a negative slack variable coeff.
virtual int AddLtEq(QcRowAdaptor &varCoeffs, numT rhs);
// AddLessEq does the same as AddEq but also introduces a new
// slack variable so the varCoeffs will represent a less than or
// equal to constraint. The slack variable is added after
// any other new regular variables.
virtual int RemoveEq(unsigned ci);
// Eliminate the original constraint ci from the solved form and
// delete it. Returns the associated solved form constraint removed.
// If the operation cannot be performed for some reason InvalidCIndex
// is returned.
virtual bool RemoveVarix(unsigned vi)
// Removes a free variable from the tableau, returns false if not free.
{ return QcDelLinEqTableau::RemoveVarix( vi); }
};
inline QcDelLinInEqTableau::QcDelLinInEqTableau(unsigned hintRows, unsigned hintCols,
QcBiMapNotifier &n)
: QcLinInEqTableau(*new QcDelCoreTableau(hintRows, hintCols,
*new QcLinInEqRowColStateVector()),
n)
{
}
inline QcDelLinInEqTableau::QcDelLinInEqTableau(QcCoreTableau &tab, QcBiMapNotifier &n)
: QcLinInEqTableau(tab, n)
{
}
#endif /* !__QcDelLinInEqTableauH */

View File

@ -1,252 +0,0 @@
// $Id: QcDenseMatrix.cc,v 1.12 2001/01/30 01:32:07 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include "qoca/QcDefines.hh"
#include "qoca/QcDenseMatrix.hh"
#include "qoca/QcDenseMatrixColIterator.hh"
QcDenseMatrix::~QcDenseMatrix()
{
if (fAllocColumns != 0)
for (unsigned i = 0; i < fAllocRows; i++)
delete[] fElements[i];
if (fAllocRows != 0)
delete[] fElements;
}
#if 0 /* unused */
void QcDenseMatrix::AddRow(unsigned destRow, unsigned srcRow)
{
qcAssertPre (srcRow < fRows);
qcAssertPre (destRow < fRows);
for (unsigned i = 0; i < fColumns; i++)
fElements[destRow][i] += fElements[srcRow][i];
}
#endif
bool QcDenseMatrix::AddScaledRow(unsigned destRow, unsigned srcRow, numT factor)
{
qcAssertPre( QcUtility::isFinite( factor));
qcAssertPre( srcRow < fRows);
qcAssertPre( destRow < fRows);
if (QcUtility::IsZero( factor))
return false;
for (unsigned i = 0; i < fColumns; i++)
fElements[destRow][i] += fElements[srcRow][i] * factor;
return true;
}
void QcDenseMatrix::FractionRow(unsigned row, numT factor)
{
qcAssertPre (row < fRows);
if (QcUtility::IsOne(factor))
return;
for (unsigned i = 0; i < fColumns; i++)
fElements[row][i] /= factor;
}
void QcDenseMatrix::Pivot(unsigned row, unsigned col)
{
qcAssertPre( row < getNRows());
qcAssertPre( col < getNColumns());
numT p = fElements[row][col];
qcAssertPre( !QcUtility::IsZero( p));
ScaleRow( row, recip( p));
for (QcDenseMatrixColIterator colItr( *this, col);
!colItr.AtEnd();
colItr.Increment())
{
if (colItr.getIndex() != row)
AddScaledRow( colItr.getIndex(), row, -colItr.getValue());
}
#ifdef qcCheckInternalPost
qcAssertPost( QcUtility::IsOne( GetValue( row, col)));
for (unsigned i = getNRows(); i--;)
if (i != row)
qcAssertPost( QcUtility::IsZero( GetValue( i, col)));
#endif
}
void QcDenseMatrix::Reserve(unsigned rows, unsigned cols)
{
numT **e;
numT *e1 = 0;
qcAssert(fAllocRows >= fRows);
qcAssert(fAllocColumns >= fColumns);
// Add new columns to existing rows
if (cols > fAllocColumns) {
// Extend rows which need copying of values
for (unsigned i = 0; i < fRows; i++) {
if (fAllocColumns > 0)
e1 = fElements[i];
fElements[i] = new numT[cols];
memcpy(fElements[i], e1, sizeof(numT) * fColumns);
if (fAllocColumns > 0)
delete [] e1;
}
// Extend rows which are presently allocated but unused
for (unsigned i = fRows; i < fAllocRows; i++) {
if (fAllocColumns > 0)
delete[] fElements[i];
fElements[i] = new numT[cols];
}
fAllocColumns = cols;
}
// Copy existing and Allocate new rows
if (rows > fAllocRows) {
e = new numT*[rows]; // Allocate a new row vector
// Copy old rows.
if (fAllocRows > 0) {
memcpy(e, fElements, sizeof(numT) * fAllocRows);
delete[] fElements; // free the old row vector
}
fElements = e; // matrix now uses the new row vector
// Allocate new rows
for (unsigned i = fAllocRows; i < rows; i++)
fElements[i] = new numT[fAllocColumns];
fAllocRows = rows;
}
qcAssertPost (fAllocRows >= rows);
qcAssertPost (fAllocColumns >= cols);
dbg(assertInvar());
}
void QcDenseMatrix::Resize(unsigned rows, unsigned cols)
{
if (rows > fAllocRows || cols > fAllocColumns)
Reserve(rows, cols);
// Initialise newly exposed columns of existing rows
for (unsigned i = 0; i < fRows; i++)
for (unsigned j = fColumns; j < cols; j++)
fElements[i][j] = 0.0;
// Initialise newly exposed rows
for (unsigned i = fRows; i < rows; i++)
for (unsigned j = 0; j < cols; j++)
fElements[i][j] = 0.0;
fRows = rows;
fColumns = cols;
dbg(assertInvar());
}
bool QcDenseMatrix::ScaleRow(unsigned row, numT factor)
{
if (QcUtility::IsOne( factor))
return false;
for (unsigned i = 0; i < fColumns; i++)
fElements[row][i] *= factor;
return true;
}
void QcDenseMatrix::SwapColumns(unsigned c1, unsigned c2)
{
numT temp;
for (unsigned i = 0; i < fRows; i++) {
temp = fElements[i][c1];
fElements[i][c1] = fElements[i][c2];
fElements[i][c2] = temp;
}
}
#ifdef KEEP_DENSE_SHADOW
void QcDenseMatrix::CopyColumn(unsigned destCol, unsigned srcCol)
{
qcAssertPre( destCol < getNColumns());
qcAssertPre( srcCol < getNColumns());
for (unsigned i = 0; i < fRows; i++)
fElements[i][destCol] = fElements[i][srcCol];
}
void QcDenseMatrix::CopyRow(unsigned destRow,
QcDenseMatrix const &srcMatrix, unsigned srcRow)
{
qcAssertPre( destRow < getNRows());
qcAssertPre( srcRow < getNRows());
for (unsigned j = 0; j < fColumns; j++)
fElements[destRow][j] = srcMatrix.fElements[srcRow][j];
}
#endif
#if 0 /* unused */
void QcDenseMatrix::SwapRows(unsigned r1, unsigned r2)
{
numT temp;
for (unsigned i = 0; i < fColumns; i++) {
temp = fElements[r1][i];
fElements[r1][i] = fElements[r2][i];
fElements[r2][i] = temp;
}
}
#endif /* unused */
void QcDenseMatrix::Zero()
{
for (unsigned i = 0; i < fRows; i++)
for (unsigned j = 0; j < fColumns; j++)
fElements[i][j] = 0.0;
}
void QcDenseMatrix::ZeroColumn(unsigned col)
{
for (unsigned i = 0; i < fRows; i++)
fElements[i][col] = 0.0;
}
void QcDenseMatrix::ZeroRow(unsigned row)
{
for (unsigned i = 0; i < fColumns; i++)
fElements[row][i] = 0.0;
}

View File

@ -1,115 +0,0 @@
// $Id: QcDenseMatrix.hh,v 1.10 2001/01/30 01:32:07 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcDenseMatrixH
#define __QcDenseMatrixH
#include "qoca/QcDefines.hh"
#ifdef qcBoundsChecks
# include <math.h> // NAN
#endif
#include "qoca/QcMatrix.hh"
class QcDenseMatrixIterator;
class QcDenseMatrix : public QcMatrix
{
public:
numT **fElements;
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcDenseMatrix();
virtual ~QcDenseMatrix();
//-----------------------------------------------------------------------//
// Enquiry functions. //
//-----------------------------------------------------------------------//
virtual numT GetValue(unsigned row, unsigned col) const;
//-----------------------------------------------------------------------//
// Matrix size management functions. //
//-----------------------------------------------------------------------//
virtual void Reserve(unsigned rows, unsigned cols);
// Ensure that future resizes up to these limits will take
// place in constant time - i.e. preallocate if necessary.
virtual void Resize(unsigned rows, unsigned cols);
// Change the size of the used part of the array up or down.
// Increases may take time up to O(rows * cols).
//-----------------------------------------------------------------------//
// Basic matrix data management functions. //
//-----------------------------------------------------------------------//
//virtual void IncreaseValue(unsigned row, unsigned col, numT inc)
// { fElements[row][col] += inc; }
virtual void SetValue(unsigned row, unsigned col, numT val);
virtual void SwapColumns(unsigned c1, unsigned c2);
#ifdef KEEP_DENSE_SHADOW
void CopyColumn(unsigned destCol, unsigned srcCol);
void CopyRow(unsigned destRow, QcDenseMatrix const &srcMatrix, unsigned srcRow);
#endif
//virtual void SwapRows(unsigned r1, unsigned r2);
virtual void Zero();
virtual void ZeroColumn(unsigned col);
virtual void ZeroRow(unsigned row);
//-----------------------------------------------------------------------//
// Numerical computation functions. //
//-----------------------------------------------------------------------//
//virtual void AddRow(unsigned destRow, unsigned srcRow);
virtual bool AddScaledRow(unsigned destRow, unsigned srcRow, numT factor);
virtual void FractionRow(unsigned row, numT factor);
virtual void Pivot(unsigned row, unsigned col);
virtual bool ScaleRow(unsigned row, numT factor);
};
inline QcDenseMatrix::QcDenseMatrix()
: QcMatrix(), fElements(0)
{
}
inline numT QcDenseMatrix::GetValue(unsigned row, unsigned col) const
{
qcAssertPre (row < fRows);
qcAssertPre (col < fColumns);
return fElements[row][col];
}
inline void QcDenseMatrix::SetValue(unsigned row, unsigned col, numT val)
{
qcAssertPre (row < fRows);
qcAssertPre (col < fColumns);
fElements[row][col] = val;
}
#endif /* !__QcDenseMatrixH */

View File

@ -1,71 +0,0 @@
// $Id: QcDenseMatrixColIterator.hh,v 1.5 2000/11/24 12:16:21 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcDenseMatrixColIteratorH
#define __QcDenseMatrixColIteratorH
#include "qoca/QcDenseMatrixIterator.hh"
#include "qoca/QcUtility.hh"
class QcDenseMatrixColIterator : public QcDenseMatrixIterator
{
public:
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcDenseMatrixColIterator(const QcDenseMatrix &m, unsigned col);
//-----------------------------------------------------------------------//
// Iteration functions. //
//-----------------------------------------------------------------------//
virtual void Advance();
virtual bool AtEnd() const
// Returns true iff the iterator is past the end of its row or column.
{ return fIndex == fMatrix.getNRows(); }
};
inline QcDenseMatrixColIterator::QcDenseMatrixColIterator(
const QcDenseMatrix &m, unsigned col)
: QcDenseMatrixIterator(m, col)
{
qcAssertPre (col < m.getNColumns());
Reset();
}
inline void QcDenseMatrixColIterator::Advance()
{
qcAssertPre (fIndex <= fMatrix.getNRows());
while (fIndex < fMatrix.getNRows()) {
fValue = fMatrix.fElements[fIndex][fVector];
if (!QcUtility::IsZero(fValue))
break;
fIndex++;
}
}
#endif /* !__QcDenseMatrixColIteratorH */

View File

@ -1,72 +0,0 @@
// $Id: QcDenseMatrixIterator.hh,v 1.5 2000/11/24 12:16:21 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcDenseMatrixIteratorH
#define __QcDenseMatrixIteratorH
#include "qoca/QcMatrixIterator.hh"
#include "qoca/QcDenseMatrix.hh"
class QcDenseMatrixIterator : public QcMatrixIterator
{
public:
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcDenseMatrixIterator(const QcDenseMatrix &m, unsigned vec);
//-----------------------------------------------------------------------//
// Iteration functions. //
//-----------------------------------------------------------------------//
virtual void Advance() = 0;
virtual void Increment();
virtual void Reset();
protected:
const QcDenseMatrix &fMatrix;
};
inline QcDenseMatrixIterator::QcDenseMatrixIterator(const QcDenseMatrix &m,
unsigned vec)
: QcMatrixIterator(vec), fMatrix(m)
{
}
inline void QcDenseMatrixIterator::Increment()
{
qcAssertPre (!AtEnd());
fIndex++;
Advance();
}
inline void QcDenseMatrixIterator::Reset()
{
fIndex = 0;
Advance();
}
#endif

View File

@ -1,69 +0,0 @@
// $Id: QcDenseMatrixRowIterator.hh,v 1.5 2001/01/30 01:32:07 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcDenseMatrixRowIteratorH
#define __QcDenseMatrixRowIteratorH
#include "qoca/QcDenseMatrixIterator.hh"
class QcDenseMatrixRowIterator : public QcDenseMatrixIterator
{
public:
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcDenseMatrixRowIterator(const QcDenseMatrix &m, unsigned row);
//-----------------------------------------------------------------------//
// Iteration functions. //
//-----------------------------------------------------------------------//
virtual void Advance();
virtual bool AtEnd() const
{ return fIndex == fMatrix.getNColumns(); }
};
inline QcDenseMatrixRowIterator::QcDenseMatrixRowIterator(
const QcDenseMatrix &m, unsigned row)
: QcDenseMatrixIterator(m, row)
{
qcAssertPre (row < m.getNRows());
Reset();
}
inline void QcDenseMatrixRowIterator::Advance()
{
qcAssertPre (fIndex <= fMatrix.getNColumns());
while (fIndex < fMatrix.getNColumns()) {
fValue = fMatrix.fElements[fVector][fIndex];
if (!QcUtility::IsZero( fValue))
break;
fIndex++;
}
}
#endif

View File

@ -1,71 +0,0 @@
// $Id: QcDenseTableauColIterator.hh,v 1.5 2000/11/24 12:24:47 pmoulder Exp $
//============================================================================//
// Written by Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcDenseTableauColIteratorH
#define __QcDenseTableauColIteratorH
#include "qoca/QcDenseTableauIterator.hh"
class QcDenseTableauColIterator : public QcDenseTableauIterator
{
public:
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
/** @precondition <tt>col &lt; tab.getNColumns()</tt> */
QcDenseTableauColIterator (const QcLinEqTableau &tab, unsigned col);
//-----------------------------------------------------------------------//
// Iteration functions. //
//-----------------------------------------------------------------------//
virtual void Advance();
};
inline QcDenseTableauColIterator::QcDenseTableauColIterator(
const QcLinEqTableau &tab, unsigned col)
: QcDenseTableauIterator(tab, col, tab.getNRows())
{
qcAssertPre (col < fTableau.getNColumns());
Reset();
dbg(assertInvar());
}
inline void QcDenseTableauColIterator::Advance()
{
assert (fIndex <= fEnd);
assert (fVector < fTableau.getNColumns());
assert (fEnd <= fTableau.getNRows());
while (fIndex < fEnd) {
fValue = fTableau.GetValue(fIndex, fVector);
if (!QcUtility::IsZero(fValue))
break;
fIndex++;
}
dbg(assertInvar());
}
#endif

View File

@ -1,118 +0,0 @@
// $Id: QcDenseTableauIterator.hh,v 1.6 2000/12/06 05:32:56 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcDenseTableauIteratorH
#define __QcDenseTableauIteratorH
#include "qoca/QcLinEqTableau.hh"
#include "qoca/QcIterator.hh"
class QcDenseTableauIterator : public QcIterator
{
public:
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcDenseTableauIterator(const QcLinEqTableau &tab,
unsigned vec, unsigned end);
#ifndef NDEBUG
void assertInvar() const
{
assert (fIndex <= fEnd);
}
#endif
//-----------------------------------------------------------------------//
// Enquiry functions. //
//-----------------------------------------------------------------------//
int GetIndex() const
{ return (int) fIndex; }
unsigned getIndex() const
{ return fIndex; }
numT GetValue() const
{
qcAssertPre (!AtEnd());
return fValue;
}
numT getValue() const
{
qcAssertPre (!AtEnd());
return fValue;
}
//------------------------------------------------------------------------//
// Iteration functions. //
//------------------------------------------------------------------------//
virtual void Advance() = 0;
virtual void Increment();
virtual void Reset();
virtual void SetToBeginOf(unsigned i);
virtual bool AtEnd() const
{ return fIndex == fEnd; }
protected:
unsigned fIndex;
numT fValue;
unsigned fVector;
unsigned fEnd;
const QcLinEqTableau &fTableau;
};
inline QcDenseTableauIterator::QcDenseTableauIterator(
const QcLinEqTableau &tab, unsigned vec, unsigned end)
: fIndex (0),
fValue(),
fVector (vec),
fEnd (end),
fTableau (tab)
{
dbg(assertInvar());
}
inline void QcDenseTableauIterator::Increment()
{
qcAssertPre (!AtEnd());
fIndex++;
Advance();
}
inline void QcDenseTableauIterator::Reset()
{
fIndex = 0;
Advance();
}
inline void QcDenseTableauIterator::SetToBeginOf(unsigned i)
{
fVector = i;
Reset();
}
#endif

View File

@ -1,72 +0,0 @@
// $Id: QcDenseTableauRowIterator.hh,v 1.5 2000/11/24 12:24:47 pmoulder Exp $
//============================================================================//
// Written by Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcDenseTableauRowIteratorH
#define __QcDenseTableauRowIteratorH
#include "qoca/QcDenseTableauIterator.hh"
class QcDenseTableauRowIterator : public QcDenseTableauIterator
{
public:
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
/** @precondition <tt>row &lt; tab.getNRows()</tt> */
QcDenseTableauRowIterator (const QcLinEqTableau &tab, unsigned row);
//-----------------------------------------------------------------------//
// Iteration functions. //
//-----------------------------------------------------------------------//
virtual void Advance();
};
inline QcDenseTableauRowIterator::QcDenseTableauRowIterator(
const QcLinEqTableau &tab, unsigned row)
: QcDenseTableauIterator(tab, row, tab.getNColumns())
{
qcAssertPre (row < fTableau.getNRows());
Reset();
dbg(assertInvar());
}
inline void QcDenseTableauRowIterator::Advance()
{
assert (fIndex <= fEnd);
assert (fVector < fTableau.getNRows());
assert (fEnd <= fTableau.getNColumns());
while (fIndex < fEnd) {
fValue = fTableau.GetValue(fVector, fIndex);
if (!QcUtility::IsZero(fValue))
break;
fIndex++;
}
dbg(assertInvar());
}
#endif

View File

@ -1,72 +0,0 @@
// $Id: QcDesireValueStore.hh,v 1.4 2000/12/11 07:48:23 pmoulder Exp $
//============================================================================//
// Written by Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcDesireValueStoreH
#define __QcDesireValueStoreH
#include <qoca/QcFloatRep.hh>
class QcDesireValueStore
{
public:
//-----------------------------------------------------------------------//
// Constructors
//-----------------------------------------------------------------------//
/* Used by vector as default initializer. */
QcDesireValueStore()
: fVariablePtr( 0),
fDesValue()
{ }
QcDesireValueStore( QcFloatRep *vr)
: fVariablePtr( vr),
fDesValue( vr->DesireValue())
{ }
//-----------------------------------------------------------------------//
// Manipulation function. //
//-----------------------------------------------------------------------//
void Restore()
{ fVariablePtr->SuggestValue( fDesValue); }
//-----------------------------------------------------------------------//
// Utility functions. //
//-----------------------------------------------------------------------//
void Print(ostream &os) const;
private:
QcFloatRep *fVariablePtr;
numT fDesValue;
};
inline void QcDesireValueStore::Print(ostream &os) const
{
fVariablePtr->Print( os);
os << ":" << fDesValue;
}
#endif /* !__QcDesireValueStoreH */

View File

@ -1,8 +0,0 @@
#ifndef QcEnables_H
#define QcEnables_H
//#define NDEBUG 1
//#define QC_USING_NLPSOLVER 1
#endif /* !QcEnables_H */

View File

@ -1,8 +0,0 @@
#ifndef QcEnables_H
#define QcEnables_H
@QC_NDEBUG_COM@#define NDEBUG 1
@NLPSOLVER_COM@#define QC_USING_NLPSOLVER 1
#endif /* !QcEnables_H */

View File

@ -1,224 +0,0 @@
// $Id: QcException.hh,v 1.3 2000/11/21 04:26:12 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcExceptionH
#define __QcExceptionH
#include <stdlib.h>
#include "qoca/QcDefines.hh"
#ifndef qcNoStream
#include <iostream>
#endif
//#ifdef DEBUG
//void QcBreak(int); // For trapping warnings when using debugger
//#else
#define QcBreak(x)
//#endif
#ifdef qcUseExceptions
class QcError
{
public:
QcError(const char *m)
: fMessage(m), fFile(0), fLine(-1), fIndex(-1), fRange(-1)
{ QcBreak(1); }
QcError(const char *f, int ln)
: fMessage("Assertion failed"), fFile(f), fLine(ln), fIndex(-1),
fRange(-1)
{ QcBreak(2); }
QcError(const char *f, int ln, const char *m)
: fMessage(m), fFile(f), fLine(ln), fIndex(-1), fRange(-1)
{ QcBreak(3); }
QcError(const char *m, int i, int r)
: fMessage(m), fFile(0), fLine(-1), fIndex(i), fRange(r)
{ QcBreak(4); }
QcError(const char *f, int ln, const char *m, int i, int r)
: fMessage(m), fFile(f), fLine(ln), fIndex(i), fRange(r)
{ QcBreak(5); }
private:
const char *fMessage;
const char *fFile;
const int fLine;
const int fIndex;
const int fRange;
};
#endif
#ifdef qcUseExceptions
class QcWarning : public QcError
{
public:
QcWarning(const char *m)
: QcError(m)
{ }
QcWarning(const char *file, int line, const char *m)
: QcError(file, line, m)
{ }
QcWarning(const char *m, int i, int r)
: QcError(m, i, r)
{ }
QcWarning(const char *file, int line, int i, int r)
: QcError(file, line, 0, i, r)
{ }
QcWarning(const char *file, int line, const char *m, int i, int r)
: QcError(file, line, m, i, r)
{ }
};
#else
#define throw
class QcWarning
{
public:
QcWarning(const char *m);
QcWarning(const char *file, int line, const char *m);
QcWarning(const char *m, int i, int r);
QcWarning(const char *file, int line, int i, int r);
QcWarning(const char *file, int line, const char *m, int i, int r);
};
inline QcWarning::QcWarning(const char *m)
{
cout << "Warning: " << m << endl;
QcBreak(1);
}
inline Warning::Warning(const char *file, int line, const char *m)
{
cout << "Warning: " << m;
cout << ", at line " << line << " of " << file << endl;
QcBreak(2);
}
inline Warning::Warning(const char *m, int i, int r)
{
cout << "Warning: " << m
<< ", index " << i << ", range (0," << r << ")" << endl;
QcBreak(3);
}
inline Warning::Warning(const char *file, int line, int i, int r)
{
cout << "Warning: out of bounds, index " << i << ", range (0,";
cout << r << ") at line " << line << " of " << file << endl;
QcBreak(4);
}
inline Warning::Warning(const char *file, int line, const char *m, int i, int r)
{
cout << "Warning: " << m << ", index " << i << ", range (0,";
cout << r << ") at line " << line << " of " << file << endl;
QcBreak(5);
}
#endif
#ifdef qcUseExceptions
class QcFatal : public QcError
{
public:
QcFatal(const char *m)
: QcError(m)
{ }
QcFatal(const char *file, int line, const char *m)
: QcError(file, line, m)
{ }
QcFatal(const char *m, int i, int r)
: QcError(m, i, r)
{ }
QcFatal(const char *file, int line, int i, int r)
: QcError(file, line, 0, i, r)
{ }
QcFatal(const char *file, int line, const char *m, int i, int r)
: QcError(file, line, m, i, r)
{ }
};
#else
#define throw
class QcFatal
{
public:
QcFatal(const char *m);
QcFatal(const char *file, int line, const char *m);
QcFatal(const char *m, int i, int r);
QcFatal(const char *file, int line, int i, int r);
QcFatal(const char *file, int line, const char *m, int i, int r);
};
inline QcFatal::QcFatal(const char *m)
{
cout << "QcFatal error: " << m << endl;
QcBreak(6);
exit(1);
}
inline QcFatal::QcFatal(const char *file, int line, const char *m)
{
cout << "QcFatal error: " << m;
cout << ", at line " << line << " of " << file << endl;
QcBreak(7);
exit(1);
}
inline QcFatal::QcFatal(const char *m, int i, int r)
{
cout << "QcFatal error: " << m
<< ", index " << i << ", range (0," << r << ")" << endl;
QcBreak(8);
exit(1);
}
inline QcFatal::QcFatal(const char *file, int line, int i, int r)
{
cout << "QcFatal error: out of bounds, index " << i << ", range (0,";
cout << r << ") at line " << line << " of " << file << endl;
QcBreak(9);
exit(1);
}
inline QcFatal::QcFatal(const char *file, int line, const char *m, int i, int r)
{
cout << "QcFatal error: " << m << ", index " << i << ", range (0,";
cout << r << ") at line " << line << " of " << file << endl;
QcBreak(10);
exit(1);
}
#endif
#endif

View File

@ -1,69 +0,0 @@
// $Id: QcFixedFloat.hh,v 1.5 2000/12/11 05:46:48 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcFixedFloatH
#define __QcFixedFloatH
#include "qoca/QcDefines.hh"
#include "qoca/QcFixedFloatRep.hh"
#include "qoca/QcFloat.hh"
class QcFixedFloat : public QcFloat
{
public:
//-----------------------------------------------------------------------//
// Constructor //
//-----------------------------------------------------------------------//
QcFixedFloat(bool restricted = false);
QcFixedFloat(const char *name, bool restricted = false);
QcFixedFloat(const char *name, numT desval, bool restricted = false);
QcFixedFloat(const char *name, numT desval, numT w,
bool restricted = false);
};
inline QcFixedFloat::QcFixedFloat(bool restricted)
: QcFloat(*new QcFixedFloatRep(restricted))
{
}
inline QcFixedFloat::QcFixedFloat(const char *name, bool restricted)
: QcFloat(*new QcFixedFloatRep(name, restricted))
{
}
inline QcFixedFloat::QcFixedFloat(const char *name, numT desval,
bool restricted)
: QcFloat(*new QcFixedFloatRep(name, desval, restricted))
{
}
inline QcFixedFloat::QcFixedFloat(const char *name, numT desval, numT w,
bool restricted)
: QcFloat(*new QcFixedFloatRep(name, desval, w, restricted))
{
}
#endif

View File

@ -1,77 +0,0 @@
// Generated automatically from QcFixedFloatRep.ch by /home/pmoulder/usr/local/bin/ch2xx.
#ifndef QcFixedFloatRepDCL
#define QcFixedFloatRepDCL
#line 1 "QcFixedFloatRep.ch"
// $Id: QcFixedFloatRep.ch,v 1.7 2000/12/12 09:59:27 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include <qoca/QcDefines.hh>
#include <qoca/QcFloatRep.H>
#define qcDefaultFixedWeight 5000.0
class QcFixedFloatRep
: public QcFloatRep
{
public:
//-----------------------------------------------------------------------//
// Constructor //
//-----------------------------------------------------------------------//
QcFixedFloatRep(bool restricted);
QcFixedFloatRep(const char *name, bool restricted);
QcFixedFloatRep(const char *name, numT desval, bool restricted);
QcFixedFloatRep(const char *name, numT desval, numT w, bool restricted);
//-----------------------------------------------------------------------//
// Manipulatiom functions. //
//-----------------------------------------------------------------------//
virtual void RestDesVal();
#line 57 "QcFixedFloatRep.ch"
virtual bool RestDesVal_changed();
#line 63 "QcFixedFloatRep.ch"
virtual void SetToEditWeight();
#line 68 "QcFixedFloatRep.ch"
virtual void SetToStayWeight();
#line 72 "QcFixedFloatRep.ch"
};
#line 113 "QcFixedFloatRep.ch"
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/
#endif /* !QcFixedFloatRepDCL */

View File

@ -1,78 +0,0 @@
// Generated automatically from QcFixedFloatRep.ch by /home/pmoulder/usr/local/bin/ch2xx.
#include "QcFixedFloatRep.hh"
#line 1 "QcFixedFloatRep.ch"
// $Id: QcFixedFloatRep.ch,v 1.7 2000/12/12 09:59:27 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include <qoca/QcDefines.hh>
#define qcDefaultFixedWeight 5000.0
#line 48 "QcFixedFloatRep.ch"
//-----------------------------------------------------------------------//
// Manipulatiom functions. //
//-----------------------------------------------------------------------//
void QcFixedFloatRep::RestDesVal()
{
}
bool QcFixedFloatRep::RestDesVal_changed()
{
return false;
}
void QcFixedFloatRep::SetToEditWeight()
{
}
void QcFixedFloatRep::SetToStayWeight()
{
}
#line 113 "QcFixedFloatRep.ch"
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/

View File

@ -1,120 +0,0 @@
// $Id: QcFixedFloatRep.ch,v 1.7 2000/12/12 09:59:27 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include <qoca/QcDefines.hh>
//o[d] #include <qoca/QcFloatRep.H>
//o[i] #include <qoca/QcFloatRep.hh>
#define qcDefaultFixedWeight 5000.0
//ho class QcFixedFloatRep
//ho : public QcFloatRep
//ho {
//ho public:
//begin o[d]
//-----------------------------------------------------------------------//
// Constructor //
//-----------------------------------------------------------------------//
QcFixedFloatRep(bool restricted);
QcFixedFloatRep(const char *name, bool restricted);
QcFixedFloatRep(const char *name, numT desval, bool restricted);
QcFixedFloatRep(const char *name, numT desval, numT w, bool restricted);
//end o[d]
//-----------------------------------------------------------------------//
// Manipulatiom functions. //
//-----------------------------------------------------------------------//
//cf
virtual void RestDesVal()
{
}
//cf
virtual bool RestDesVal_changed()
{
return false;
}
//cf
virtual void SetToEditWeight()
{
}
//cf
virtual void SetToStayWeight()
{
}
//ho };
//begin o[i]
inline QcFixedFloatRep::QcFixedFloatRep(bool restricted)
: QcFloatRep("", 0.0, qcDefaultFixedWeight, qcDefaultFixedWeight,
restricted)
{
#if qcReportAlloc
cerr << "inited fixed " << this << endl;
#endif
}
inline QcFixedFloatRep::QcFixedFloatRep(const char *name, bool restricted)
: QcFloatRep(name, 0.0, qcDefaultFixedWeight, qcDefaultFixedWeight,
restricted)
{
#if qcReportAlloc
cerr << "inited fixed " << this << endl;
#endif
}
inline QcFixedFloatRep::QcFixedFloatRep(const char *name, numT desval,
bool restricted)
: QcFloatRep(name, desval, qcDefaultFixedWeight,
qcDefaultFixedWeight, restricted)
{
#if qcReportAlloc
cerr << "inited fixed " << this << endl;
#endif
}
inline QcFixedFloatRep::QcFixedFloatRep(const char *name, numT desval,
numT w, bool restricted)
: QcFloatRep(name, desval, w, w, restricted)
{
#if qcReportAlloc
cerr << "inited fixed " << this << endl;
#endif
}
//end o[i]
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/

View File

@ -1,97 +0,0 @@
// Generated automatically from QcFixedFloatRep.ch by /home/pmoulder/usr/local/bin/ch2xx.
#include "QcFixedFloatRep.H"
#ifndef QcFixedFloatRepIFN
#define QcFixedFloatRepIFN
#line 1 "QcFixedFloatRep.ch"
// $Id: QcFixedFloatRep.ch,v 1.7 2000/12/12 09:59:27 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include <qoca/QcDefines.hh>
#include <qoca/QcFloatRep.hh>
#define qcDefaultFixedWeight 5000.0
#line 48 "QcFixedFloatRep.ch"
//-----------------------------------------------------------------------//
// Manipulatiom functions. //
//-----------------------------------------------------------------------//
#line 75 "QcFixedFloatRep.ch"
inline QcFixedFloatRep::QcFixedFloatRep::QcFixedFloatRep(bool restricted)
: QcFloatRep("", 0.0, qcDefaultFixedWeight, qcDefaultFixedWeight,
restricted)
{
#if qcReportAlloc
cerr << "inited fixed " << this << endl;
#endif
}
inline QcFixedFloatRep::QcFixedFloatRep::QcFixedFloatRep(const char *name, bool restricted)
: QcFloatRep(name, 0.0, qcDefaultFixedWeight, qcDefaultFixedWeight,
restricted)
{
#if qcReportAlloc
cerr << "inited fixed " << this << endl;
#endif
}
inline QcFixedFloatRep::QcFixedFloatRep::QcFixedFloatRep(const char *name, numT desval,
bool restricted)
: QcFloatRep(name, desval, qcDefaultFixedWeight,
qcDefaultFixedWeight, restricted)
{
#if qcReportAlloc
cerr << "inited fixed " << this << endl;
#endif
}
inline QcFixedFloatRep::QcFixedFloatRep::QcFixedFloatRep(const char *name, numT desval,
numT w, bool restricted)
: QcFloatRep(name, desval, w, w, restricted)
{
#if qcReportAlloc
cerr << "inited fixed " << this << endl;
#endif
}
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/
#endif /* !QcFixedFloatRepIFN */

View File

@ -1,373 +0,0 @@
// $Id: QcFloat.hh,v 1.15 2000/12/14 02:28:54 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//----------------------------------------------------------------------------//
// This class provides the only mechanism to create cfloats and the //
// constructors return a handle. The semantics of cfloat handles are sharing //
// on assignment with automatic destruction when the last handle is lost. //
// The handles are implemented to use a representation that fits in a single //
// word. Handles are therefore quite efficient to pass by value. Pass //
// handles by reference where efficiency is critical. It is intended that //
// clients be able to derive classes from QcFloat and be able to //
// override most public methods. //
//============================================================================//
#ifndef __QcFloatH
#define __QcFloatH
#if HAVE_LROUND || HAVE_LRINT || HAVE_ROUND
# define _ISOC9X_SOURCE 1
#endif
#if HAVE_LROUND || HAVE_LRINT || HAVE_ROUND || HAVE_RINT
# include <math.h>
#endif
#include "qoca/QcDefines.hh"
#include "qoca/QcFloatRep.hh"
#include "qoca/QcNullableElement.hh"
#include "qoca/QcNomadicFloatRep.hh"
#define subclassOfNullable 0
class QcFloat
#if subclassOfNullable
: QcNullableElement<QcFloatRep,QcFloat>
#endif
{
public:
friend class QcNullableElement<QcFloatRep,QcFloat>;
//-----------------------------------------------------------------------//
// Constructors //
//-----------------------------------------------------------------------//
explicit QcFloat(QcFloatRep *ptr);
explicit QcFloat(QcFloatRep &rep);
explicit QcFloat(bool restricted = false);
explicit QcFloat(const char *name, bool restricted = false);
QcFloat(const char *name, numT desval, bool restricted = false);
QcFloat(const char *name, numT desval, numT sw, numT ew,
bool restricted = false);
QcFloat(const QcFloat &other);
//QcFloat(QcNullableElement<QcFloatRep,QcFloat> const &other);
~QcFloat()
{ Decrease(); }
void assertInvar() const
{
qcAssertInvar(fRep != 0);
fRep->assertInvar();
}
//-----------------------------------------------------------------------//
// Data structure access functions //
//-----------------------------------------------------------------------//
QcFloatRep *pointer() const
{ return fRep; }
#if 0
const QcFloatRep &Rep() const
{ return *fRep; }
const QcFloatRep &getRep() const
{ return *fRep; }
#endif
#if NUMT_IS_DOUBLE
# ifdef HAVE_LROUND
# define Round(_x) lround (_x)
# elif HAVE_LRINT
# define Round(_x) lrint (_x)
# elif HAVE_ROUND
# define Round(_x) ((long) round (_x))
# elif HAVE_RINT
# define Round(_x) ((long) rint (_x))
# else
private:
static inline long Round (double x)
{
return long (x > 0.0
? x + 0.5
: x - 0.5);
}
public:
# endif
#elif NUMT_IS_PJM_MPQ
# define Round(_x) ((_x).get_lround())
#else
# error "Unknown numT"
#endif
//-----------------------------------------------------------------------//
// Query functions //
//-----------------------------------------------------------------------//
long Counter() const
{ return (long)fRep->Counter(); }
numT DesireValue() const
{ return fRep->DesireValue(); }
numT EditWeight() const
{ return fRep->EditWeight(); }
QcFloatRep::TId Id() const
{ return fRep->Id(); }
QcFloatRep::TId getId() const
{ return fRep->Id(); }
long IntDesireValue() const
{ return Round(fRep->DesireValue()); }
long IntValue() const
{ return Round(fRep->Value()); }
bool IsRestricted() const
{ return fRep->IsRestricted(); }
const char *Name() const
{ return fRep->Name(); }
numT StayWeight() const
{ return fRep->StayWeight(); }
numT Weight() const
{ return fRep->Weight(); }
numT Value() const
{ return GetValue(); }
numT GetValue() const
{ return fRep->Value(); }
bool operator <(const QcFloat &other) const
{ return *fRep < *other.fRep; }
/* FIXME: Is it a problem that these compare pointers whereas `<' compares ids?
E.g. is it possible that (a != b) && !(a < b) && !(b < a)? */
bool operator ==(const QcFloat &other) const
{ return (fRep == other.fRep); }
bool operator !=(const QcFloat &other) const
{ return (fRep != other.fRep); }
#if 0
operator int() const
{ return (int) Round( fRep->Value()); }
#endif
bool isDead() const
{ return fRep == 0; }
//-----------------------------------------------------------------------//
// Manipulation functions //
//-----------------------------------------------------------------------//
private:
/** Deallocates old name string. */
bool FreeName()
{ return fRep->FreeName(); }
/** Called when number of references decreases. */
void Decrease();
/** Call when number of references increases. */
void Increase()
{
#if qcReportAlloc
cerr << "f: " << &fRep << " increasing " << fRep << endl;
#endif
fRep->Increase();
}
public:
void SetWeight(numT w)
{ fRep->SetWeight(w); }
void SetValue(numT v)
{ fRep->SetValue(v); }
void SuggestValue(numT dv)
{ fRep->SuggestValue(dv); }
void SetName(const char *n)
{ fRep->SetName(n); }
void SetToEditWeight()
{ fRep->SetToEditWeight(); }
void SetToStayWeight()
{ fRep->SetToStayWeight(); }
void SetVariable()
{ fRep->SetToGoal(); }
/** Old name for <tt>RestDesVal</tt>. */
void RestVariable()
{ fRep->RestDesVal(); }
void RestDesVal()
{ fRep->RestDesVal(); }
bool RestDesVal_changed()
{ return fRep->RestDesVal_changed(); }
QcFloat &operator=(const QcFloat &other);
// N.B. checked self assignment, x = x ok
//-----------------------------------------------------------------------//
// Utility functions //
//-----------------------------------------------------------------------//
void Print(ostream &os) const
{ fRep->Print(os); }
protected:
QcFloatRep *fRep;
};
inline QcFloat::QcFloat(QcFloatRep *ptr)
: fRep (ptr)
{
#if qcReportAlloc
cerr << "f: " << &fRep << " constructing from rep " << fRep << endl;
#endif
Increase();
}
inline QcFloat::QcFloat(QcFloatRep &rep)
: fRep(&rep)
{
#if qcReportAlloc
cerr << "f: " << &fRep << " constructing from rep " << fRep << endl;
#endif
Increase();
}
inline QcFloat::QcFloat(bool restricted)
: fRep(new QcNomadicFloatRep(restricted))
{
#if qcReportAlloc
cerr << "f: " << &fRep << " created QcFloatRep " << fRep << endl;
#endif
}
inline QcFloat::QcFloat(const char *name, bool restricted)
: fRep(new QcNomadicFloatRep(name, restricted))
{
#if qcReportAlloc
cerr << "f: " << &fRep << " created QcFloatRep " << fRep << endl;
#endif
}
inline QcFloat::QcFloat(const char *name, numT desval, bool restricted)
: fRep(new QcNomadicFloatRep(name, desval, restricted))
{
#if qcReportAlloc
cerr << "f: " << &fRep << " created QcFloatRep " << fRep << endl;
#endif
}
inline QcFloat::QcFloat(const char *name, numT desval, numT sw, numT ew,
bool restricted)
: fRep(new QcNomadicFloatRep(name, desval, sw, ew, restricted))
{
#if qcReportAlloc
cerr << "f: " << &fRep << " created QcFloatRep " << fRep << endl;
#endif
}
inline QcFloat::QcFloat(const QcFloat &other)
: fRep(other.fRep)
{
#if qcReportAlloc
cerr << "f: " << &fRep << " constructed from QcFloatRep " << fRep << endl;
#endif
Increase();
}
#if 0
inline QcFloat::QcFloat(QcNullableElement<QcFloatRep,QcFloat> const &other)
: fRep(other.fRep)
{
# if qcReportAlloc
cerr << "f: " << &fRep << " constructed from QcFloatRep " << fRep << endl;
# endif
Increase();
}
#endif
#ifndef qcSafetyChecks
inline void QcFloat::Decrease()
{
# if qcReportAlloc
cerr << "f: " << &fRep << " decreasing " << fRep << endl;
# endif
# if 0
if (fRep == 0)
return;
# endif
fRep->Decrease();
if (fRep->Counter() == 0)
delete fRep;
fRep = 0;
}
#else /* qcSafetyChecks */
inline void QcFloat::Decrease()
{
# if qcReportAlloc
cout << "Decreasing " << fRep << endl;
# endif
# if 0
if (fRep == 0)
return;
# endif
fRep->Decrease();
if (fRep->Counter() == 0) {
fRep->assertInvar();
if (fRep->Magic() == qcFloatMagic1 && fRep->FreeName()) {
delete fRep;
} else
throw QcWarning("QcFloat::Decrease detected cfloat corruption");
}
fRep = 0;
}
#endif /* qcSafetyChecks */
inline QcFloat &QcFloat::operator=(const QcFloat &other)
{
other.fRep->Increase();
Decrease();
fRep = other.fRep;
return *this;
}
#ifndef qcNoStream
inline ostream &operator<<(ostream &os, const QcFloat &cf)
{
cf.Print(os);
return os;
}
#endif
#endif /* !__QcFloatH */

View File

@ -1,285 +0,0 @@
// Generated automatically from QcFloatRep.ch by /home/pmoulder/usr/local/bin/ch2xx.
#ifndef QcFloatRepDCL
#define QcFloatRepDCL
#line 1 "QcFloatRep.ch"
// $Id: QcFloatRep.ch,v 1.13 2001/01/10 05:01:51 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include <string>
#include "qoca/QcUtility.hh"
#define qcFloatMagic1 18732
#define qcFloatMagic2 "Qoca var:"
#define qcMagic2Len 9
// The length of magic2 without the terminal '\0'
class QcFloatRep
{
public:
/** It is intended that <tt>TId</tt> be signed. Negative values are not
allocated and are reserved for future (unknown) usage. The value 0
is reserved as an invalid identifier. */
typedef long TId;
public:
//-----------------------------------------------------------------------//
// Constructors //
//-----------------------------------------------------------------------//
QcFloatRep (const char *name, numT desval, numT sw, numT ew,
bool restricted);
#line 74 "QcFloatRep.ch"
#ifndef NDEBUG
bool isQcFloatRep() const
{ return fMagic == qcFloatMagic1; }
#endif
virtual ~QcFloatRep()
{
#if qcReportAlloc
cout << "destroying " << this << endl;
#endif
qcAssertPre( isQcFloatRep());
qcAssertPre ((fName == 0)
|| memcmp (fName, qcFloatMagic2,
qcMagic2Len) == 0);
delete [] fName;
fMagic = 0;
}
//-----------------------------------------------------------------------//
// Set and Get member functions //
//-----------------------------------------------------------------------//
long Counter() const
{
qcAssertPre( isQcFloatRep());
return fCounter;
}
numT EditWeight() const
{
qcAssertPre( isQcFloatRep());
return fEditWeight;
}
long Magic() const
{ return fMagic; }
numT StayWeight() const
{
qcAssertPre( isQcFloatRep());
return fStayWeight;
}
numT Value() const
{
qcAssertPre( isQcFloatRep());
return fValue;
}
numT Weight() const
{
qcAssertPre( isQcFloatRep());
return fWeight;
}
numT DesireValue() const
{
qcAssertPre( isQcFloatRep());
return fDesireValue;
}
bool IsRestricted() const
{
qcAssertPre( isQcFloatRep());
return fRestricted;
}
TId Id() const
{
qcAssertPre( isQcFloatRep());
return fId;
}
/** Called when number of references decreases. */
void Decrease()
{
qcAssertPre( isQcFloatRep());
fCounter--;
qcAssertPre (fCounter >= 0);
}
/** Call when number of references increases. */
void Increase()
{
qcAssertPre( isQcFloatRep());
fCounter++;
}
inline char const *Name() const;
#line 176 "QcFloatRep.ch"
virtual void SetWeight (numT w);
#line 183 "QcFloatRep.ch"
virtual void SetValue (numT v);
#line 194 "QcFloatRep.ch"
/** Set the goal value of this variable to <tt>dv</tt>.
<p>Note that many solvers ignore SuggestValue on variables that are not edit
variables.
**/
void
SuggestValue (numT dv);
#line 206 "QcFloatRep.ch"
/** Sets field <tt>fName</tt> to point to a heap-allocated string with a hidden
magic number field at the front. (The magic number is qcFloatMagic2 without
the '\0' terminator.)
<p>(The Java version doesn't bother with a magic number, presumably because
of lack of pointers. The Java version consists of `fName = n'.)
**/
void SetName (char const *n);
#line 248 "QcFloatRep.ch"
inline void SetToGoal();
#line 255 "QcFloatRep.ch"
virtual void SetToEditWeight() = 0;
virtual void SetToStayWeight() = 0;
/** Do RestDesVal, then return true iff the goal value changed. */
virtual bool RestDesVal_changed() = 0;
/** For nomadic variables, set the goal value to equal the actual
(solved) value; does nothing for "fixed" (non-nomadic) variables.
**/
virtual void RestDesVal() = 0;
/** Called just before delete, to detect pointer corruption. */
virtual void assertInvar() const;
#line 296 "QcFloatRep.ch"
/** Deallocates old name string checking magic2.
Returns success indicator.
**/
bool FreeName();
#line 321 "QcFloatRep.ch"
/** Set variables to defaults (including getting a new fId). */
inline void Reset();
#line 330 "QcFloatRep.ch"
bool operator<(const QcFloatRep &other) const
// The comparisons are for when QcFloatRep is used
// as an identifier and compares instances not structure.
// General pointer inequality comparisons are not reliable
// (see the C++ ARM section 5.9), fId is provided for this.
{
qcAssertPre( isQcFloatRep());
qcAssertPre( other.isQcFloatRep());
return fId < other.fId;
}
#if 0
bool operator==(const QcFloatRep &other) const
{ return fId == other.fId; }
bool operator!=(const QcFloatRep &other) const
{ return fId != other.fId; }
#endif
//-----------------------------------------------------------------------//
// Utility functions. //
//-----------------------------------------------------------------------//
virtual void Print (ostream &os) const;
#line 372 "QcFloatRep.ch"
protected:
static TId fNextValidId;
static const TId fInvalidId = 0;
// fInvalidId is currently set to 0. All negative values are reserved
// for future use.
private:
TId fId; // Used as index key and for operator<.
long fMagic; // To detect corruption.
long fCounter; // Reference count.
numT fStayWeight;
numT fEditWeight;
protected:
numT fValue;
numT fWeight;
numT fDesireValue;
private:
char *fName; // 0 or a heap allocated string with hidden prefix.
bool fRestricted;
};
struct QcFloatRep_hash
{
size_t operator()(QcFloatRep const *v) const
{
return (size_t) v->Id();
}
};
struct QcFloatRep_equal
{
size_t operator()(QcFloatRep const *v1,
QcFloatRep const *v2) const
{
return v1->Id() == v2->Id();
}
};
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/
#endif /* !QcFloatRepDCL */

View File

@ -1,204 +0,0 @@
// Generated automatically from QcFloatRep.ch by /home/pmoulder/usr/local/bin/ch2xx.
#include "QcFloatRep.hh"
#line 1 "QcFloatRep.ch"
// $Id: QcFloatRep.ch,v 1.13 2001/01/10 05:01:51 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include <string>
#include "qoca/QcUtility.hh"
#line 48 "QcFloatRep.ch"
//-----------------------------------------------------------------------//
// Constructors //
//-----------------------------------------------------------------------//
QcFloatRep::QcFloatRep (const char *name, numT desval, numT sw, numT ew,
bool restricted)
: fStayWeight( sw),
fEditWeight( ew),
fValue( 0), /* perhaps should be desval; but perhaps not too important so
long as it is understood that Solve needs to be called. */
fWeight( sw),
fDesireValue( desval)
{
qcAssertExternalPre( sw >= 0);
qcAssertExternalPre( ew >= 0);
#if qcReportAlloc
cerr << "initing " << this << endl;
#endif
fMagic = qcFloatMagic1;
Reset();
fRestricted = restricted;
fName = 0;
SetName( name);
}
#line 93 "QcFloatRep.ch"
//-----------------------------------------------------------------------//
// Set and Get member functions //
//-----------------------------------------------------------------------//
#line 176 "QcFloatRep.ch"
void QcFloatRep::SetWeight (numT w)
{
qcAssertPre( isQcFloatRep());
fWeight = w;
}
void QcFloatRep::SetValue (numT v)
{
qcAssertPre( isQcFloatRep());
#ifdef qcSafetyChecks
if (fRestricted && QcUtility::IsNegative(v))
throw QcWarning("Restricted float made negative");
#endif
fValue = v;
}
#line 199 "QcFloatRep.ch"
void
QcFloatRep::SuggestValue (numT dv)
{
qcAssertPre( isQcFloatRep());
fDesireValue = dv;
}
#line 213 "QcFloatRep.ch"
void QcFloatRep::SetName (char const *n)
{
qcAssertPre( isQcFloatRep());
/* Note: Although <strings.h> is pretty standard, for portability we try
to avoid using it here as we have no other need for it. */
int len = 0;
char const *magic2 = qcFloatMagic2;
// find length of source string
while (n[len] != '\0')
len++;
qcAssertPost (n[len] == '\0');
#ifdef qcSafetyChecks
if (len > 1000)
throw QcWarning("QcFloatRep::SetName name over 1000 chars long");
#endif
/* Deallocate existing name string. If FreeName fails, leave old string
and allocate a new one. */
if (!FreeName())
throw QcWarning("QcFloatRep::SetName: failed to free old name string");
fName = new char[len + qcMagic2Len + 1]; // allocate for magic+string
for (int i = 0; i < qcMagic2Len; i++)
fName[i] = magic2[i];
for (int i=0; i <= len; i++)
fName[i + qcMagic2Len] = n[i];
qcAssertPost (fName[len + qcMagic2Len] == '\0');
}
#line 279 "QcFloatRep.ch"
#if qcCheckInternalPre
void QcFloatRep::assertInvar() const
{
qcAssertInvar (fId > 0);
qcAssertInvar (Magic() == qcFloatMagic1);
qcAssertInvar (fCounter >= 0);
qcAssertInvar (fStayWeight >= 0);
qcAssertInvar (fEditWeight >= 0);
qcAssertInvar (fWeight >= 0);
qcAssertInvar ((fName == 0)
|| (memcmp (fName, qcFloatMagic2, qcMagic2Len)
== 0));
}
#endif
#line 299 "QcFloatRep.ch"
bool QcFloatRep::FreeName()
{
qcAssertPre( isQcFloatRep());
bool ok = true;
if (fName != 0)
{ // check for magic2
char const *magic2 = qcFloatMagic2;
for (int i = 0; i < qcMagic2Len; i++)
ok &= (fName[i] == magic2[i]);
if (ok)
{
delete[] fName;
fName = 0;
}
}
return ok;
}
#line 352 "QcFloatRep.ch"
//-----------------------------------------------------------------------//
// Utility functions. //
//-----------------------------------------------------------------------//
void QcFloatRep::Print (ostream &os) const
{
qcAssertPre( isQcFloatRep());
if (fName != 0)
os << Name();
os << "#" << fId
<< "(" << fValue << ", "
<< fDesireValue << ", "
<< fWeight
<< ")";
}
#line 414 "QcFloatRep.ch"
QcFloatRep::TId QcFloatRep::fNextValidId = 1;
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/

View File

@ -1,423 +0,0 @@
// $Id: QcFloatRep.ch,v 1.13 2001/01/10 05:01:51 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include <string>
#include "qoca/QcUtility.hh"
//begin o[d]
#define qcFloatMagic1 18732
#define qcFloatMagic2 "Qoca var:"
#define qcMagic2Len 9
// The length of magic2 without the terminal '\0'
//end o[d]
//ho class QcFloatRep
//ho {
//ho public:
/** It is intended that <tt>TId</tt> be signed. Negative values are not
allocated and are reserved for future (unknown) usage. The value 0
is reserved as an invalid identifier. */
typedef long TId;
//ho public:
//-----------------------------------------------------------------------//
// Constructors //
//-----------------------------------------------------------------------//
//cf
QcFloatRep (const char *name, numT desval, numT sw, numT ew,
bool restricted)
: fStayWeight( sw),
fEditWeight( ew),
fValue( 0), /* perhaps should be desval; but perhaps not too important so
long as it is understood that Solve needs to be called. */
fWeight( sw),
fDesireValue( desval)
{
qcAssertExternalPre( sw >= 0);
qcAssertExternalPre( ew >= 0);
#if qcReportAlloc
cerr << "initing " << this << endl;
#endif
fMagic = qcFloatMagic1;
Reset();
fRestricted = restricted;
fName = 0;
SetName( name);
}
//begin ho
#ifndef NDEBUG
bool isQcFloatRep() const
{ return fMagic == qcFloatMagic1; }
#endif
virtual ~QcFloatRep()
{
#if qcReportAlloc
cout << "destroying " << this << endl;
#endif
qcAssertPre( isQcFloatRep());
qcAssertPre ((fName == 0)
|| memcmp (fName, qcFloatMagic2,
qcMagic2Len) == 0);
delete [] fName;
fMagic = 0;
}
//end ho
//-----------------------------------------------------------------------//
// Set and Get member functions //
//-----------------------------------------------------------------------//
//begin o[d]
long Counter() const
{
qcAssertPre( isQcFloatRep());
return fCounter;
}
numT EditWeight() const
{
qcAssertPre( isQcFloatRep());
return fEditWeight;
}
long Magic() const
{ return fMagic; }
numT StayWeight() const
{
qcAssertPre( isQcFloatRep());
return fStayWeight;
}
numT Value() const
{
qcAssertPre( isQcFloatRep());
return fValue;
}
numT Weight() const
{
qcAssertPre( isQcFloatRep());
return fWeight;
}
numT DesireValue() const
{
qcAssertPre( isQcFloatRep());
return fDesireValue;
}
bool IsRestricted() const
{
qcAssertPre( isQcFloatRep());
return fRestricted;
}
TId Id() const
{
qcAssertPre( isQcFloatRep());
return fId;
}
/** Called when number of references decreases. */
void Decrease()
{
qcAssertPre( isQcFloatRep());
fCounter--;
qcAssertPre (fCounter >= 0);
}
/** Call when number of references increases. */
void Increase()
{
qcAssertPre( isQcFloatRep());
fCounter++;
}
//end o[d]
//hf
inline char const *Name() const
{
qcAssertPre( isQcFloatRep());
if (fName == 0)
return 0;
else
return (fName + qcMagic2Len);
}
//cf
virtual void SetWeight (numT w)
{
qcAssertPre( isQcFloatRep());
fWeight = w;
}
//cf
virtual void SetValue (numT v)
{
qcAssertPre( isQcFloatRep());
#ifdef qcSafetyChecks
if (fRestricted && QcUtility::IsNegative(v))
throw QcWarning("Restricted float made negative");
#endif
fValue = v;
}
/** Set the goal value of this variable to <tt>dv</tt>.
<p>Note that many solvers ignore SuggestValue on variables that are not edit
variables.
**/ //cf
void
SuggestValue (numT dv)
{
qcAssertPre( isQcFloatRep());
fDesireValue = dv;
}
/** Sets field <tt>fName</tt> to point to a heap-allocated string with a hidden
magic number field at the front. (The magic number is qcFloatMagic2 without
the '\0' terminator.)
<p>(The Java version doesn't bother with a magic number, presumably because
of lack of pointers. The Java version consists of `fName = n'.)
**/ //cf
void SetName (char const *n)
{
qcAssertPre( isQcFloatRep());
/* Note: Although <strings.h> is pretty standard, for portability we try
to avoid using it here as we have no other need for it. */
int len = 0;
char const *magic2 = qcFloatMagic2;
// find length of source string
while (n[len] != '\0')
len++;
qcAssertPost (n[len] == '\0');
#ifdef qcSafetyChecks
if (len > 1000)
throw QcWarning("QcFloatRep::SetName name over 1000 chars long");
#endif
/* Deallocate existing name string. If FreeName fails, leave old string
and allocate a new one. */
if (!FreeName())
throw QcWarning("QcFloatRep::SetName: failed to free old name string");
fName = new char[len + qcMagic2Len + 1]; // allocate for magic+string
for (int i = 0; i < qcMagic2Len; i++)
fName[i] = magic2[i];
for (int i=0; i <= len; i++)
fName[i + qcMagic2Len] = n[i];
qcAssertPost (fName[len + qcMagic2Len] == '\0');
}
//hf
inline void SetToGoal()
{
qcAssertPre( isQcFloatRep());
SetValue (fDesireValue);
}
//begin o[d]
virtual void SetToEditWeight() = 0;
virtual void SetToStayWeight() = 0;
/** Do RestDesVal, then return true iff the goal value changed. */
virtual bool RestDesVal_changed() = 0;
/** For nomadic variables, set the goal value to equal the actual
(solved) value; does nothing for "fixed" (non-nomadic) variables.
**/
virtual void RestDesVal() = 0;
//end o[d]
/** Called just before delete, to detect pointer corruption. */
//o[d] virtual void assertInvar() const;
//begin o[i]
#ifndef qcCheckInternalPre
inline void QcFloatRep::assertInvar() const
{ }
#endif
//end o[i]
//begin o[c]
#if qcCheckInternalPre
void QcFloatRep::assertInvar() const
{
qcAssertInvar (fId > 0);
qcAssertInvar (Magic() == qcFloatMagic1);
qcAssertInvar (fCounter >= 0);
qcAssertInvar (fStayWeight >= 0);
qcAssertInvar (fEditWeight >= 0);
qcAssertInvar (fWeight >= 0);
qcAssertInvar ((fName == 0)
|| (memcmp (fName, qcFloatMagic2, qcMagic2Len)
== 0));
}
#endif
//end o[c]
/** Deallocates old name string checking magic2.
Returns success indicator.
**/ //cf
bool FreeName()
{
qcAssertPre( isQcFloatRep());
bool ok = true;
if (fName != 0)
{ // check for magic2
char const *magic2 = qcFloatMagic2;
for (int i = 0; i < qcMagic2Len; i++)
ok &= (fName[i] == magic2[i]);
if (ok)
{
delete[] fName;
fName = 0;
}
}
return ok;
}
/** Set variables to defaults (including getting a new fId). */
inline void Reset()
{
fCounter = 1;
fId = fNextValidId++;
qcAssertPost (fNextValidId > 0);
}
//begin o[d]
bool operator<(const QcFloatRep &other) const
// The comparisons are for when QcFloatRep is used
// as an identifier and compares instances not structure.
// General pointer inequality comparisons are not reliable
// (see the C++ ARM section 5.9), fId is provided for this.
{
qcAssertPre( isQcFloatRep());
qcAssertPre( other.isQcFloatRep());
return fId < other.fId;
}
#if 0
bool operator==(const QcFloatRep &other) const
{ return fId == other.fId; }
bool operator!=(const QcFloatRep &other) const
{ return fId != other.fId; }
#endif
//end o[d]
//-----------------------------------------------------------------------//
// Utility functions. //
//-----------------------------------------------------------------------//
//cf
virtual void Print (ostream &os) const
{
qcAssertPre( isQcFloatRep());
if (fName != 0)
os << Name();
os << "#" << fId
<< "(" << fValue << ", "
<< fDesireValue << ", "
<< fWeight
<< ")";
}
//begin ho
protected:
static TId fNextValidId;
static const TId fInvalidId = 0;
// fInvalidId is currently set to 0. All negative values are reserved
// for future use.
private:
TId fId; // Used as index key and for operator<.
long fMagic; // To detect corruption.
long fCounter; // Reference count.
numT fStayWeight;
numT fEditWeight;
protected:
numT fValue;
numT fWeight;
numT fDesireValue;
private:
char *fName; // 0 or a heap allocated string with hidden prefix.
bool fRestricted;
//end ho
//ho };
//begin ho
struct QcFloatRep_hash
{
size_t operator()(QcFloatRep const *v) const
{
return (size_t) v->Id();
}
};
struct QcFloatRep_equal
{
size_t operator()(QcFloatRep const *v1,
QcFloatRep const *v2) const
{
return v1->Id() == v2->Id();
}
};
//end ho
//o[c] QcFloatRep::TId QcFloatRep::fNextValidId = 1;
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/

View File

@ -1,97 +0,0 @@
// Generated automatically from QcFloatRep.ch by /home/pmoulder/usr/local/bin/ch2xx.
#include "QcFloatRep.H"
#ifndef QcFloatRepIFN
#define QcFloatRepIFN
#line 1 "QcFloatRep.ch"
// $Id: QcFloatRep.ch,v 1.13 2001/01/10 05:01:51 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include <string>
#include "qoca/QcUtility.hh"
#line 48 "QcFloatRep.ch"
//-----------------------------------------------------------------------//
// Constructors //
//-----------------------------------------------------------------------//
#line 93 "QcFloatRep.ch"
//-----------------------------------------------------------------------//
// Set and Get member functions //
//-----------------------------------------------------------------------//
#line 166 "QcFloatRep.ch"
inline char const *QcFloatRep::Name() const
{
qcAssertPre( isQcFloatRep());
if (fName == 0)
return 0;
else
return (fName + qcMagic2Len);
}
#line 248 "QcFloatRep.ch"
inline void QcFloatRep::SetToGoal()
{
qcAssertPre( isQcFloatRep());
SetValue (fDesireValue);
}
#line 273 "QcFloatRep.ch"
#ifndef qcCheckInternalPre
inline void QcFloatRep::QcFloatRep::assertInvar() const
{ }
#endif
#line 322 "QcFloatRep.ch"
inline void QcFloatRep::Reset()
{
fCounter = 1;
fId = fNextValidId++;
qcAssertPost (fNextValidId > 0);
}
#line 352 "QcFloatRep.ch"
//-----------------------------------------------------------------------//
// Utility functions. //
//-----------------------------------------------------------------------//
#line 416 "QcFloatRep.ch"
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/
#endif /* !QcFloatRepIFN */

View File

@ -1,136 +0,0 @@
// Generated automatically from QcIneqSolverBase.ch by /home/pmoulder/usr/local/bin/ch2xx.
#ifndef QcIneqSolverBaseDCL
#define QcIneqSolverBaseDCL
#include <qoca/QcSolver.H>
#include <qoca/QcDelLinInEqSystem.hh>
class QcIneqSolverBase
: public QcSolver
{
public:
inline
#line 18 "QcIneqSolverBase.ch"
QcIneqSolverBase()
: QcSolver(),
fSystem()
{
;
}
inline
#line 26 "QcIneqSolverBase.ch"
QcIneqSolverBase(unsigned hintNumConstraints, unsigned hintNumVariables)
: QcSolver(),
fSystem( hintNumConstraints, hintNumVariables)
{
;
}
virtual ~QcIneqSolverBase()
{
}
//-----------------------------------------------------------------------//
// Variable management methods //
//-----------------------------------------------------------------------//
virtual void
AddVar(QcFloat &v)
{
fSystem.AddVar( v);
}
virtual void
SuggestValue(QcFloat &v, numT desval)
{
fSystem.SuggestValue( v, desval);
}
virtual bool
RemoveVar(QcFloat &v)
{
return fSystem.RemoveVar( v);
}
virtual void
RestSolver()
{
fSystem.RestSolver();
}
//-----------------------------------------------------------------------//
// Enquiry functions for variables //
//-----------------------------------------------------------------------//
virtual bool
IsRegistered(QcFloat const &v) const
{
return fSystem.IsRegistered( v);
}
virtual bool
IsFree(QcFloat const &v) const
{
return fSystem.IsFree( v);
}
virtual bool
IsBasic(QcFloat const &v) const
{
return fSystem.IsBasic( v);
}
//-----------------------------------------------------------------------//
// Constraint management methods //
//-----------------------------------------------------------------------//
virtual bool
AddConstraint(QcConstraint &c);
virtual bool
AddConstraint(QcConstraint &c, QcFloat &hint);
virtual void
BeginAddConstraint()
{
fSystem.BeginAddConstraint();
}
virtual bool
EndAddConstraint()
{
return fSystem.EndAddConstraint();
}
virtual bool
ChangeConstraint(QcConstraint &oldc, numT rhs);
virtual bool
RemoveConstraint(QcConstraint &c);
virtual bool
Reset()
{
return fSystem.Reset();
}
protected:
QcDelLinInEqSystem fSystem;
};
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/
#endif /* !QcIneqSolverBaseDCL */

View File

@ -1,88 +0,0 @@
// Generated automatically from QcIneqSolverBase.ch by /home/pmoulder/usr/local/bin/ch2xx.
#include "QcIneqSolverBase.hh"
#line 1 "QcIneqSolverBase.ch"
#include <qoca/QcSolver.hh>
#line 80 "QcIneqSolverBase.ch"
//-----------------------------------------------------------------------//
// Constraint management methods //
//-----------------------------------------------------------------------//
bool
QcIneqSolverBase::AddConstraint(QcConstraint &c)
{
bool success = fSystem.AddConstraint( c);
if (success)
{
#if qcCheckPost
addCheckedConstraint( c.pointer());
#endif
if (fAutoSolve)
Solve();
}
return success;
}
bool
QcIneqSolverBase::AddConstraint(QcConstraint &c, QcFloat &hint)
{
bool success = fSystem.AddConstraint( c, hint);
if (success)
{
#if qcCheckPost
addCheckedConstraint( c.pointer());
#endif
if (fAutoSolve)
Solve();
}
return success;
}
#line 131 "QcIneqSolverBase.ch"
bool
QcIneqSolverBase::ChangeConstraint(QcConstraint &oldc, numT rhs)
{
bool success = fSystem.ChangeConstraint( oldc, rhs);
#if qcCheckPost
if (success)
changeCheckedConstraint( oldc.pointer(), rhs);
#endif
return success;
}
bool
QcIneqSolverBase::RemoveConstraint(QcConstraint &c)
{
bool success = fSystem.RemoveConstraint( c);
if (success)
{
#if qcCheckPost
removeCheckedConstraint( c.pointer());
#endif
if (fAutoSolve)
Solve();
}
return success;
}
#line 173 "QcIneqSolverBase.ch"
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/

View File

@ -1,180 +0,0 @@
//o[d] #include <qoca/QcSolver.H>
//o[ci] #include <qoca/QcSolver.hh>
//o[d] #include <qoca/QcDelLinInEqSystem.hh>
//ho class QcIneqSolverBase
//ho : public QcSolver
//ho {
//ho public:
inline
QcIneqSolverBase()
: QcSolver(),
fSystem()
{
}
inline
QcIneqSolverBase(unsigned hintNumConstraints, unsigned hintNumVariables)
: QcSolver(),
fSystem( hintNumConstraints, hintNumVariables)
{
}
//begin ho
virtual ~QcIneqSolverBase()
{
}
//-----------------------------------------------------------------------//
// Variable management methods //
//-----------------------------------------------------------------------//
virtual void
AddVar(QcFloat &v)
{
fSystem.AddVar( v);
}
virtual void
SuggestValue(QcFloat &v, numT desval)
{
fSystem.SuggestValue( v, desval);
}
virtual bool
RemoveVar(QcFloat &v)
{
return fSystem.RemoveVar( v);
}
virtual void
RestSolver()
{
fSystem.RestSolver();
}
//-----------------------------------------------------------------------//
// Enquiry functions for variables //
//-----------------------------------------------------------------------//
virtual bool
IsRegistered(QcFloat const &v) const
{
return fSystem.IsRegistered( v);
}
virtual bool
IsFree(QcFloat const &v) const
{
return fSystem.IsFree( v);
}
virtual bool
IsBasic(QcFloat const &v) const
{
return fSystem.IsBasic( v);
}
//end ho
//-----------------------------------------------------------------------//
// Constraint management methods //
//-----------------------------------------------------------------------//
//cf
virtual bool
AddConstraint(QcConstraint &c)
{
bool success = fSystem.AddConstraint( c);
if (success)
{
#if qcCheckPost
addCheckedConstraint( c.pointer());
#endif
if (fAutoSolve)
Solve();
}
return success;
}
//cf
virtual bool
AddConstraint(QcConstraint &c, QcFloat &hint)
{
bool success = fSystem.AddConstraint( c, hint);
if (success)
{
#if qcCheckPost
addCheckedConstraint( c.pointer());
#endif
if (fAutoSolve)
Solve();
}
return success;
}
//begin ho
virtual void
BeginAddConstraint()
{
fSystem.BeginAddConstraint();
}
virtual bool
EndAddConstraint()
{
return fSystem.EndAddConstraint();
}
//end ho
//cf
virtual bool
ChangeConstraint(QcConstraint &oldc, numT rhs)
{
bool success = fSystem.ChangeConstraint( oldc, rhs);
#if qcCheckPost
if (success)
changeCheckedConstraint( oldc.pointer(), rhs);
#endif
return success;
}
//cf
virtual bool
RemoveConstraint(QcConstraint &c)
{
bool success = fSystem.RemoveConstraint( c);
if (success)
{
#if qcCheckPost
removeCheckedConstraint( c.pointer());
#endif
if (fAutoSolve)
Solve();
}
return success;
}
//begin ho
virtual bool
Reset()
{
return fSystem.Reset();
}
//end ho
//begin ho
protected:
QcDelLinInEqSystem fSystem;
//end ho
//ho };
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/

View File

@ -1,46 +0,0 @@
// Generated automatically from QcIneqSolverBase.ch by /home/pmoulder/usr/local/bin/ch2xx.
#include "QcIneqSolverBase.H"
#ifndef QcIneqSolverBaseIFN
#define QcIneqSolverBaseIFN
#include <qoca/QcSolver.hh>
/*inline
QcIneqSolverBase::QcIneqSolverBase()
: QcSolver(),
fSystem()
{
;
}
inline
QcIneqSolverBase::QcIneqSolverBase(unsigned hintNumConstraints, unsigned hintNumVariables)
: QcSolver(),
fSystem( hintNumConstraints, hintNumVariables)
{
;
}*/
//-----------------------------------------------------------------------//
// Constraint management methods //
//-----------------------------------------------------------------------//
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/
#endif /* !QcIneqSolverBaseIFN */

View File

@ -1,46 +0,0 @@
// $Id: QcIterator.hh,v 1.5 2000/12/06 05:32:56 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcIteratorH
#define __QcIteratorH
class QcIterator
{
public:
virtual ~QcIterator() { }
//-----------------------------------------------------------------------//
// Iteration functions. //
//-----------------------------------------------------------------------//
//virtual void Advance() = 0;
virtual bool AtEnd() const = 0;
// Returns true iff the iterator is past the end of its row or column.
virtual void Increment() = 0;
virtual void Reset() = 0;
//virtual void SetToBeginOf(int i) = 0;
};
#endif /* !__QcIteratorH */

View File

@ -1,132 +0,0 @@
// $Id: QcLinEqColState.hh,v 1.5 2000/12/06 05:32:56 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//----------------------------------------------------------------------------//
// The class QcBiMap provides a bi-directional mapping from //
// identifier class to index class. //
//============================================================================//
#ifndef __QcLinEqColStateH
#define __QcLinEqColStateH
#include <qoca/QcTableau.hh>
#include "qoca/QcQuasiColState.hh"
class QcLinEqColState : public QcQuasiColState
{
friend class QcLinEqColStateVector;
friend class QcLinEqRowColStateVector;
public:
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcLinEqColState(int vi);
QcLinEqColState(bool isbasic);
//-----------------------------------------------------------------------//
// Query functions
//-----------------------------------------------------------------------//
QcLinEqColState const *getNextBasicnessCol() const
{
return fNextCol;
}
/** Returns true iff the variable is a basic (i.e.&nbsp;dependent)
variable. */
bool isBasic() const
{ return fIsBasic; }
/** The constraint that this variable is basic in, or InvalidCIndex if
none. */
int getConstraintBasicIn() const
{ return fIsBasicIn; }
/** Returns cached value of variable's desired value, for during solve. */
numT getGoalVal() const
{
return fDesValue;
}
//-----------------------------------------------------------------------
// Setter functions
//-----------------------------------------------------------------------
/** The constraint that this variable is basic in, or InvalidCIndex if
none. */
void setConstraintBasicIn(int c)
{ fIsBasicIn = c; }
//-----------------------------------------------------------------------//
// Utility functions. //
//-----------------------------------------------------------------------//
virtual void Print(ostream &os);
private:
numT fDesValue; // cache desired value of variable during solve
bool fIsBasic; // means variable is basic, otherwise it is parametric.
int fIsBasicIn;
/** fNextCol and fPrevCol are used by QcLinEqColStateVector for some
doubly-linked lists. See that class for details. */
QcLinEqColState *fNextCol;
QcLinEqColState *fPrevCol;
protected:
/** Arbitrary constant used as fIndex for the heads of linked lists. Used
only in assertion checking. */
static unsigned const fHeadIndex = 0x4eadad4e;
};
inline QcLinEqColState::QcLinEqColState(int vi)
: QcQuasiColState(vi),
fDesValue( 0),
fIsBasic( false),
fIsBasicIn(QcTableau::fInvalidConstraintIndex),
fNextCol( 0),
fPrevCol( 0)
{
}
inline QcLinEqColState::QcLinEqColState(bool isbasic)
: QcQuasiColState( fHeadIndex),
fDesValue(),
fIsBasic( isbasic),
fNextCol( this),
fPrevCol( this)
{
}
inline void QcLinEqColState::Print(ostream &os)
{
QcQuasiColState::Print(os);
os << ",DV(" << fDesValue << "),"
<< "IsBasic(" << fIsBasic << "),"
<< "BasicIn(" << fIsBasicIn << "),"
<< "PrevCol(" << fPrevCol << "),"
<< "NextCol(" << fNextCol << ")";
}
#endif

View File

@ -1,149 +0,0 @@
// Generated automatically from QcLinEqColStateVector.ch by /home/pmoulder/usr/local/bin/ch2xx.
#ifndef QcLinEqColStateVectorDCL
#define QcLinEqColStateVectorDCL
#line 1 "QcLinEqColStateVector.ch"
// $Id: QcLinEqColStateVector.ch,v 1.2 2000/12/06 05:32:56 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include "qoca/QcQuasiColStateVector.hh"
#include "qoca/QcLinEqColState.hh"
class QcLinEqColStateVector
: public QcQuasiColStateVector
{
public:
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcLinEqColStateVector()
: QcQuasiColStateVector(),
fParamHead( false),
fBasicHead( true)
{
}
#ifndef NDEBUG
private:
void
assertLinkageInvar() const;
#line 113 "QcLinEqColStateVector.ch"
protected:
virtual void
virtualAssertLinkageInvar() const;
#line 121 "QcLinEqColStateVector.ch"
#endif /* !NDEBUG */
//-----------------------------------------------------------------------//
// Query functions. //
//-----------------------------------------------------------------------//
public:
inline numT
GetDesireValue(unsigned i) const;
#line 136 "QcLinEqColStateVector.ch"
inline bool
IsBasic(unsigned i) const;
#line 143 "QcLinEqColStateVector.ch"
inline int
IsBasicIn(unsigned i) const;
#line 151 "QcLinEqColStateVector.ch"
//-----------------------------------------------------------------------//
// Set functions. //
//-----------------------------------------------------------------------//
inline void
SetDesireValue(unsigned i, numT dv) const;
#line 161 "QcLinEqColStateVector.ch"
inline QcLinEqColState *
head( bool isbasic);
#line 172 "QcLinEqColStateVector.ch"
void
SetBasic(unsigned i, bool b);
#line 187 "QcLinEqColStateVector.ch"
inline void
SetBasicIn(unsigned i, int bi) const;
#line 195 "QcLinEqColStateVector.ch"
//-----------------------------------------------------------------------//
// Manipulation functions. //
//-----------------------------------------------------------------------//
virtual void
FixLinkage();
#line 223 "QcLinEqColStateVector.ch"
inline void
Link(QcLinEqColState *state, QcLinEqColState *head);
#line 238 "QcLinEqColStateVector.ch"
inline void
Unlink(QcLinEqColState *state);
#line 251 "QcLinEqColStateVector.ch"
protected:
virtual void
Alloc(QcState **start, QcState **finish);
#line 269 "QcLinEqColStateVector.ch"
virtual void
AddToList(QcState **start, QcState **finish);
#line 292 "QcLinEqColStateVector.ch"
virtual void
RemoveFromList(QcState **start, QcState **finish);
#line 310 "QcLinEqColStateVector.ch"
public:
virtual void
Print(ostream &os) const;
#line 339 "QcLinEqColStateVector.ch"
private:
inline QcLinEqColState *
getState(unsigned i) const;
#line 351 "QcLinEqColStateVector.ch"
public:
QcLinEqColState fParamHead; // head of linked list of non-basic variables.
QcLinEqColState fBasicHead; // head of linked list of basic variables.
};
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/
#endif /* !QcLinEqColStateVectorDCL */

View File

@ -1,264 +0,0 @@
// Generated automatically from QcLinEqColStateVector.ch by /home/pmoulder/usr/local/bin/ch2xx.
#include "QcLinEqColStateVector.hh"
#line 1 "QcLinEqColStateVector.ch"
// $Id: QcLinEqColStateVector.ch,v 1.2 2000/12/06 05:32:56 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include "qoca/QcQuasiColStateVector.hh"
#include "qoca/QcLinEqColState.hh"
#line 49 "QcLinEqColStateVector.ch"
#ifndef NDEBUG
void
QcLinEqColStateVector::assertLinkageInvar() const
{
unsigned nParams = 0, nBasic = 0;
assert( fParamHead.getIndex() == QcLinEqColState::fHeadIndex);
assert( fBasicHead.getIndex() == QcLinEqColState::fHeadIndex);
{
QcState const * const *i, * const *end = fStates + fSize;
for (i = getAllocEnd();
i-- != end;)
{
QcLinEqColState const *curr = CAST(QcLinEqColState const *, *i);
assert( curr->fNextCol == 0);
assert( curr->fPrevCol == 0);
}
assert( i + 1 == end);
for (;i >= fStates; i--)
{
QcLinEqColState const *curr = CAST(QcLinEqColState const *, *i);
if (curr->isBasic())
nBasic++;
else
nParams++;
assert( curr->fNextCol != 0);
assert( curr->fNextCol->fPrevCol == curr);
}
}
assert( nBasic + nParams == fSize);
assert( fParamHead.fNextCol != 0);
assert( fParamHead.fNextCol->fPrevCol == &fParamHead);
for (QcLinEqColState *curr = fParamHead.fNextCol;
curr != &fParamHead;
curr = curr->fNextCol)
{
assert( !curr->isBasic());
assert( curr->fIndex < (int) fSize);
assert( nParams != 0);
nParams--;
}
assert( nParams == 0);
assert( fBasicHead.fNextCol != 0);
assert( fBasicHead.fNextCol->fPrevCol == &fBasicHead);
for (QcLinEqColState *curr = fBasicHead.fNextCol;
curr != &fBasicHead;
curr = curr->fNextCol)
{
assert( curr->isBasic());
assert( curr->getIndex() < fSize);
assert( nBasic != 0);
nBasic--;
}
assert( nBasic == 0);
}
void
QcLinEqColStateVector::virtualAssertLinkageInvar() const
{
assertLinkageInvar();
}
#endif /* !NDEBUG */
//-----------------------------------------------------------------------//
// Query functions. //
//-----------------------------------------------------------------------//
#line 151 "QcLinEqColStateVector.ch"
//-----------------------------------------------------------------------//
// Set functions. //
//-----------------------------------------------------------------------//
#line 172 "QcLinEqColStateVector.ch"
void
QcLinEqColStateVector::SetBasic(unsigned i, bool b)
{
qcAssertPre( i < fSize);
qcAssertPre( (unsigned) b <= 1);
QcLinEqColState *state = getState( i);
if (state->fIsBasic != b)
{
state->fIsBasic = b;
Unlink( state);
Link( state, head( b));
}
}
#line 195 "QcLinEqColStateVector.ch"
//-----------------------------------------------------------------------//
// Manipulation functions. //
//-----------------------------------------------------------------------//
void
QcLinEqColStateVector::FixLinkage()
{
dbg(assertLinkageInvar());
#if 0 /* shouldn't be necessary any more. */
fBasicHead->fPrevCol = fBasicHead->fNextCol = &fBasicHead;
fParamHead->fPrevCol = fParamHead->fNextCol = &fParamHead;
QcLinEqColState heads[] = {fParamHead, fBasicHead};
for (unsigned i = 0; i < fSize; i++)
{
QcLinEqColState *state = getState( i);
unsigned ix = state->isBasic();
assert (ix <= 1);
Link( state, heads[ix]);
}
dbg(assertLinkageInvar());
#endif
}
#line 254 "QcLinEqColStateVector.ch"
void
QcLinEqColStateVector::Alloc(QcState **start, QcState **finish)
{
qcAssertPre( fStates <= start);
qcAssertPre( start <= finish);
qcAssertPre( finish <= fStates + fCapacity);
for (unsigned i = start - fStates;
start != finish;
start++, i++)
*start = new QcLinEqColState( (int) i);
}
void
QcLinEqColStateVector::AddToList(QcState **start, QcState **finish)
{
qcAssertPre( fStates <= start);
qcAssertPre( start < finish);
qcAssertPre( finish <= getAllocEnd());
for(; start != finish; start++)
{
QcLinEqColState *state = CAST(QcLinEqColState *, *start);
assert( (state->fNextCol == 0)
&& (state->fPrevCol == 0)
&& (state->fDesValue == 0.0)
&& (state->fIsBasic == false)
&& (state->fIsBasicIn == QcTableau::fInvalidConstraintIndex));
Link( state, &fParamHead);
}
}
void
QcLinEqColStateVector::RemoveFromList(QcState **start, QcState **finish)
{
qcAssertPre( fStates <= start);
qcAssertPre( start <= finish);
qcAssertPre( finish <= fStates + fSize);
for(; start != finish; start++)
{
QcLinEqColState *state = CAST(QcLinEqColState *, *start);
Unlink( state);
state->fDesValue = 0.0f;
state->fIsBasic = false;
state->fIsBasicIn = QcTableau::fInvalidConstraintIndex;
}
}
void
QcLinEqColStateVector::Print(ostream &os) const
{
QcQuasiColStateVector::Print(os);
os << endl << "Basic variable list:" << endl;
QcLinEqColState *curr = fBasicHead.fNextCol;
while (curr != &fBasicHead)
{
curr->Print(os);
os << endl;
curr = curr->fNextCol;
}
os << endl << "Param variable list:" << endl;
curr = fParamHead.fNextCol;
while (curr != &fBasicHead)
{
curr->Print(os);
os << endl;
curr = curr->fNextCol;
}
}
#line 358 "QcLinEqColStateVector.ch"
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/

View File

@ -1,365 +0,0 @@
// $Id: QcLinEqColStateVector.ch,v 1.2 2000/12/06 05:32:56 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include "qoca/QcQuasiColStateVector.hh"
#include "qoca/QcLinEqColState.hh"
//o[d] class QcLinEqColStateVector
//o[d] : public QcQuasiColStateVector
//o[d] {
//o[d] public:
//begin o[d]
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcLinEqColStateVector()
: QcQuasiColStateVector(),
fParamHead( false),
fBasicHead( true)
{
}
//end o[d]
#ifndef NDEBUG
//o[d] private:
//cf
void
assertLinkageInvar() const
{
unsigned nParams = 0, nBasic = 0;
assert( fParamHead.getIndex() == QcLinEqColState::fHeadIndex);
assert( fBasicHead.getIndex() == QcLinEqColState::fHeadIndex);
{
QcState const * const *i, * const *end = fStates + fSize;
for (i = getAllocEnd();
i-- != end;)
{
QcLinEqColState const *curr = CAST(QcLinEqColState const *, *i);
assert( curr->fNextCol == 0);
assert( curr->fPrevCol == 0);
}
assert( i + 1 == end);
for (;i >= fStates; i--)
{
QcLinEqColState const *curr = CAST(QcLinEqColState const *, *i);
if (curr->isBasic())
nBasic++;
else
nParams++;
assert( curr->fNextCol != 0);
assert( curr->fNextCol->fPrevCol == curr);
}
}
assert( nBasic + nParams == fSize);
assert( fParamHead.fNextCol != 0);
assert( fParamHead.fNextCol->fPrevCol == &fParamHead);
for (QcLinEqColState *curr = fParamHead.fNextCol;
curr != &fParamHead;
curr = curr->fNextCol)
{
assert( !curr->isBasic());
assert( curr->fIndex < (int) fSize);
assert( nParams != 0);
nParams--;
}
assert( nParams == 0);
assert( fBasicHead.fNextCol != 0);
assert( fBasicHead.fNextCol->fPrevCol == &fBasicHead);
for (QcLinEqColState *curr = fBasicHead.fNextCol;
curr != &fBasicHead;
curr = curr->fNextCol)
{
assert( curr->isBasic());
assert( curr->getIndex() < fSize);
assert( nBasic != 0);
nBasic--;
}
assert( nBasic == 0);
}
//o[d] protected:
//cf
virtual void
virtualAssertLinkageInvar() const
{
assertLinkageInvar();
}
#endif /* !NDEBUG */
//-----------------------------------------------------------------------//
// Query functions. //
//-----------------------------------------------------------------------//
//o[d] public:
inline numT
GetDesireValue(unsigned i) const
{
qcAssertPre (i < fSize);
return ((QcLinEqColState *)fStates[i])->fDesValue;
}
inline bool
IsBasic(unsigned i) const
{
qcAssertPre (i < fSize);
return ((QcLinEqColState *)fStates[i])->fIsBasic;
}
inline int
IsBasicIn(unsigned i) const
{
qcAssertPre (i < fSize);
return ((QcLinEqColState *)fStates[i])->fIsBasicIn;
}
//-----------------------------------------------------------------------//
// Set functions. //
//-----------------------------------------------------------------------//
inline void
SetDesireValue(unsigned i, numT dv) const
{
qcAssertPre (i < fSize);
((QcLinEqColState *)fStates[i])->fDesValue = dv;
}
inline QcLinEqColState *
head( bool isbasic)
{
QcLinEqColState *heads = &fParamHead;
assert( &heads[1] == &fBasicHead);
unsigned ix = isbasic;
qcAssertPre( ix <= 1);
return &heads[ix];
}
//cf
void
SetBasic(unsigned i, bool b)
{
qcAssertPre( i < fSize);
qcAssertPre( (unsigned) b <= 1);
QcLinEqColState *state = getState( i);
if (state->fIsBasic != b)
{
state->fIsBasic = b;
Unlink( state);
Link( state, head( b));
}
}
inline void
SetBasicIn(unsigned i, int bi) const
{
qcAssertPre (i < fSize);
((QcLinEqColState *)fStates[i])->fIsBasicIn = bi;
}
//-----------------------------------------------------------------------//
// Manipulation functions. //
//-----------------------------------------------------------------------//
//cf
virtual void
FixLinkage()
{
dbg(assertLinkageInvar());
#if 0 /* shouldn't be necessary any more. */
fBasicHead->fPrevCol = fBasicHead->fNextCol = &fBasicHead;
fParamHead->fPrevCol = fParamHead->fNextCol = &fParamHead;
QcLinEqColState heads[] = {fParamHead, fBasicHead};
for (unsigned i = 0; i < fSize; i++)
{
QcLinEqColState *state = getState( i);
unsigned ix = state->isBasic();
assert (ix <= 1);
Link( state, heads[ix]);
}
dbg(assertLinkageInvar());
#endif
}
inline void
Link(QcLinEqColState *state, QcLinEqColState *head)
{
qcAssertPre( (head == &fParamHead)
|| (head == &fBasicHead));
qcAssertPre( (state->fNextCol == 0)
&& (state->fPrevCol == 0));
state->fPrevCol = head;
head->fNextCol->fPrevCol = state;
state->fNextCol = head->fNextCol;
head->fNextCol = state;
}
inline void
Unlink(QcLinEqColState *state)
{
qcAssertPre( (state->fNextCol != 0)
&& (state->fPrevCol != 0));
state->fNextCol->fPrevCol = state->fPrevCol;
state->fPrevCol->fNextCol = state->fNextCol;
dbg(state->fPrevCol = state->fNextCol = 0);
}
//o[d] protected:
//cf
virtual void
Alloc(QcState **start, QcState **finish)
{
qcAssertPre( fStates <= start);
qcAssertPre( start <= finish);
qcAssertPre( finish <= fStates + fCapacity);
for (unsigned i = start - fStates;
start != finish;
start++, i++)
*start = new QcLinEqColState( (int) i);
}
//cf
virtual void
AddToList(QcState **start, QcState **finish)
{
qcAssertPre( fStates <= start);
qcAssertPre( start < finish);
qcAssertPre( finish <= getAllocEnd());
for(; start != finish; start++)
{
QcLinEqColState *state = CAST(QcLinEqColState *, *start);
assert( (state->fNextCol == 0)
&& (state->fPrevCol == 0)
&& (state->fDesValue == 0.0)
&& (state->fIsBasic == false)
&& (state->fIsBasicIn == QcTableau::fInvalidConstraintIndex));
Link( state, &fParamHead);
}
}
//cf
virtual void
RemoveFromList(QcState **start, QcState **finish)
{
qcAssertPre( fStates <= start);
qcAssertPre( start <= finish);
qcAssertPre( finish <= fStates + fSize);
for(; start != finish; start++)
{
QcLinEqColState *state = CAST(QcLinEqColState *, *start);
Unlink( state);
state->fDesValue = 0.0f;
state->fIsBasic = false;
state->fIsBasicIn = QcTableau::fInvalidConstraintIndex;
}
}
//o[d] public:
//cf
virtual void
Print(ostream &os) const
{
QcQuasiColStateVector::Print(os);
os << endl << "Basic variable list:" << endl;
QcLinEqColState *curr = fBasicHead.fNextCol;
while (curr != &fBasicHead)
{
curr->Print(os);
os << endl;
curr = curr->fNextCol;
}
os << endl << "Param variable list:" << endl;
curr = fParamHead.fNextCol;
while (curr != &fBasicHead)
{
curr->Print(os);
os << endl;
curr = curr->fNextCol;
}
}
private:
inline QcLinEqColState *
getState(unsigned i) const
{
qcAssertPre( i < fSize);
QcLinEqColState *ret = CAST(QcLinEqColState *, fStates[i]);
qcAssertPost( ret != 0);
return ret;
}
//begin o[d]
public:
QcLinEqColState fParamHead; // head of linked list of non-basic variables.
QcLinEqColState fBasicHead; // head of linked list of basic variables.
//end o[d]
//o[d] };
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/

View File

@ -1,165 +0,0 @@
// Generated automatically from QcLinEqColStateVector.ch by /home/pmoulder/usr/local/bin/ch2xx.
#include "QcLinEqColStateVector.H"
#ifndef QcLinEqColStateVectorIFN
#define QcLinEqColStateVectorIFN
#line 1 "QcLinEqColStateVector.ch"
// $Id: QcLinEqColStateVector.ch,v 1.2 2000/12/06 05:32:56 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include "qoca/QcQuasiColStateVector.hh"
#include "qoca/QcLinEqColState.hh"
#line 49 "QcLinEqColStateVector.ch"
#ifndef NDEBUG
#line 121 "QcLinEqColStateVector.ch"
#endif /* !NDEBUG */
//-----------------------------------------------------------------------//
// Query functions. //
//-----------------------------------------------------------------------//
inline numT
QcLinEqColStateVector::GetDesireValue(unsigned i) const
{
qcAssertPre (i < fSize);
return ((QcLinEqColState *)fStates[i])->fDesValue;
}
inline bool
QcLinEqColStateVector::IsBasic(unsigned i) const
{
qcAssertPre (i < fSize);
return ((QcLinEqColState *)fStates[i])->fIsBasic;
}
inline int
QcLinEqColStateVector::IsBasicIn(unsigned i) const
{
qcAssertPre (i < fSize);
return ((QcLinEqColState *)fStates[i])->fIsBasicIn;
}
//-----------------------------------------------------------------------//
// Set functions. //
//-----------------------------------------------------------------------//
inline void
QcLinEqColStateVector::SetDesireValue(unsigned i, numT dv) const
{
qcAssertPre (i < fSize);
((QcLinEqColState *)fStates[i])->fDesValue = dv;
}
inline QcLinEqColState *
QcLinEqColStateVector::head( bool isbasic)
{
QcLinEqColState *heads = &fParamHead;
assert( &heads[1] == &fBasicHead);
unsigned ix = isbasic;
qcAssertPre( ix <= 1);
return &heads[ix];
}
#line 187 "QcLinEqColStateVector.ch"
inline void
QcLinEqColStateVector::SetBasicIn(unsigned i, int bi) const
{
qcAssertPre (i < fSize);
((QcLinEqColState *)fStates[i])->fIsBasicIn = bi;
}
//-----------------------------------------------------------------------//
// Manipulation functions. //
//-----------------------------------------------------------------------//
#line 223 "QcLinEqColStateVector.ch"
inline void
QcLinEqColStateVector::Link(QcLinEqColState *state, QcLinEqColState *head)
{
qcAssertPre( (head == &fParamHead)
|| (head == &fBasicHead));
qcAssertPre( (state->fNextCol == 0)
&& (state->fPrevCol == 0));
state->fPrevCol = head;
head->fNextCol->fPrevCol = state;
state->fNextCol = head->fNextCol;
head->fNextCol = state;
}
inline void
QcLinEqColStateVector::Unlink(QcLinEqColState *state)
{
qcAssertPre( (state->fNextCol != 0)
&& (state->fPrevCol != 0));
state->fNextCol->fPrevCol = state->fPrevCol;
state->fPrevCol->fNextCol = state->fNextCol;
dbg(state->fPrevCol = state->fNextCol = 0);
}
#line 340 "QcLinEqColStateVector.ch"
inline QcLinEqColState *
QcLinEqColStateVector::getState(unsigned i) const
{
qcAssertPre( i < fSize);
QcLinEqColState *ret = CAST(QcLinEqColState *, fStates[i]);
qcAssertPost( ret != 0);
return ret;
}
#line 358 "QcLinEqColStateVector.ch"
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/
#endif /* !QcLinEqColStateVectorIFN */

View File

@ -1,169 +0,0 @@
// $Id: QcLinEqRowColStateVector.hh,v 1.8 2001/01/30 01:32:08 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcLinEqRowColStateVectorH
#define __QcLinEqRowColStateVectorH
#include "qoca/QcQuasiRowColStateVector.hh"
#include "qoca/QcLinEqRowStateVector.hh"
#include "qoca/QcLinEqColStateVector.hh"
class QcLinEqRowColStateVector : public QcQuasiRowColStateVector
{
public:
QcLinEqRowStateVector *fRowState;
QcLinEqColStateVector *fColState;
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcLinEqRowColStateVector();
QcLinEqRowColStateVector(QcLinEqColStateVector *csv);
//-----------------------------------------------------------------------//
// Query functions. //
//-----------------------------------------------------------------------//
QcLinEqRowStateVector &GetRowState() const
{ return *fRowState; }
QcLinEqColStateVector &GetColState() const
{ return *fColState; }
//-----------------------------------------------------------------------//
// Manipulation functions. //
//-----------------------------------------------------------------------//
virtual void SwapColumns(unsigned v1, unsigned v2);
#if 0 /* unused */
virtual void SwapRows(unsigned c1, unsigned c2);
#endif
};
inline QcLinEqRowColStateVector::QcLinEqRowColStateVector()
: QcQuasiRowColStateVector(new QcLinEqRowStateVector(),
new QcLinEqColStateVector())
{
fRowState = (QcLinEqRowStateVector *)QcQuasiRowColStateVector::fRowState;
fColState = (QcLinEqColStateVector *)QcQuasiRowColStateVector::fColState;
}
inline QcLinEqRowColStateVector::QcLinEqRowColStateVector(
QcLinEqColStateVector *csv)
: QcQuasiRowColStateVector(new QcLinEqRowStateVector(), csv)
{
fRowState = (QcLinEqRowStateVector *)QcQuasiRowColStateVector::fRowState;
fColState = (QcLinEqColStateVector *)QcQuasiRowColStateVector::fColState;
}
inline void QcLinEqRowColStateVector::SwapColumns(unsigned v1, unsigned v2)
{
qcAssertPre( v1 < fColState->getNColumns());
qcAssertPre( v2 < fColState->getNColumns());
if (v1 == v2)
return;
QcLinEqColState *r1 = (QcLinEqColState *)fColState->GetState(v1);
QcLinEqColState *r2 = (QcLinEqColState *)fColState->GetState(v2);
// Swap col references in fRowState
{
int c1 = r1->getConstraintBasicIn();
int c2 = r2->getConstraintBasicIn();
if (c1 != QcTableau::fInvalidConstraintIndex)
fRowState->SetBasicVar( c1, v2);
if (c2 != QcTableau::fInvalidConstraintIndex)
fRowState->SetBasicVar( c2, v1);
}
// Exchange the data contents (excluding the Index field)
{
int isbin = r1->getConstraintBasicIn();
r1->fIsBasicIn = r2->getConstraintBasicIn();
r2->fIsBasicIn = isbin;
}
{
numT dv = r1->fDesValue;
r1->fDesValue = r2->fDesValue;
r2->fDesValue = dv;
}
// Now fix up the linkage
if (r1->fIsBasic != r2->fIsBasic)
{ // N.B. its an unordered list!
if (r2->fIsBasic)
{ // Make r1-> original basic
QcLinEqColState *temp = r2; // and r2-> original parameter
r2 = r1;
r1 = temp;
}
assert( r1->fIsBasic && !r2->fIsBasic);
// First, the Basic vars linked list
fColState->Unlink( r1);
fColState->Unlink( r2);
// Finally, swap over the descriminator.
r1->fIsBasic = false;
r2->fIsBasic = true;
fColState->Link( r1, &fColState->fParamHead);
fColState->Link( r2, &fColState->fBasicHead);
}
}
#if 0 /* unused */
inline void QcLinEqRowColStateVector::SwapRows(unsigned c1, unsigned c2)
{
qcAssertPre( c1 < fRowState->getNRows());
qcAssertPre( c2 < fRowState->getNRows());
if (c1 == c2)
return;
QcLinEqRowState *r1 = (QcLinEqRowState *)fRowState->GetState(c1);
QcLinEqRowState *r2 = (QcLinEqRowState *)fRowState->GetState(c2);
// Swap row references in ColState
int v1 = r1->fBasicVar;
int v2 = r2->fBasicVar;
if (v1 != QcTableau::fInvalidVariableIndex)
fColState->SetBasicIn(v1, c2);
if (v2 != QcTableau::fInvalidVariableIndex)
fColState->SetBasicIn(v2, c1);
// Swap fCondition, fBasicVar
r1->swap( *r2);
// Swap lower level properties
QcQuasiRowColStateVector::SwapRows(c1, c2);
}
#endif /* unused */
#endif /* !__QcLinEqRowColStateVectorH */

View File

@ -1,135 +0,0 @@
// $Id: QcLinEqRowState.hh,v 1.4 2000/12/13 01:44:58 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//----------------------------------------------------------------------------//
// The class QcBiMap provides a bi-directional mapping from //
// identifier class to index class. //
//============================================================================//
#ifndef __QcLinEqRowStateH
#define __QcLinEqRowStateH
#include "qoca/QcQuasiRowState.hh"
#include "qoca/QcTableau.hh"
class QcLinEqRowState : public QcQuasiRowState
{
public:
enum {
fInvalid = 0,
fNormalised = 1,
fRegular = 2,
fRedundant = 3
};
// If any row is normalised then the tableau is not in solved form
// (undetermined means invalid or normalised).
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcLinEqRowState(int ci);
//-----------------------------------------------------------------------//
// Utility functions. //
//-----------------------------------------------------------------------//
virtual void Print(ostream &os);
int getCondition() const
{
dbg(assertValidCondition( fCondition));
return fCondition;
}
void setCondition(int c)
{
dbg(assertValidCondition( c));
fCondition = c;
}
void swap(QcLinEqRowState &other)
{
// Swap fCondition
{
int tmp = fCondition;
fCondition = other.fCondition;
other.fCondition = tmp;
}
// Swap fBasicVar
{
int tmp = fBasicVar;
fBasicVar = other.fBasicVar;
other.fBasicVar = tmp;
}
}
private:
#ifndef NDEBUG
void assertValidCondition(int c) const
{
assert( (unsigned) c <= 3);
}
#endif
private:
int fCondition;
public:
int fBasicVar; // The basic variable for a regular row else
// fInvalidVariableIndex.
};
inline QcLinEqRowState::QcLinEqRowState(int ci)
: QcQuasiRowState(ci)
{
fCondition = fInvalid;
fBasicVar = QcTableau::fInvalidVariableIndex;
}
inline void QcLinEqRowState::Print(ostream &os)
{
QcQuasiRowState::Print(os);
os << ",Cond(";
switch (fCondition) {
case fInvalid:
os << "Invalid";
break;
case fNormalised:
os << "Normalised";
break;
case fRegular:
os << "Regular";
break;
case fRedundant:
os << "Redundant";
break;
}
os << "), BasicVar(" << fBasicVar << ")";
}
#endif

View File

@ -1,99 +0,0 @@
// Generated automatically from QcLinEqRowStateVector.ch by /home/pmoulder/usr/local/bin/ch2xx.
#ifndef QcLinEqRowStateVectorDCL
#define QcLinEqRowStateVectorDCL
#line 1 "QcLinEqRowStateVector.ch"
// $Id: QcLinEqRowStateVector.ch,v 1.3 2000/12/13 01:44:58 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include <qoca/QcQuasiRowStateVector.H>
#include <qoca/QcLinEqRowState.hh>
class QcLinEqRowStateVector
: public QcQuasiRowStateVector
{
public:
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcLinEqRowStateVector()
: QcQuasiRowStateVector()
{ }
//-----------------------------------------------------------------------//
// Query functions. //
//-----------------------------------------------------------------------//
int GetBasicVar(unsigned i) const
{
qcAssertPre (i < fSize);
return ((QcLinEqRowState *)fStates[i])->fBasicVar;
}
int GetCondition(unsigned i) const
{
qcAssertPre (i < fSize);
return ((QcLinEqRowState *)fStates[i])->getCondition();
}
//-----------------------------------------------------------------------//
// Set functions. //
//-----------------------------------------------------------------------//
void SetBasicVar(unsigned i, int vi)
{
qcAssertPre (i < fSize);
((QcLinEqRowState *)fStates[i])->fBasicVar = vi;
}
void SetCondition(unsigned i, int c)
{
qcAssertPre (i < fSize);
((QcLinEqRowState *)fStates[i])->setCondition( c);
}
virtual void
Alloc(QcState **start, QcState **finish);
#line 91 "QcLinEqRowStateVector.ch"
virtual void
RemoveFromList(QcState **start, QcState **finish);
#line 108 "QcLinEqRowStateVector.ch"
};
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/
#endif /* !QcLinEqRowStateVectorDCL */

View File

@ -1,82 +0,0 @@
// Generated automatically from QcLinEqRowStateVector.ch by /home/pmoulder/usr/local/bin/ch2xx.
#include "QcLinEqRowStateVector.hh"
#line 1 "QcLinEqRowStateVector.ch"
// $Id: QcLinEqRowStateVector.ch,v 1.3 2000/12/13 01:44:58 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include <qoca/QcLinEqRowState.hh>
#line 77 "QcLinEqRowStateVector.ch"
void
QcLinEqRowStateVector::Alloc(QcState **start, QcState **finish)
{
qcAssertPre( fStates <= start);
qcAssertPre( start <= finish);
qcAssertPre( finish <= fStates + fCapacity);
for (unsigned i = start - fStates;
start != finish;
start++, i++)
*start = new QcLinEqRowState( i);
}
void
QcLinEqRowStateVector::RemoveFromList(QcState **start, QcState **finish)
{
qcAssertPre( fStates <= start);
qcAssertPre( start <= finish);
qcAssertPre( finish <= fStates + fSize);
for(; start != finish; start++)
{
QcLinEqRowState *state = CAST(QcLinEqRowState *, *start);
state->setCondition( QcLinEqRowState::fInvalid);
state->fBasicVar = QcTableau::fInvalidVariableIndex;
QcQuasiRowStateVector::Restart( start - fStates);
}
}
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/

View File

@ -1,118 +0,0 @@
// $Id: QcLinEqRowStateVector.ch,v 1.3 2000/12/13 01:44:58 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
//o[d] #include <qoca/QcQuasiRowStateVector.H>
//o[i] #include <qoca/QcQuasiRowStateVector.hh>
#include <qoca/QcLinEqRowState.hh>
//o[d] class QcLinEqRowStateVector
//o[d] : public QcQuasiRowStateVector
//o[d] {
//o[d] public:
//begin o[d]
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcLinEqRowStateVector()
: QcQuasiRowStateVector()
{ }
//-----------------------------------------------------------------------//
// Query functions. //
//-----------------------------------------------------------------------//
int GetBasicVar(unsigned i) const
{
qcAssertPre (i < fSize);
return ((QcLinEqRowState *)fStates[i])->fBasicVar;
}
int GetCondition(unsigned i) const
{
qcAssertPre (i < fSize);
return ((QcLinEqRowState *)fStates[i])->getCondition();
}
//-----------------------------------------------------------------------//
// Set functions. //
//-----------------------------------------------------------------------//
void SetBasicVar(unsigned i, int vi)
{
qcAssertPre (i < fSize);
((QcLinEqRowState *)fStates[i])->fBasicVar = vi;
}
void SetCondition(unsigned i, int c)
{
qcAssertPre (i < fSize);
((QcLinEqRowState *)fStates[i])->setCondition( c);
}
//end o[d]
//cf
virtual void
Alloc(QcState **start, QcState **finish)
{
qcAssertPre( fStates <= start);
qcAssertPre( start <= finish);
qcAssertPre( finish <= fStates + fCapacity);
for (unsigned i = start - fStates;
start != finish;
start++, i++)
*start = new QcLinEqRowState( i);
}
//cf
virtual void
RemoveFromList(QcState **start, QcState **finish)
{
qcAssertPre( fStates <= start);
qcAssertPre( start <= finish);
qcAssertPre( finish <= fStates + fSize);
for(; start != finish; start++)
{
QcLinEqRowState *state = CAST(QcLinEqRowState *, *start);
state->setCondition( QcLinEqRowState::fInvalid);
state->fBasicVar = QcTableau::fInvalidVariableIndex;
QcQuasiRowStateVector::Restart( start - fStates);
}
}
//o[d] };
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/

View File

@ -1,52 +0,0 @@
// Generated automatically from QcLinEqRowStateVector.ch by /home/pmoulder/usr/local/bin/ch2xx.
#include "QcLinEqRowStateVector.H"
#ifndef QcLinEqRowStateVectorIFN
#define QcLinEqRowStateVectorIFN
#line 1 "QcLinEqRowStateVector.ch"
// $Id: QcLinEqRowStateVector.ch,v 1.3 2000/12/13 01:44:58 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include <qoca/QcQuasiRowStateVector.hh>
#include <qoca/QcLinEqRowState.hh>
#line 111 "QcLinEqRowStateVector.ch"
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/
#endif /* !QcLinEqRowStateVectorIFN */

View File

@ -1,459 +0,0 @@
// $Id: QcLinEqSolver.cc,v 1.16 2001/01/30 01:32:08 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include "qoca/QcDefines.hh"
#include "qoca/QcDesireValueStore.hh"
#include "qoca/QcLinEqSolver.hh"
#include "qoca/QcParamVarIndexIterator.hh"
#include "qoca/QcTableauColIterator.hh"
#include "qoca/QcBasicVarIndexIterator.hh"
#include "qoca/QcSparseMatrixRowIterator.hh"
#include "qoca/QcVariableIndexIterator.hh"
#ifndef NDEBUG
void QcLinEqSolver::assertDeepInvar() const
{
QcSolver::assertDeepInvar();
fSystem.vAssertDeepInvar();
}
void QcLinEqSolver::vAssertDeepInvar() const
{
assertDeepInvar();
}
#endif
void QcLinEqSolver::BeginEdit()
{
vector<QcFloat>::iterator voiIt;
vector<unsigned int>::iterator viIt;
// build a version of fEditVars by index.
fVarsByIndex.resize(0);
for (voiIt = fEditVars.begin(); voiIt != fEditVars.end(); ++voiIt)
fVarsByIndex.push_back(fVBiMap.Index(*voiIt));
fSubSystem.Restart();
TransitiveClosure(); // Calculates fDepPars and fDepBasicVars
// Create a variable for the desired value of each EditVars.
// Also set fSubSystem EditVars to this->EditVars.
fDesValVar.resize( fTableau.getNColumns());
for (unsigned i = 0; i < fVarsByIndex.size(); i++)
{
unsigned vi = fVarsByIndex[i];
assert( vi < fTableau.getNColumns());
fSubSystem.RegisterEditVar( fDesValVar[vi] = QcFloat( "desired value"));
}
// Make a copy of a matrix of coefficients to speed up GenerateKT1.
QcSparseMatrix ccache;
ccache.Resize(fTableau.GetRows(), fTableau.GetColumns());
QcParamVarIndexIterator vIt(fTableau);
while (!vIt.AtEnd()) {
QcTableauColIterator colCoeffs (fTableau, vIt.getIndex());
while (!colCoeffs.AtEnd()) {
ccache.SetValue(colCoeffs.getIndex(), vIt.getIndex(), colCoeffs.getValue());
colCoeffs.Increment();
}
vIt.Increment();
}
#ifndef qcRealTableauRHS
vector<numT> crhs;
crhs.Resize(fTableau.GetRows());
for (int r = 0; r < fTableau.GetRows(); r++)
crhs[r] = fTableau.GetRHS(r);
#endif
// Generate subsystem KT constraint for each dependent parameter
// Also set fSystem EditVars to fDepPars.
fSystem.ClearEditVars();
for (viIt = fDepPars.begin(); viIt != fDepPars.end(); ++viIt) {
QcFloat &v = fVBiMap.Identifier(*viIt);
// N.B. constraint may be needed even when v is free
GenerateKT2(v, ccache
#ifndef qcRealTableauRHS
, crhs
#endif
);
fSystem.RegisterEditVar(v);
}
fSubSystem.BeginEdit();
fEditVarsSetup = true;
dbg(assertInvar());
}
void QcLinEqSolver::EndEdit()
{
vector<unsigned int>::const_iterator vIt;
for (unsigned int vi = 0; vi < fDepBasicVars.size(); ++vi)
if (fDepBasicVars[vi])
fVBiMap.Identifier(vi).RestVariable();
for (vIt = fDepPars.begin(); vIt != fDepPars.end(); ++vIt)
fVBiMap.Identifier(*vIt).RestVariable();
QcSolver::EndEdit();
dbg(assertInvar());
}
void QcLinEqSolver::GenerateKT1(QcFloat &p, QcSparseMatrix &ccache
#ifndef qcRealTableauRHS
, vector<numT> &crhs
#endif
)
// Generate the constraint df'/dp == 0
// where f' = least squares objective function with basic variables
// eliminated. Add the constraint to the subsystem fSubSystem.
// It is important that this routine does not rely on
// the values of any of the variables being a solution of LinEq.
// See note in QcLinEqSolver::Solve.
{
#ifndef qcRealTableauRHS
qcAssertPre (crhs.size() == ccache.getNRows());
#endif
QcLinPoly lpoly; // N.B. lpoly is destroyed when this routine returns
numT rhs = 0.0;
int pIndex = fVBiMap.Index(p);
numT pWeight2 = p.Weight() * 2;
numT pAccumulator = pWeight2;
QcBasicVarIndexIterator bvIt(fTableau);
while (!bvIt.AtEnd()) {
QcFloat &bv = fVBiMap.Identifier(bvIt.getIndex());
unsigned c = bvIt.getConstraintBasicIn(); // use constraint c to eliminate bv
assert (c < ccache.getNRows());
numT pCoeff = ccache.GetValue(c, pIndex);
numT factor = bv.Weight() * pCoeff * 2;
pAccumulator += factor * pCoeff;
QcSparseMatrixRowIterator varCoeffs(ccache, c);
while (!varCoeffs.AtEnd()) {
QcFloat &pv = fVBiMap.Identifier(varCoeffs.GetIndex());
int pvIndex = varCoeffs.GetIndex();
if (pvIndex!=pIndex)
lpoly += QcLinPolyTerm(factor * varCoeffs.GetValue(), pv);
varCoeffs.Increment();
}
#ifdef qcRealTableauRHS
rhs += factor * (fTableau.GetRHS(c) - bv.DesireValue());
#else
rhs += factor * (crhs[c] - bv.GetDesValue());
#endif
bvIt.Increment();
}
lpoly.Push(pAccumulator, p);
rhs += pWeight2 * p.DesireValue();
QcConstraint kt("", lpoly, QcConstraintRep::coEQ, rhs);
#ifdef qcSafetyChecks
if (!fSubSystem.AddConstraint(kt))
throw QcWarning("QcLinEqSolver::GenerateKT1: subsystem inconsistant");
#else
fSubSystem.AddConstraint(kt);
#endif
}
void QcLinEqSolver::GenerateKT2(QcFloat &p, QcSparseMatrix &ccache
#ifndef qcRealTableauRHS
, vector<numT> &crhs
#endif
)
// Generate the constraint df'/dp == 0 where parameters of interest
// have variable desired values and where f' = least squares
// objective function with basic variables eliminated.
// Add the constraint to the subsystem fSubSystem.
{
#ifndef qcRealTableauRHS
qcAssertPre (crhs.size() == ccache.getNRows());
#endif
QcLinPoly lpoly; // N.B. lpoly is destroyed when this routine returns
numT rhs = 0.0;
int pIndex = fVBiMap.Index(p);
numT pWeight2 = p.Weight() * 2;
numT pAccumulator = pWeight2;
QcFloat &pDV = fDesValVar[pIndex];
QcBasicVarIndexIterator bvIt(fTableau);
while (!bvIt.AtEnd()) {
unsigned bvi = bvIt.getIndex();
QcFloat &bv = fVBiMap.Identifier(bvi);
unsigned c = bvIt.getConstraintBasicIn(); // use constraint c to eliminate bv
assert (c < ccache.getNRows());
numT pCoeff = ccache.GetValue(c, pIndex);
numT factor = bv.Weight() * pCoeff * 2;
pAccumulator += factor * pCoeff;
QcSparseMatrixRowIterator varCoeffs(ccache, c);
while (!varCoeffs.AtEnd()) {
QcFloat &pv = fVBiMap.Identifier(varCoeffs.GetIndex());
int pvIndex = varCoeffs.GetIndex();
if (pvIndex!=pIndex)
lpoly += QcLinPolyTerm(factor * varCoeffs.GetValue(), pv);
varCoeffs.Increment();
}
if (IsDepBasicVar(bvi) && IsEditVar(bv)) {
#ifdef qcRealTableauRHS
rhs += factor * fTableau.GetRHS(c);
#else
rhs += factor * crhs[c];
#endif
lpoly += QcLinPolyTerm(factor, fDesValVar[bvi]);
} else {
#ifdef qcRealTableauRHS
rhs += factor * (fTableau.GetRHS(c) - bv.DesireValue());
#else
rhs += factor * (crhs[c] - bv.GetDesValue());
#endif
}
bvIt.Increment();
}
lpoly.Push(pAccumulator, p);
if (IsEditVar(p))
lpoly.Push(-pWeight2, pDV);
else
rhs += pWeight2 * p.DesireValue();
QcConstraint kt("", lpoly, QcConstraintRep::coEQ, rhs);
#ifdef qcSafetyChecks
if (!fSubSystem.AddConstraint(kt))
throw QcWarning("QcLinEqSolver::GenerateKT2: subsystem inconsistant");
#else
fSubSystem.AddConstraint(kt);
#endif
}
bool QcLinEqSolver::IsDepPar(int vi) const
{
if (vi < 0) /* TODO: We can probably assertPre (vi > 0). Similarly for other IsDepPar implementations. */
return false;
vector<unsigned int>::const_iterator it;
for (it = fDepPars.begin(); it != fDepPars.end(); ++it)
if ((*it) == (unsigned) vi)
return true;
return false;
}
numT QcLinEqSolver::Objective()
{
numT opt = 0.0;
QcVariableIndexIterator vIt(fTableau);
while (!vIt.AtEnd()) {
QcFloat &v = fVBiMap.Identifier(vIt.getIndex());
numT delta = v.Value() - v.DesireValue();
opt += v.Weight() * delta * delta;
vIt.Increment();
}
return opt;
}
void QcLinEqSolver::Resolve()
{
if (!fEditVarsSetup)
BeginEdit();
// Setup the desired value variables.
assert( fVarsByIndex.size() == fEditVars.size());
for (unsigned i = 0; i < fVarsByIndex.size(); i++)
{
unsigned vi = fVarsByIndex[i];
assert( vi < fDesValVar.size());
fDesValVar[vi].SuggestValue( fEditVars[i].DesireValue());
}
fSubSystem.Resolve();
/* effic: The handling of saveDesireValue (both here and in Solve) could
be improved: we do a lot of unnecessary construction and
deconstruction. */
vector<QcDesireValueStore> saveDesireValue;
// The dependent variables have their desired values altered
// according to the value found by the subsystem solve.
for (vector<unsigned int>::const_iterator vIt = fDepPars.begin();
vIt != fDepPars.end();
++vIt)
{
QcFloatRep *vr = fVBiMap.getIdentifierPtr( *vIt);
saveDesireValue.push_back( QcDesireValueStore( vr));
if (!vr->RestDesVal_changed())
saveDesireValue.pop_back();
}
fSystem.Resolve();
// Restore the altered desired values.
for (vector<QcDesireValueStore>::iterator irdv = saveDesireValue.begin(), irdvEnd = saveDesireValue.end();
irdv != irdvEnd;
irdv++)
irdv->Restore();
#if qcCheckPost
checkSatisfied();
dbg(assertInvar());
#endif
}
void QcLinEqSolver::Solve()
{
// Make a copy of a matrix of coefficients to speed up GenerateKT1.
QcSparseMatrix ccache;
ccache.Resize(fTableau.GetRows(), fTableau.GetColumns());
QcParamVarIndexIterator vIt(fTableau);
while (!vIt.AtEnd()) {
QcTableauColIterator colCoeffs (fTableau, vIt.getIndex());
while (!colCoeffs.AtEnd()) {
ccache.SetValue (colCoeffs.getIndex(), vIt.getIndex(), colCoeffs.getValue());
colCoeffs.Increment();
}
vIt.Increment();
}
#ifndef qcRealTableauRHS
vector<numT> crhs;
crhs.Resize(tableau.GetRows());
for (int r = 0; r < fTableau.GetRows(); r++)
crhs[r] = fTableau.GetRHS(r);
#endif
// Generate a subsystem constraint for each parametric variable.
fSubSystem.Restart();
vIt.Reset();
while (!vIt.AtEnd()) {
unsigned vi = vIt.getIndex();
// The test avoids entering a redundant constraint in
// the subsystem to save time. Also, there is no need to
// call v.Set when the variable is free since this will be
// done when LinEq::Solve() is called later.
if (!fTableau.IsFree(vi))
GenerateKT1(fVBiMap.Identifier(vi), ccache
#ifndef qcRealTableauRHS
, crhs
#endif
);
vIt.Increment();
}
fSubSystem.Solve();
vector<QcDesireValueStore> saveDesireValue;
// At this point we have final values for the non-free parametric
// variables. Set the desired values and solve the original system
// again to get the values for the basic variables.
// Make a record of the altered desired values.
for (QcBasicVarIndexIterator bvIt( fSubSystem.GetTableau());
!bvIt.AtEnd();
bvIt.Increment())
{
unsigned ix = bvIt.getIndex();
assert( fSubSystem.GetTableau().IsBasic( ix));
QcFloatRep *vr = fSubSystem.GetVBiMap().getIdentifierPtr( ix);
saveDesireValue.push_back( QcDesireValueStore( vr));
if (!vr->RestDesVal_changed())
saveDesireValue.pop_back();
}
fSystem.Solve();
// Restore the altered desired values
for (vector<QcDesireValueStore>::iterator irdv = saveDesireValue.begin(), irdvEnd = saveDesireValue.end();
irdv != irdvEnd;
irdv++)
irdv->Restore();
// And now the variable values provide the solution.
#if qcCheckPost
checkSatisfied();
#endif
}
void QcLinEqSolver::TransitiveClosure()
{
vector<unsigned int> depVars(fVarsByIndex);
fSystem.TransitiveClosure(depVars);
// Sift depVars into fDepPars and fDepBasicVars.
fDepBasicVars.resize( fTableau.getNColumns());
for (unsigned int i = 0; i < fDepBasicVars.size(); i++)
fDepBasicVars[i] = false;
fDepPars.resize(0);
for (unsigned i = 0; i < depVars.size(); i++)
{
unsigned vi = depVars[i];
if (fTableau.IsBasic( vi))
fDepBasicVars[vi] = true;
else
fDepPars.push_back( vi);
}
}
void QcLinEqSolver::Print(ostream &os) const
{
fSystem.Print(os);
if (fEditVarsSetup) {
os << "Subsystem:" << endl;
fSubSystem.Print(os);
os << endl << "fDepBasicVars is:";
for (unsigned int i = 0; i < fDepBasicVars.size(); i++)
if (fDepBasicVars[i])
os << i << ", ";
os << endl << "fDepPars is:";
for (unsigned int i = 0; i < fDepPars.size(); i++)
os << fDepPars[i] << ", ";
}
}

View File

@ -1,247 +0,0 @@
// $Id: QcLinEqSolver.hh,v 1.12 2001/01/30 01:32:08 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//----------------------------------------------------------------------------//
// This interface needs to be read in conjuction with that of Solver. //
//============================================================================//
#ifndef __QcEqSolverH
#define __QcEqSolverH
#include "qoca/QcDelLinEqSystem.hh"
class QcLinEqSolver : public QcSolver
{
protected:
QcDelLinEqSystem fSystem;
#if defined(qcRealTableauCoeff) || defined(qcRealTableauRHS)
QcLinEqSystem fSubSystem;
#else
QcDelLinEqSystem fSubSystem;
#endif
vector<QcFloat> fDesValVar;
vector<unsigned int> fDepPars;
vector<unsigned int> fVarsByIndex;
vector<bool> fDepBasicVars;
QcVariableBiMap &fVBiMap;
const QcBiMapNotifier &fNotifier;
QcConstraintBiMap &fOCBiMap;
QcDelLinEqTableau &fTableau;
public:
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcLinEqSolver();
QcLinEqSolver(unsigned hintNumConstraints, unsigned hintNumVariables);
#ifndef NDEBUG
void assertInvar() const { }
void assertDeepInvar() const;
virtual void vAssertDeepInvar() const;
#endif
//-----------------------------------------------------------------------//
// Variable management methods //
//-----------------------------------------------------------------------//
virtual void AddVar(QcFloat &v)
{ fSystem.AddVar(v); }
virtual void SuggestValue(QcFloat &v, numT desval)
{ fSystem.SuggestValue(v, desval); }
virtual bool RemoveVar(QcFloat &v)
{ return fSystem.RemoveVar(v); }
virtual void RestSolver()
{ fSystem.RestSolver(); }
//-----------------------------------------------------------------------//
// Enquiry functions for variables //
//-----------------------------------------------------------------------//
virtual bool IsRegistered(QcFloat const &v) const
{ return fSystem.IsRegistered(v); }
virtual bool IsFree(QcFloat const &v) const
{ return fSystem.IsFree(v); }
virtual bool IsBasic(QcFloat const &v) const
{ return fSystem.IsBasic(v); }
bool IsDepBasicVar(unsigned vi) const
{
qcAssertPre( vi < fDepBasicVars.size());
return fDepBasicVars[vi];
}
bool IsDepPar(int vi) const;
//-----------------------------------------------------------------------//
// High Level Edit Variable Interface for use by solver clients. //
//-----------------------------------------------------------------------//
virtual void BeginEdit();
virtual void EndEdit();
//-----------------------------------------------------------------------//
// Constraint management methods //
//-----------------------------------------------------------------------//
virtual bool AddConstraint(QcConstraint &c);
virtual bool AddConstraint(QcConstraint &c, QcFloat &hint);
virtual bool ChangeConstraint(QcConstraint &oldc, numT rhs);
virtual bool RemoveConstraint(QcConstraint &c);
virtual bool Reset()
{ return fSystem.Reset(); }
//-----------------------------------------------------------------------//
// Constraint Solving methods //
//-----------------------------------------------------------------------//
virtual void Solve();
// IMPORTANT NOTE.
// It is is not necessary to call QcLinEqSystem::solve() before
// creating and solving the subsystem since the subsystem
// is created without using the values of any variables - just
// desired values and weights.
virtual void Resolve();
protected:
numT Objective();
//-----------------------------------------------------------------------//
// Sub-system specific functions. //
//-----------------------------------------------------------------------//
void GenerateKT1(QcFloat &p, QcSparseMatrix &ccache
#ifndef qcRealTableauRHS
, vector<numT> &crhs
#endif
);
// Generate the constraint df'/dp == 0
// where f' = least squares objective function with basic variables
// eliminated. Add the constraint to the subsystem fSubSystem.
// It is important that this routine does not rely on
// the values of any of the variables being a solution of LinEq.
// See note in QcLinEqSolver::Solve.
void GenerateKT2(QcFloat &p, QcSparseMatrix &ccache
#ifndef qcRealTableauRHS
, vector<numT> &crhs
#endif
);
// Generate the constraint df'/dp == 0 where parameters of interest
// have variable desired values and where f' = least squares
// objective function with basic variables eliminated.
// Add the constraint to the subsystem fSubSystem.
void TransitiveClosure();
// Calculates dependent basic variables and parameters as transitive
// closure of VOI using the relation "belongs to same constraint".
//-----------------------------------------------------------------------//
// Utility functions. //
//-----------------------------------------------------------------------//
QcConstraint GetConstraint(const char *n)
{ return fSystem.GetConstraint(n); }
QcFloat GetVariable(const char *n)
{ return fSystem.GetVariable(n); }
void GetVariableSet(vector<QcFloat> &vars)
{ fSystem.GetVariableSet(vars); }
virtual void Print(ostream &os) const;
};
inline QcLinEqSolver::QcLinEqSolver()
: QcSolver(),
fVBiMap(fSystem.GetVBiMap()),
fNotifier(fSystem.GetNotifier()),
fOCBiMap(fSystem.GetOCBiMap()),
fTableau((QcDelLinEqTableau &)fSystem.GetTableau())
{
}
inline QcLinEqSolver::QcLinEqSolver(unsigned hintNumConstraints, unsigned hintNumVariables)
: QcSolver(),
fSystem(hintNumConstraints, hintNumVariables),
fSubSystem(hintNumConstraints, hintNumVariables),
fVBiMap(fSystem.GetVBiMap()),
fNotifier(fSystem.GetNotifier()),
fOCBiMap(fSystem.GetOCBiMap()),
fTableau((QcDelLinEqTableau &)fSystem.GetTableau())
{
}
inline bool QcLinEqSolver::AddConstraint(QcConstraint &c)
{
bool success = fSystem.AddConstraint(c);
if (success) {
#if qcCheckPost
addCheckedConstraint( c.pointer());
#endif
if (fAutoSolve)
Solve();
}
return success;
}
inline bool QcLinEqSolver::AddConstraint(QcConstraint &c, QcFloat &hint)
{
bool success = fSystem.AddConstraint(c, hint);
if (success) {
#if qcCheckPost
addCheckedConstraint( c.pointer());
#endif
if (fAutoSolve)
Solve();
}
return success;
}
inline bool QcLinEqSolver::ChangeConstraint(QcConstraint &oldc, numT rhs)
{
bool success = fSystem.ChangeConstraint(oldc, rhs);
#if qcCheckPost
if (success)
changeCheckedConstraint( oldc.pointer(), rhs);
#endif
return success;
}
inline bool QcLinEqSolver::RemoveConstraint(QcConstraint &c)
{
bool success = fSystem.RemoveConstraint(c);
if (success) {
#if qcCheckPost
removeCheckedConstraint( c.pointer());
#endif
if (fAutoSolve)
Solve();
}
return success;
}
#endif

View File

@ -1,539 +0,0 @@
// $Id: QcLinEqSystem.cc,v 1.14 2001/01/31 07:37:13 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//----------------------------------------------------------------------------//
// Unlike identifiers, indexes start from 0 since they are used as array and //
// matrix subscripts in the tableau. //
//============================================================================//
#include <math.h>
#include "qoca/QcDefines.hh"
#include "qoca/QcLinEqSystem.hh"
#include "qoca/QcRowAdaptor.hh"
#include "qoca/QcTableauRowIterator.hh"
#include "qoca/QcTableauColIterator.hh"
#include "qoca/QcBasicVarIndexIterator.hh"
#include "qoca/QcVariableIndexIterator.hh"
#include "qoca/QcConstraintIndexIterator.hh"
#include "qoca/QcDenseTableauRowIterator.hh"
#if qcCheckInternalInvar
void QcLinEqSystem::assertDeepInvar() const
{
QcSolver::assertDeepInvar();
fVBiMap.vAssertDeepInvar();
fNotifier.vAssertDeepInvar();
fOCBiMap.vAssertDeepInvar();
fTableau.vAssertDeepInvar();
}
void QcLinEqSystem::vAssertDeepInvar() const
{
assertDeepInvar();
}
#endif
bool QcLinEqSystem::AddConstraint(QcConstraint &c)
{
return doAddConstraint(c, -1);
}
bool QcLinEqSystem::AddConstraint(QcConstraint &c, QcFloat &hint)
{
#if qcCheckPre
int hintIx = fVBiMap.safeIndex(hint);
qcAssertExternalPre(hintIx >= 0);
#else
int hintIx = fVBiMap.Index(hint);
#endif
return doAddConstraint(c, hintIx);
}
bool QcLinEqSystem::doAddConstraint(QcConstraint &c, int hintIx)
{
qcAssertExternalPre(c.getRelation() == QcConstraintRep::coEQ);
if (fBatchAddConst && fBatchAddConstFail)
return false;
QcRowAdaptor ra(c.LinPoly(), fVBiMap, fTableau);
bool success = true;
int co = fTableau.AddEq(ra, c.RHS()); // co is original constraint index
int cs = fTableau.Eliminate(co); // cs is solved form constraint index
if (hintIx >= 0) {
fTableau.fPivotHints.clear();
fTableau.fPivotHints.push_back(hintIx);
}
if (cs == QcTableau::fInvalidConstraintIndex) {
fInconsistant.push_back(c);
success = false;
} else if (!fTableau.IsRedundant(cs))
ApplyHints(cs);
if (success) {
fOCBiMap.Update(c, co);
fBatchConstraints.push_back(c);
} else if (fBatchAddConst)
fBatchAddConstFail = true;
fEditVarsSetup = false;
dbg(assertInvar());
return success;
}
bool QcLinEqSystem::ApplyHints(int cs)
{
bool pivoted = false;
if (cs < 0 || cs >= fTableau.GetRows() || fTableau.IsRedundant(cs))
throw QcWarning("ApplyHints called for invalid constraint",
cs, fTableau.GetRows() - 1);
else {
for (unsigned int i = 0; i < fTableau.fPivotHints.size() && !pivoted; i++)
pivoted = fTableau.Pivot(cs,fTableau.fPivotHints[i]);
// If PivotHints failed, this means all the pivot hints variables
// have zero coeffs. Now try all the rest of the parametric
// variables with non-zero coeffs in the solved form constraint.
if (!pivoted)
{
#ifdef qcUseSafeIterator
{
QcDenseTableauRowIterator varCoeffs(fTableau, cs);
// Note this iterator will not return zero coeffs, so
// there is no need to exclude the hints.
while (!varCoeffs.AtEnd()) {
if (!fTableau.IsBasic(varCoeffs.getIndex()))
pivoted = fTableau.Pivot(cs, varCoeffs.getIndex());
varCoeffs.Increment();
}
}
#else
// Cache tableau column coefficients since it is possible that
// the iterator may be invalidated (by Pivot) during iteration.
{
vector<QcSparseCoeff> coeffCache;
for(QcTableauRowIterator rowIt( fTableau, cs);
!rowIt.AtEnd();
rowIt.Increment())
coeffCache.push_back( QcSparseCoeff( rowIt.getValue(),
rowIt.getIndex()));
/* Note that the iterator above will not return zero
coeffs, so there is no need to exclude the hints. */
for (vector<QcSparseCoeff>::iterator cIt = coeffCache.begin();
(cIt != coeffCache.end()) && !pivoted;
cIt++)
{
unsigned cix = cIt->getIndex();
if (!fTableau.IsBasic( cix))
pivoted = fTableau.Pivot( cs, cix);
}
}
#endif
}
qcAssert(pivoted);
}
return true;
}
void QcLinEqSystem::BeginEdit()
{
qcAssert(fTableau.IsSolved());
// build a version of fEditVars by index.
vector<QcFloat>::iterator voiIt;
vector<unsigned int>::iterator viIt;
fVarsByIndex.resize(0);
for (voiIt = fEditVars.begin(); voiIt != fEditVars.end(); ++voiIt)
if (IsRegistered( *voiIt))
fVarsByIndex.push_back( fVBiMap.Index( *voiIt));
// try to make all variables of interest into parameters.
for (viIt = fVarsByIndex.begin();
viIt != fVarsByIndex.end();
++viIt)
{
int const vi = *viIt;
if (fTableau.IsBasic( vi)) {
int const ci = fTableau.IsBasicIn(vi);
#ifdef qcUseSafeIterator
for (QcDenseTableauRowIterator varCoeffs( fTableau, ci);
!varCoeffs.AtEnd();
varCoeffs.Increment())
{
unsigned const coeff_ix = varCoeffs.getIndex();
bool reject = false;
for (vector<unsigned int>::const_iterator viIt2 = fVarsByIndex.begin();
!reject && (viIt2 != fVarsByIndex.end());
viIt2++)
if (coeff_ix == *viIt2)
reject = true;
if (!reject)
{
qcAssert( fTableau.IsBasic( vi));
qcAssert( fTableau.GetBasicVar( ci) == vi);
qcAssert( !fTableau.IsBasic( coeff_ix));
qcAssert( fVBiMap.Identifier( coeff_ix)
!= *voiIt); // TODO: looks wrong; perhaps meant `coeff_ix != *viIt'?
dbg(bool pivoted =)
fTableau.Pivot( ci, coeff_ix);
assert( pivoted);
break;
}
}
#else
// Cache tableau column coefficients since it is possible that
// the iterator may be invalidated during iteration.
{
vector<QcSparseCoeff> coeffCache;
for (QcTableauRowIterator varCoeffs( fTableau, ci);
!varCoeffs.AtEnd();
varCoeffs.Increment())
coeffCache.push_back( QcSparseCoeff( varCoeffs.getValue(),
varCoeffs.getIndex()));
for (vector<QcSparseCoeff>::iterator cIt = coeffCache.begin();
cIt != coeffCache.end();
cIt++)
{
QcSparseCoeff &coeff = (*cIt);
unsigned const coeff_ix = coeff.getIndex();
bool reject = false;
for (vector<unsigned int>::const_iterator viIt2 = fVarsByIndex.begin();
!reject && (viIt2 != fVarsByIndex.end());
viIt2++)
if (coeff_ix == *viIt2)
reject = true;
if (!reject)
{
qcAssert( fTableau.IsBasic( vi));
qcAssert( fTableau.GetBasicVar( ci) == vi);
qcAssert( !fTableau.IsBasic( coeff_ix));
qcAssert( fVBiMap.Identifier( coeff_ix) != *voiIt); // TODO: looks wrong; perhaps meant `coeff_ix != *viIt'?
dbg(bool pivoted =)
fTableau.Pivot(ci, coeff_ix);
assert( pivoted);
break;
}
}
}
#endif
qcAssert( !fTableau.IsBasic( vi));
}
}
Solve(); // Compute new solution here.
fParsOfInterest.resize(0); // setup fParsOfInterest
for (viIt = fVarsByIndex.begin(); viIt != fVarsByIndex.end(); ++viIt)
if (!fTableau.IsBasic(*viIt) && !IsParOfInterest(*viIt))
fParsOfInterest.push_back(*viIt);
fDepVars.resize(0); // setup fDepVars
// setup fDepVarCoeffs
// extend fDepVarCoeffs so 0..fTableau.GetColumns()-1 are legal indices.
fDepVarCoeffs.resize(fTableau.GetColumns());
fDepVarBaseVals.resize(fTableau.GetColumns());
for (unsigned int i = 0; i < fDepVarCoeffs.size(); i++)
fDepVarCoeffs[i].resize(0);
QcBasicVarIndexIterator bvIt(fTableau);
while (!bvIt.AtEnd())
{
unsigned bvi = bvIt.getIndex();
assert (fTableau.IsBasic (bvi));
unsigned ci = bvIt.getConstraintBasicIn();
fDepVarBaseVals[bvi] = fTableau.GetRHS (ci);;
QcTableauRowIterator varCoeffs (fTableau, ci);
while (!varCoeffs.AtEnd())
{
if (IsParOfInterest (varCoeffs.getIndex()))
{
/* TODO: Check this logic here. The previous formatting
gave the impression that the author intended something
else. */
if (!IsDepVar (bvi))
fDepVars.push_back (bvi);
fDepVarCoeffs[bvi].push_back (QcSparseCoeff (varCoeffs.getValue(),
varCoeffs.getIndex()));
}
else if (bvi != varCoeffs.getIndex())
{
numT val = fVBiMap.getIdentifierPtr( varCoeffs.getIndex())->Value();
fDepVarBaseVals[bvi] -= val * varCoeffs.getValue();
}
varCoeffs.Increment();
}
bvIt.Increment();
}
fEditVarsSetup = true;
}
void QcLinEqSystem::EndEdit()
{
for (vector<unsigned int>::const_iterator vIt = fDepVars.begin(); vIt != fDepVars.end(); ++vIt)
fVBiMap.getIdentifierPtr( *vIt)->RestDesVal();
for (vector<unsigned int>::const_iterator vIt = fParsOfInterest.begin(); vIt != fParsOfInterest.end(); ++vIt)
fVBiMap.getIdentifierPtr( *vIt)->RestDesVal();
QcSolver::EndEdit();
}
bool QcLinEqSystem::IsDepVar(int vi) const
{
if (vi < 0) /* TODO: We can probably assertPre (vi > 0). Similarly for other IsDepPar implementations. */
return false;
vector<unsigned int>::const_iterator loc = fDepVars.begin();
while (loc != fDepVars.end()) {
if (*loc == (unsigned) vi)
return true;
++loc;
}
return false;
}
bool QcLinEqSystem::IsParOfInterest(int vi) const
{
if (vi < 0) /* TODO: We can probably assertPre (vi > 0). Similarly for other IsParOfInterest implementations. */
return false;
vector<unsigned int>::const_iterator loc = fParsOfInterest.begin();
while (loc != fParsOfInterest.end()) {
if (*loc == (unsigned) vi)
return true;
++loc;
}
return false;
}
void QcLinEqSystem::LoadDesValCache()
{
for (QcVariableIndexIterator vIt( fTableau);
!vIt.AtEnd();
vIt.Increment())
{
unsigned const vi = vIt.getIndex();
fTableau.SetDesireValue( vi, fVBiMap.getIdentifierPtr( vi)->DesireValue());
}
}
bool QcLinEqSystem::Reset()
{
bool result = true;
/* Record the columns of the previous basic variables so to make them
basic after this Reset() method. */
bool *basic = new bool[fTableau.getNColumns()];
for (unsigned c = 0; c < fTableau.getNColumns(); c++)
basic[c] = fTableau.IsBasic(c);
fEditVarsSetup = false;
fTableau.Restore(); // Reset variable state information
// Establish solved form and quasi-inverse from original constraints.
for (unsigned c = 0; c < fTableau.getNColumns(); c++)
{
if (!basic[c])
continue;
int maxrow = -1;
{
numT max = QcUtility::qcMaxZeroVal;
QcTableauColIterator iC (fTableau, c);
while (!iC.AtEnd())
{
numT absVal = fabs (iC.getValue());
if (max < absVal)
{
max = absVal;
maxrow = iC.getIndex();
}
iC.Increment();
}
assert( (maxrow < 0) == (QcUtility::IsZero( max)));
}
// If there is at least one non-zero coefficient in the current
// column.
if (maxrow != -1)
fTableau.Pivot (maxrow, c);
}
delete [] basic; // no longer need.
// Make sure that all solved form constraints are assigned a basic variable.
for (unsigned r = 0; r < fTableau.getNRows(); r++)
{
if (fTableau.GetRowCondition (r) != QcLinEqRowState::fNormalised)
continue;
int maxcol = -1;
{
numT max = QcUtility::qcMaxZeroVal;
QcTableauRowIterator iR (fTableau, r);
while (!iR.AtEnd())
{
numT absVal = fabs (iR.getValue());
if (max < absVal)
{
max = absVal;
maxcol = iR.getIndex();
assert (maxcol >= 0);
}
iR.Increment();
}
}
// If there is at least one non-zero coefficient in the current
// column.
if (maxcol != -1)
fTableau.Pivot (r, maxcol);
else
{
// Verify that the Reset operation is successful. It fails
// if one of more of the solved form row is marked as
// "invalid".
if (QcUtility::IsZero (fTableau.GetRHS (r)))
fTableau.SetRowCondition (r, QcLinEqRowState::fRedundant);
else
{
fTableau.SetRowCondition (r, QcLinEqRowState::fInvalid);
result = false;
}
}
}
dbg(assertInvar());
return result;
}
void QcLinEqSystem::Resolve()
{
if (!fEditVarsSetup)
BeginEdit();
// adjust the dependent basic variables
vector<unsigned int>::const_iterator vIt;
vector<QcSparseCoeff>::iterator pIt;
for (vIt = fDepVars.begin(); vIt != fDepVars.end(); ++vIt)
{
QcFloatRep *dvr = fVBiMap.getIdentifierPtr( *vIt);
qcAssert(fTableau.IsBasic(*vIt));
vector<QcSparseCoeff> &Coeffs = fDepVarCoeffs[*vIt];
numT dvValue = fDepVarBaseVals[*vIt];
for (pIt = Coeffs.begin(); pIt != Coeffs.end(); ++pIt)
{
QcFloatRep const *pr = fVBiMap.getIdentifierPtr( (*pIt).getIndex());
dvValue -= (*pIt).getValue() * pr->DesireValue();
}
dvr->SetValue( QcUtility::Zeroise( dvValue));
}
// Adjust the parameters of interest
for (vIt = fParsOfInterest.begin(); vIt != fParsOfInterest.end(); ++vIt)
fVBiMap.getIdentifierPtr( *vIt)->SetToGoal();
}
void QcLinEqSystem::Restart()
{
QcSolver::Restart();
fTableau.Restart();
fNotifier.Restart();
fDepVars.resize(0);
fParsOfInterest.resize(0);
fDepVarCoeffs.resize(0);
}
void QcLinEqSystem::RestSolver()
{
for (QcVariableIndexIterator vIt( fTableau);
!vIt.AtEnd();
vIt.Increment())
fVBiMap.getIdentifierPtr( vIt.getIndex())->RestDesVal();
}
void QcLinEqSystem::Solve()
{
LoadDesValCache();
for (QcVariableIndexIterator vIt( fTableau);
!vIt.AtEnd();
vIt.Increment())
{
unsigned const vi = vIt.getIndex();
QcFloatRep *vr = fVBiMap.getIdentifierPtr( vi);
if (fTableau.IsBasic( vi))
{
numT value = fTableau.EvalBasicVar( vi);
vr->SetValue( QcUtility::Zeroise( value));
}
else
vr->SetToGoal();
}
}

View File

@ -1,254 +0,0 @@
// $Id: QcLinEqSystem.hh,v 1.10 2001/01/30 01:32:08 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcLinEqSystemH
#define __QcLinEqSystemH
#include <vector>
#include "qoca/QcSolver.hh"
#include "qoca/QcLinEqTableau.hh"
#include "qoca/QcConstraint.hh"
#include "qoca/QcBiMapNotifier.hh"
#include "qoca/QcSparseCoeff.hh"
#include <qoca/QcVariableBiMap.hh>
class QcLinEqSystem : public QcSolver
{
public:
typedef QcVariableBiMap::const_identifier_iterator const_var_iterator;
protected:
vector<unsigned int> fDepVars;
vector<unsigned int> fParsOfInterest;
vector<unsigned int> fVarsByIndex; // Indices of variables of interest.
vector<numT> fDepVarBaseVals; // Used for Resolve
vector<vector<QcSparseCoeff> > fDepVarCoeffs;
// fDepVarCoeffs is a partial map from dependant variable index
// to a vector (used as a list) of sparse coefficients.
QcVariableBiMap &fVBiMap;
QcBiMapNotifier fNotifier;
QcConstraintBiMap &fOCBiMap;
QcLinEqTableau &fTableau;
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
public:
QcLinEqSystem();
QcLinEqSystem(unsigned hintRows, unsigned hintCols);
QcLinEqSystem(QcLinEqTableau &tab);
virtual ~QcLinEqSystem();
#if qcCheckInternalInvar
void assertInvar() const { }
void assertDeepInvar() const;
virtual void vAssertDeepInvar() const;
#endif
//-----------------------------------------------------------------------//
// Data Structure query functions //
//-----------------------------------------------------------------------//
QcBiMapNotifier GetNotifier()
{ return fNotifier; }
QcConstraintBiMap &GetOCBiMap()
{ return fOCBiMap; }
QcVariableBiMap &GetVBiMap()
{ return fVBiMap; }
QcLinEqTableau &GetTableau()
{ return fTableau; }
//-----------------------------------------------------------------------//
// Variable management methods (see QcSolver.java for descriptions) //
//-----------------------------------------------------------------------//
virtual void AddVar(QcFloat &v);
// N.B. AddVar does nothing if the variable is already registered.
virtual void SuggestValue(QcFloat &v, numT desval);
// Sets the desired value of v to desval.
virtual void RestSolver();
//-----------------------------------------------------------------------//
// Enquiry functions for variables //
//-----------------------------------------------------------------------//
virtual bool IsRegistered(QcFloat const &v) const
{ return (fVBiMap.IdentifierPresent(v)); }
virtual bool IsBasic(QcFloat const &v) const
{ return fTableau.IsBasic(fVBiMap.Index(v)); }
//-----------------------------------------------------------------------//
// High Level Edit Variable Interface for use by solver clients. //
// The methods addEditVar and endEdit are more efficient than the ones //
// inherited from Solver since variable weights have no effect on //
// QcLinEqSystem::Resolve. //
//-----------------------------------------------------------------------//
virtual void BeginEdit();
// Implementation note.
// It does not appear to be necessary to call solve before
// BeginEdit, so don't depend on this in the first loop.
virtual void EndEdit();
// Specialised version of EndEdit since LinEqSystem does not adjust
// weights.
//-----------------------------------------------------------------------//
// Constraint management methods //
//-----------------------------------------------------------------------//
virtual bool AddConstraint(QcConstraint &c);
// Extracts the various components and calls Insert, as well as
// updating the bimapnotifier for the tableau if successful. The
// return value indicates success or failure. If AddConstraint fails
// the state of the tableau is unchanged.
virtual bool AddConstraint(QcConstraint &c, QcFloat &hint);
virtual bool ChangeConstraint(QcConstraint &c, numT rhs);
virtual bool Reset();
// While this routine is in progress the tableau is slowly rebuilt
// from row 0 forwards retaining the original constraint matrix fA.
// The implementation used here only relies on the rest of the tableau
// methods being able to cope with multiple undetermined constraints.
// Reset starts by calling Restore to establish a state equivalent
// to the original constraints having been all entered using AddEq
// and nothing else apart from the deleted entries being left alone.
//-----------------------------------------------------------------------//
// Constraint Solving methods //
//-----------------------------------------------------------------------//
virtual void Solve();
// Using the tableau's desired values cache, calculate the value
// for each variable depending upon whether it is basic or parametric.
virtual void Resolve();
protected:
//-----------------------------------------------------------------------//
// Read access to the Tableau and BimapNotifier are a low level aspect of//
// the public interface. //
//-----------------------------------------------------------------------//
virtual bool ApplyHints(int cs);
// ApplyHints calls Pivot according to the PivotHints and should
// only be called after a successful Eliminate call (i.e. the
// new constraint is consistent and independent). If all the
// PivotHints fail then ApplyHints trys pivoting at all the
// parametric variables with non-zero coeffs for cs.
virtual void LoadDesValCache(); // Used for Solve
virtual void NewVariable(QcFloat &v)
{ fVBiMap.Update(v, fTableau.NewVariable()); }
bool IsDepVar(int vi) const;
// Used by EditVars and Resolve optimised linkage.
bool IsParOfInterest(int vi) const;
public:
//-----------------------------------------------------------------------//
// Utility functions. //
//-----------------------------------------------------------------------//
virtual void Print(ostream &os) const;
virtual void Restart();
// Erase everything ready to start afresh.
QcFloat &GetVariable(const char *n) const
{ return fVBiMap.Identifier(n); }
void GetVariableSet(vector<QcFloat> &vars) const
{ fVBiMap.GetVariableSet(vars); }
const_var_iterator getVariables_begin() const
{ return fVBiMap.getIdentifiers_begin(); }
const_var_iterator getVariables_end() const
{ return fVBiMap.getIdentifiers_end(); }
QcConstraint &GetConstraint(const char *n) const
{ return fOCBiMap.Identifier(n); }
private:
bool doAddConstraint(QcConstraint &c, int hintIx);
};
inline QcLinEqSystem::QcLinEqSystem()
: QcSolver(),
fVBiMap( fNotifier.GetVMap()),
fOCBiMap( fNotifier.GetOCMap()),
fTableau( *new QcLinEqTableau( 0, 0, fNotifier))
{
}
inline QcLinEqSystem::QcLinEqSystem(unsigned hintRows, unsigned hintCols)
: QcSolver(), fVBiMap(fNotifier.GetVMap()),
fOCBiMap(fNotifier.GetOCMap()),
fTableau(*new QcLinEqTableau(hintRows, hintCols, fNotifier))
{
}
inline QcLinEqSystem::QcLinEqSystem(QcLinEqTableau &tab)
: QcSolver(), fVBiMap(fNotifier.GetVMap()),
fOCBiMap(fNotifier.GetOCMap()),
fTableau(tab)
{
}
inline QcLinEqSystem::~QcLinEqSystem()
{
delete &fTableau;
}
inline void QcLinEqSystem::AddVar(QcFloat &v)
{
if (!fVBiMap.IdentifierPresent(v)) {
NewVariable(v);
dbg(assertInvar());
}
}
inline bool QcLinEqSystem::ChangeConstraint(QcConstraint &c, numT rhs)
{
int ix = fOCBiMap.safeIndex(c);
if (ix < 0)
return false; // TODO: perhaps use qcAssertExternalPre.
fTableau.ChangeRHS(ix, rhs);
// TODO: if (!fBatchAddConst) { maybe return false; }
return true;
}
inline void QcLinEqSystem::Print(ostream &os) const
{
QcSolver::Print(os);
fNotifier.Print(os);
os << endl;
fTableau.Print(os);
}
inline void QcLinEqSystem::SuggestValue(QcFloat &v, numT desval)
{
if (!fVBiMap.IdentifierPresent(v))
throw QcWarning("SuggestValue: variable must be registered");
else
v.SuggestValue(desval);
}
#endif

View File

@ -1,489 +0,0 @@
// $Id: QcLinEqTableau.cc,v 1.12 2001/01/31 07:37:13 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include <math.h>
#include "qoca/QcDefines.hh"
#include "qoca/QcLinEqTableau.hh"
#include "qoca/QcTableauRowIterator.hh"
#include "qoca/QcTableauColIterator.hh"
#include "qoca/QcConstraintIndexIterator.hh"
#include "qoca/QcBasicVarIndexIterator.hh"
#include "qoca/QcDenseTableauRowIterator.hh"
#include "qoca/QcDenseTableauColIterator.hh"
#ifndef NDEBUG
void
QcLinEqTableau::assertDeepInvar() const
{
assertInvar();
QcTableau::assertDeepInvar();
fCoreTableau->vAssertDeepInvar();
}
void
QcLinEqTableau::vAssertDeepInvar() const
{
assertDeepInvar();
}
#endif
int
QcLinEqTableau::Eliminate(unsigned ci)
{
qcAssertPre( ci < getNRows());
qcAssertPre( !fCoreTableau->GetARowDeleted( ci));
int quasiRow = fCoreTableau->GetMRowIndex(ci);
// The corresponding row of fM
qcAssert(quasiRow >= 0 && quasiRow < GetRows() &&
!fCoreTableau->GetMRowDeleted(quasiRow));
#ifdef qcSafetyChecks
if (GetRowCondition(quasiRow) != QcLinEqRowState::fInvalid)
throw QcWarning(qcPlace, "Eliminate called for a valid constraint");
qcAssert(GetBasicVar(quasiRow) == QcTableau::fInvalidVariableIndex);
#endif
// Erase the list of pivot variable index hints.
fPivotHints.resize(0);
// Eliminate the basic variables from quasiRow.
#ifdef qcUseSafeIterator
QcDenseTableauRowIterator rowIt( *this, quasiRow);
numT maxCoeff( 0);
for(; !rowIt.AtEnd(); rowIt.Increment())
{
unsigned col = rowIt.getIndex();
if(IsBasic( col))
fCoreTableau->AddScaledRow( quasiRow, IsBasicIn( col),
-rowIt.getValue());
else
{
// Arrange to put the biggest hint coeff first.
numT absVal = fabs( rowIt.getValue());
if(absVal > maxCoeff)
{
maxCoeff = absVal;
fPivotHints.push_front( col);
}
else
fPivotHints.push_back( col);
}
}
#else
// N.B. Eliminate cannot use QcLeqTabRowIterator as the tableau
// quasi matrix fM is altered (and this is essential to Eliminate).
QcTableauRowIterator rowIt(*this, quasiRow);
{
vector<QcSparseCoeff> coeffCache;
while (!rowIt.AtEnd())
{
coeffCache.push_back( QcSparseCoeff( rowIt.getValue(),
rowIt.getIndex()));
rowIt.Increment();
}
numT maxCoeff( 0);
for(vector<QcSparseCoeff>::iterator cIt = coeffCache.begin();
cIt != coeffCache.end();
cIt++)
{
QcSparseCoeff &coeff = (*cIt);
unsigned col = coeff.getIndex();
if(IsBasic( col))
{
fCoreTableau->AddScaledRow( quasiRow, IsBasicIn( col),
-coeff.getValue());
}
else
{
/* Arrange to put the biggest (in magnitude) hint coeff first.
A full sort shouldn't be necessary, as usually only the
first element is consulted. */
numT absVal = fabs( coeff.getValue());
if(absVal > maxCoeff)
{
maxCoeff = absVal;
fPivotHints.push_front( col);
}
else
fPivotHints.push_back( col);
}
}
}
#endif
// Check for linear independance
rowIt.SetToBeginOf(quasiRow);
if (rowIt.AtEnd()) { // all coeffs are zero
if (QcUtility::IsZero(fCoreTableau->GetRHS(quasiRow))) {
SetRowCondition(quasiRow, QcLinEqRowState::fRedundant);
SetMRowIndex(ci, QcTableau::fInvalidConstraintIndex);
SetARowIndex(quasiRow, QcTableau::fInvalidConstraintIndex);
} else {
#ifdef qcSafetyChecks
throw QcWarning(qcPlace, "Inconsistant Constraint");
#endif
qcAssert(GetRowCondition(quasiRow) == QcLinEqRowState::fInvalid);
DeleteRow(ci);
return QcTableau::fInvalidConstraintIndex;
}
} else
SetRowCondition(quasiRow, QcLinEqRowState::fNormalised);
return quasiRow; // Note alternative return qcInvalidCIndex above.
}
numT QcLinEqTableau::EvalBasicVar(unsigned vi) const
{
qcAssertPre( IsBasic( vi));
int ci = IsBasicIn( vi);
assert( ci != QcTableau::fInvalidConstraintIndex);
numT value = GetRHS( ci);
for (QcTableauRowIterator varCoeffs( *this, ci);
!varCoeffs.AtEnd();
varCoeffs.Increment())
{
unsigned coeff_vi = varCoeffs.getIndex();
if (coeff_vi != vi)
value -= varCoeffs.getValue() * GetDesireValue( coeff_vi);
}
return value;
}
#if 0 /* unused */
//numT QcLinEqTableau::GetSparsenessExBasic() const
//{
// unsigned nZeros = 0;
// unsigned total = 0;
//
// for (unsigned i = 0; i < getNRows(); i++)
// if (GetRowCondition( i) == QcLinEqRowState::fRegular)
// for (unsigned j = 0; j < getNColumns(); j++)
// if (!IsBasic( j))
// {
// total++;
// if (QcUtility::IsZero(GetValue( i, j)))
// nZeros++;
// }
//
// if (total == 0)
// return 0;
//#if NUMT_IS_DOUBLE
// return (total - nZeros) / (numT) total;
//#else
// return numT( total - nZeros, total);
//#endif
//}
//
//numT QcLinEqTableau::GetSparsenessInBasic() const
//{
// unsigned nZeros = 0;
// unsigned total = 0;
//
// for (unsigned i = 0; i < getNRows(); i++)
// if (GetRowCondition( i) == QcLinEqRowState::fRegular)
// for (unsigned j = 0; j < getNColumns(); j++)
// {
// total++;
// if (QcUtility::IsZero( GetValue( i, j)))
// nZeros++;
// }
//
// if (total == 0)
// return 0;
//#if NUMT_IS_DOUBLE
// return (total - nZeros) / (numT) total;
//#else
// return numT( total - nZeros, total);
//#endif
//}
#endif /* unused */
numT QcLinEqTableau::GetValue(unsigned ci, unsigned vi) const
{
qcAssertPre (ci < getNRows());
qcAssertPre (vi < getNColumns());
// Short cut evaluations
switch (GetRowCondition(ci)) {
case QcLinEqRowState::fRedundant:
return 0.0;
case QcLinEqRowState::fNormalised:
if (IsBasic(vi))
return 0.0;
break;
case QcLinEqRowState::fRegular:
if (IsBasic(vi)) {
if ((int) vi == GetBasicVar(ci))
return numT( 1);
else
return numT( 0);
}
break;
case QcLinEqRowState::fInvalid: break;
default:
throw QcWarning(qcPlace, "Invalid LinEqRowCondition");
}
return fCoreTableau->GetValue(ci, vi);
}
bool QcLinEqTableau::IsSolved() const
{
for (QcConstraintIndexIterator cIt( *this);
!cIt.AtEnd();
cIt.Increment())
if (IsUndetermined( cIt.getIndex()))
return false;
return true;
}
bool QcLinEqTableau::Pivot(unsigned ci, unsigned vi)
{
qcAssertPre( ci < getNRows());
qcAssertPre( !IsRedundant( ci));
qcAssertPre( GetRowCondition(ci) != QcLinEqRowState::fInvalid);
numT p = GetValue(ci, vi); // GetValue returns the raw coefficient
if (QcUtility::IsZero(p)) // so this test is required.
return false;
#ifdef qcSafetyChecks
if (IsBasic( vi)
&& !((GetRowCondition( ci) == QcLinEqRowState::fRegular)
&& (GetBasicVar( ci) == (int) vi)))
{
throw QcWarning(qcPlace,
"Pivot attempted for variable already basic in another constraint");
return false;
}
#endif
// If ci is regular then remove it from the basis.
if (GetRowCondition(ci) == QcLinEqRowState::fRegular)
Unsolve(ci);
// Note that fARowIndex[ci] can be left as qcInvalidCIndex,
// hence check below.
// From this point, until the pivot is completed,
// the conditions MRowIndex(fARowIndex(ci))==ci and
// ARowIndex(MRowIndex(ci2))==ci2 may not hold. Since it is
// Pivot that causes a row to become regular, and these conditions
// do not hold for regular rows, this is a consequence of the
// change of state. We could introduce another row state for this
// phase, but that seems a bit over the top. Just check that all
// tableau methods that Pivot calls from here on do not assume the
// conditions. I.E. don't call: DecreaseRows, Eliminate, RemoveEq,
// Restore, or AddRow. And of course if IsSolved is
// called with checks enabled it may report an assert violation.
// From this point the pivot must succeed.
// So can now wipe fARowIndex and fMRowIndex
if (GetARowIndex(ci) != QcTableau::fInvalidConstraintIndex) {
SetMRowIndex(GetARowIndex(ci), QcTableau::fInvalidConstraintIndex);
SetARowIndex(ci, QcTableau::fInvalidConstraintIndex);
}
#ifdef qcSafetyChecks
qcAssert(GetARowIndex(ci) == QcTableau::fInvalidConstraintIndex);
qcAssert(GetRowCondition(ci) == QcLinEqRowState::fNormalised);
qcAssert(GetBasicVar(ci) == QcTableau::fInvalidVariableIndex);
qcAssert(IsBasicIn(vi) == QcTableau::fInvalidConstraintIndex);
#endif
// Scale the pivot row so pivot coeff is 1.0
fCoreTableau->ScaleRow(ci, recip( p));
// FractionRow may be used here rather than ScaleRow(ci,recip(p))
// so that we don't introduce rounding errors at the cost of
// efficiency (FractionRow uses division so is less efficient).
#ifdef qcUseSafeIterator
// Eliminate the new basic variable from all the other rows.
QcDenseTableauColIterator varCoeffs(*this, vi);
while (!varCoeffs.AtEnd())
{
// Only process regular rows. Redundant and deleted rows would
// not be affected in any case. Undetermined rows are not
// in solved form so should not be included. By checking here
// we can allow rows to be added without requiring an
// immediate pivot and also enable a full resolve by
// setting all the rows to normalised and fM to identity.
if ((GetRowCondition( varCoeffs.getIndex()) == QcLinEqRowState::fRegular)
|| ((GetRowCondition( varCoeffs.getIndex()) == QcLinEqRowState::fNormalised)
&& (varCoeffs.getIndex() != ci)))
{
// Excludes (varCoeffs.Index() == ci)
// since (GetRowCondition(ci) != regular).
fCoreTableau->AddScaledRow( varCoeffs.getIndex(), ci, -varCoeffs.getValue());
}
varCoeffs.Increment();
}
#else
// Eliminate the new basic variable from all the other rows.
{
vector<QcSparseCoeff> coeffCache;
for(QcTableauColIterator varCoeffs( *this, vi);
!varCoeffs.AtEnd();
varCoeffs.Increment())
{
unsigned row = varCoeffs.getIndex();
/* Process only regular rows. Redundant and deleted rows would
not be affected in any case. Undetermined rows are not in
solved form so should not be included. By checking here we can
allow rows to be added without requiring an immediate pivot and
also enable a full resolve by setting all the rows to
normalised and fM to identity. */
// Excludes (varCoeffs.Index() == ci)
// since (GetRowCondition(ci) != regular).
if ((GetRowCondition( row) == QcLinEqRowState::fRegular)
|| ((GetRowCondition( row) == QcLinEqRowState::fNormalised)
&& (row != ci)))
coeffCache.push_back( QcSparseCoeff( varCoeffs.getValue(), row));
}
for(vector<QcSparseCoeff>::iterator cIt = coeffCache.begin();
cIt != coeffCache.end();
cIt++)
fCoreTableau->AddScaledRow( cIt->getIndex(), ci, -cIt->getValue());
}
#endif
SetBasic(vi, true);
SetBasicIn(vi, ci);
SetBasicVar(ci, vi);
SetRowCondition(ci, QcLinEqRowState::fRegular);
return true;
}
void QcLinEqTableau::Print(ostream &os) const
{
unsigned rows = getNRows();
unsigned cols = getNColumns();
fCoreTableau->Print(os);
os << endl;
os << (IsSolved() ? "Solved " : "Unsolved ") << endl;
os << "Tableau with " << rows << " rows and " << cols << " columns." << endl;
os << "==================================================" << endl;
os << "Basic vars are: " << endl;
QcBasicVarIndexIterator it(*this);
while (!it.AtEnd()) {
os << it.getIndex() << ", ";
it.Increment();
}
os << endl << "Solved Form:" << endl;
for (unsigned i = 0; i < rows; i++) {
os << i << ":";
switch (GetRowCondition(i)) {
case QcLinEqRowState::fInvalid:
if (fCoreTableau->GetMRowDeleted(i))
os << "deleted\t";
else
os << "invalid\t";
break;
case QcLinEqRowState::fNormalised:
os << "normalised\t";
break;
case QcLinEqRowState::fRegular:
os << "regular\t";
break;
case QcLinEqRowState::fRedundant:
os << "redundant\t";
break;
default:
throw QcWarning("RowCondition is invalid");
}
os << "Basic(" << GetBasicVar(i) << ")\t";
for (unsigned j = 0; j < cols; j++)
os << GetValue(i, j) << "\t";
os << endl;
}
os << endl;
for (unsigned i = 0; i < rows; i++)
os << "[" << i << "] " << GetRHS(i) << endl;
}
void QcLinEqTableau::Restore()
{
// Reset state information.
for (int c = 0; c < GetColumns(); c++) {
SetBasic(c, false);
SetBasicIn(c, QcTableau::fInvalidConstraintIndex);
}
for (int r = 0; r < GetRows(); r++) {
// Row condition is set to normalised so that a full pivot can be
// performed on Reset().
SetBasicVar(r, QcTableau::fInvalidVariableIndex);
SetRowCondition(r, GetMRowDeleted(r) ?
QcLinEqRowState::fInvalid : QcLinEqRowState::fNormalised);
}
fCoreTableau->Restore(); // Do this last as it calls Row/Col FixLinkage
dbg(assertInvar());
}
void QcLinEqTableau::Unsolve(unsigned ci)
// Remove constraint from the basis given solved form constraint index
{
qcAssertPre( ci < getNRows());
qcAssert(GetRowCondition(ci) == QcLinEqRowState::fRegular);
int b = GetBasicVar(ci);
qcAssert(b != QcTableau::fInvalidVariableIndex);
SetBasic(b, false);
SetBasicIn(b, QcTableau::fInvalidConstraintIndex);
SetBasicVar(ci, QcTableau::fInvalidVariableIndex);
SetRowCondition(ci, QcLinEqRowState::fNormalised);
}

View File

@ -1,356 +0,0 @@
// $Id: QcLinEqTableau.hh,v 1.18 2001/01/30 01:32:08 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#ifndef __QcLinEqTableauH
#define __QcLinEqTableauH
#include <deque>
#include <vector>
#include "qoca/QcTableau.hh"
#include "qoca/QcSparseCoeff.hh"
#include "qoca/QcDelCoreTableau.hh"
#include "qoca/QcLinEqRowColStateVector.hh"
class QcLinEqTableau : public QcTableau
{
protected:
QcLinEqRowColStateVector *fRowColState;
QcLinEqRowStateVector *fRowState;
QcLinEqColStateVector *fColState;
QcCoreTableau *fCoreTableau;
public:
deque<unsigned int> fPivotHints;
// During an eliminate operation, fPivotHints is erased and then
// the indices of parametric variables that do not have zero
// solved form coeffs are recorded. These are likely to be good
// candidates for the pivot operation. Note that it is still
// necessary to check that the coeff is non-zero, since
// parametric coeffs may be modified by eliminate after the coeff
// is recorded, this check is intended to be done using pivot.
//-----------------------------------------------------------------------//
// Constructors. //
//-----------------------------------------------------------------------//
QcLinEqTableau(unsigned hintRows, unsigned hintCols, QcBiMapNotifier &n);
QcLinEqTableau(QcCoreTableau &tab, QcBiMapNotifier &n);
virtual ~QcLinEqTableau();
#ifndef NDEBUG
void assertInvar() const { }
void assertDeepInvar() const;
virtual void vAssertDeepInvar() const;
#endif
//-----------------------------------------------------------------------//
// Data Structure access functions. //
//-----------------------------------------------------------------------//
QcCoreTableau &GetCoreTableau() const
{ return *fCoreTableau; }
QcLinEqRowColStateVector &GetRowColState() const
{ return *fRowColState; }
QcLinEqRowStateVector &GetRowState() const
{ return *fRowState; }
QcLinEqColStateVector &GetColState() const
{ return *fColState; }
//-----------------------------------------------------------------------//
// Query functions. //
//-----------------------------------------------------------------------//
/** Get RHS for solved-form constraint <tt>ci</tt>.
<p><tt>ci</tt> is allowed to be a deleted constraint, in which case zero
is returned.
**/
virtual numT GetRHS(unsigned ci) const
{ return fCoreTableau->GetRHS(ci); }
/** Get coefficient for variable <tt>vi</tt> in solved-form constraint <tt>ci</tt>.
<p><tt>ci</tt> is allowed to be a deleted constraint, in which case zero
is returned.
@precondition <tt>ci &lt; getNRows()</tt>
@precondition <tt>vi &lt; getNColumns()</tt>
**/
virtual numT GetValue(unsigned ci, unsigned vi) const;
/** Find the value of the basic variable with index <tt>vi</tt>, using
the desired value cache and tableau coeffs.
@precondition <tt>IsBasic(vi)</tt>
**/
virtual numT EvalBasicVar(unsigned vi) const;
int GetColumns() const
{ return fCoreTableau->GetColumns(); }
unsigned getNColumns() const
{ return fCoreTableau->GetColumns(); }
bool GetARowDeleted(unsigned ci) const
{ return fCoreTableau->GetARowDeleted(ci); }
int GetARowIndex(unsigned ci) const
{ return fCoreTableau->GetARowIndex(ci); }
bool GetMRowDeleted(unsigned ci) const
{ return fCoreTableau->GetMRowDeleted(ci); }
int GetMRowIndex(unsigned ci) const
{ return fCoreTableau->GetMRowIndex(ci); }
int GetBasicVar(unsigned ci) const
{ return fRowState->GetBasicVar(ci); }
numT GetDesireValue(unsigned vi) const
{ return fColState->GetDesireValue(vi); }
int GetRowCondition(unsigned ci) const
{ return fRowState->GetCondition(ci); }
int GetRows() const
{ return fCoreTableau->GetRows(); }
unsigned getNRows() const
{ return fCoreTableau->GetRows(); }
#if 0 /* unused */
numT GetSparsenessInBasic() const;
numT GetSparsenessExBasic() const;
#endif
int IsBasicIn(unsigned vi) const
{ return fColState->IsBasicIn(vi); }
bool IsBasic(unsigned vi) const
{ return fColState->IsBasic(vi); }
bool IsRedundant(unsigned ci) const
{ return (GetRowCondition(ci) == QcLinEqRowState::fRedundant); }
/** Indicates whether the tableau is in solved form.
Returns true iff every constraint is determined (i.e. !IsUndetermined).
**/
bool IsSolved() const;
bool IsUndetermined(unsigned ci) const;
bool IsValidCIndex(int ci) const
{ return fCoreTableau->IsValidCIndex(ci); }
bool IsValidOCIndex(int ci) const
{ return fCoreTableau->IsValidOCIndex(ci); }
bool IsValidVIndex(int vi)
{ return fCoreTableau->IsValidVIndex(vi); }
//-----------------------------------------------------------------------//
// Manipulation functions. //
//-----------------------------------------------------------------------//
/** Create a new invalid constraint, and add any new variables
indicated.
@return The new original constraint index.
@postcondition ret &ge; 0
@postcondition ret &lt; getNRows()
**/
virtual int AddEq(QcRowAdaptor &varCoeffs, numT rhs)
{
int ret = fCoreTableau->AddRow( varCoeffs, rhs);
qcAssertPost( (unsigned) ret < getNRows());
return ret;
}
virtual void ChangeRHS(unsigned ci, numT rhs)
// Change the RHS of the constraint ci.
{ fCoreTableau->ChangeRHS(ci, rhs); }
virtual void DeleteRow(int co);
// Delete an undetermined constraint given its original row index
virtual int Eliminate(unsigned ci); // Call after addEq
// see QcTableau.hh for doc.
/** Create a new non-basic variable. */
virtual unsigned IncreaseColumns();
/** Create a new constraint. */
virtual unsigned IncreaseRows()
{ return fCoreTableau->IncreaseRows(); }
virtual unsigned NewVariable()
// Create a new non basic variable and return its index. This
// new variable will have zero coefficient in all existing constraints.
// There is no necessity to explicitely call this function. It just
// may is convenient to determine in advance the variable index for
// a new variable rather than let AddEq to assign one.
{ return IncreaseColumns(); }
virtual bool Pivot(unsigned ci, unsigned vi);
// The parameters indicate a solved form coeff. Pivot can only be
// applied to a normalised or regular constraint. Get the pivot
// element and check it is non-zero, this catches redundant and
// deleted constaints as well (Pivot should not be called for these).
// To save checking that the pivot element is non-zero before calling
// Pivot, and Pivot has to look at this in any case, it is expected
// that Pivot be used to do this check.
virtual void Restart()
// Erase everything ready to start afresh. This also restarts
// fRowColState.
{ fCoreTableau->Restart(); }
virtual void Restore();
// By setting all the undeleted constraints to normalised, the tableau
// data structures can remain in a consistent state through this Reset.
// It is tempting to set fRows to -1 and bring it back up to its
// original value while solving each constraint in turn. But this is
// an invitation to disaster since other routines are entitled to
// assume fRows is an upper bound for constraint indices and the
// deleted rows information in fMRowIndex and fIsDeleted would need to
// violate this. Hence the safe implementation used here only relies
// on the rest of the tableau methods being able to cope with multiple
// normalised constraints. Restore establishes a state equivalent to
// the original constraints having been all entered using AddRow and
// nothing else apart from the deleted entries being left alone.
/** Normalize the corresponding row in fM if the rhs is negative. This
makes rhs positive.
@precondition <tt>ci &lt; getNRows()</tt>
**/
void Normalize (unsigned ci)
{
qcAssertPre (ci < getNRows());
fCoreTableau->Normalize (ci);
}
void SetARowDeleted(int ci, bool d)
{ fCoreTableau->SetARowDeleted(ci, d); }
void SetARowIndex(int ci, int i)
{ fCoreTableau->SetARowIndex(ci, i); }
void SetDesireValue(int vi, numT dv) // must be setup by client
{ fColState->SetDesireValue(vi, dv); }
void SetMRowDeleted(int ci, bool d)
{ fCoreTableau->SetMRowDeleted(ci, d); }
void SetMRowIndex(int ci, int i)
{ fCoreTableau->SetMRowIndex(ci, i); }
void SetBasicVar(int ci, int i)
{ fRowState->SetBasicVar(ci, i); }
void SetRowCondition(int ci, int s)
{ fRowState->SetCondition(ci, s); }
void SetBasicIn(int vi, int i)
{ fColState->SetBasicIn(vi, i); }
void SetBasic(int vi, bool b)
{ fColState->SetBasic(vi, b); }
void Unsolve(unsigned ci);
// Given a solved form constraint index, for a regular constraint,
// Unsolve removes it from the basis so that it looks like a newly
// entered row after Eliminate but before a Pivot. However the
// bookeeping information associating this solved form constraint with
// an original constraint is not done by Unsolve.
//-----------------------------------------------------------------------//
// Utility function. //
//-----------------------------------------------------------------------//
virtual void Print(ostream &os) const;
protected:
//-----------------------------------------------------------------------//
// Constructors. //
//-----------------------------------------------------------------------//
QcLinEqTableau(QcBiMapNotifier &n);
};
inline QcLinEqTableau::QcLinEqTableau(unsigned hintRows, unsigned hintCols,
QcBiMapNotifier &n)
: QcTableau(n),
fRowColState(new QcLinEqRowColStateVector()),
fRowState(&fRowColState->GetRowState()),
fColState(&fRowColState->GetColState()),
fCoreTableau(new QcCoreTableau(hintRows, hintCols, *fRowColState))
{
}
inline QcLinEqTableau::QcLinEqTableau(QcCoreTableau &tab, QcBiMapNotifier &n)
: QcTableau(n),
fRowColState((QcLinEqRowColStateVector *)&tab.GetRowColState()),
fRowState(&fRowColState->GetRowState()),
fColState(&fRowColState->GetColState()),
fCoreTableau(&tab)
{
}
inline QcLinEqTableau::QcLinEqTableau(QcBiMapNotifier &n)
: QcTableau(n)
{
}
inline QcLinEqTableau::~QcLinEqTableau()
{
delete fRowColState;
delete fCoreTableau;
}
inline void QcLinEqTableau::DeleteRow(int co)
{
SetRowCondition(fCoreTableau->GetMRowIndex(co), QcLinEqRowState::fInvalid);
fCoreTableau->DeleteRow(co);
}
inline unsigned QcLinEqTableau::IncreaseColumns()
{
unsigned i = fCoreTableau->IncreaseColumns();
return i;
}
inline bool QcLinEqTableau::IsUndetermined(unsigned ci) const
{
int status = GetRowCondition( ci);
return ((status == QcLinEqRowState::fInvalid)
|| (status == QcLinEqRowState::fNormalised));
}
#endif /* !__QcLinEqTableauH */

View File

@ -1,153 +0,0 @@
// $Id: QcLinInEqColState.hh,v 1.8 2000/12/13 05:59:49 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//----------------------------------------------------------------------------//
// The class QcBiMap provides a bi-directional mapping from //
// identifier class to index class. //
//============================================================================//
#ifndef __QcLinInEqColStateH
#define __QcLinInEqColStateH
#include "qoca/QcQuasiColState.hh"
class QcLinInEqColState : public QcLinEqColState
{
friend class QcLinInEqColStateVector;
friend class QcLinInEqRowColStateVector;
public:
enum {
fStructural = 0x01,
fSlack = 0x02,
fDual = 0x04,
fArtificial = 0x08,
fDesire = 0x10,
fError = 0x20
};
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcLinInEqColState(int vi);
private:
#ifndef NDEBUG
bool isValidColCondition(int c) const
{
switch( c)
{
case fDual:
case fArtificial:
case fDesire:
case fStructural:
case (fStructural | fSlack):
case (fStructural | fSlack | fError):
return true;
}
return false;
}
#endif
//-----------------------------------------------------------------------
// Query functions
//-----------------------------------------------------------------------
public:
int getCondition() const
{
qcAssertPost( isValidColCondition( fCondition));
return fCondition;
}
void setCondition(int c)
{
qcAssertPre( isValidColCondition( c));
fCondition = c;
}
QcLinInEqColState const *getNextStructuralCol() const
{
return fNextStruct;
}
//-----------------------------------------------------------------------//
// Utility functions. //
//-----------------------------------------------------------------------//
virtual void Print(ostream &os);
public:
/** A constrained variable may only take non-negative values and hence if it
is basic, its coefficient cannot be allowed to have a different sign from
the rhs value if the tableau is in solved form. A solved form tableau row
with a constrained basic variable is called restricted.
**/
bool fIsConstrained;
private:
int fCondition;
// Currently only slack and dual variables are constrained.
public:
numT fObj; // Objective function coeff (for Solver's use)
private:
QcLinInEqColState *fNextStruct; // Circular doubly linked list of
QcLinInEqColState *fPrevStruct; // slack variables.
};
inline QcLinInEqColState::QcLinInEqColState(int vi)
: QcLinEqColState(vi)
{
fIsConstrained = false;
fCondition = fStructural;
fObj = 0.0;
fNextStruct = 0;
fPrevStruct = 0;
}
inline void QcLinInEqColState::Print(ostream &os)
{
QcLinEqColState::Print(os);
os << ",IsConst(" << fIsConstrained << "),"
<< "Cond(" << fCondition << "),";
if (fCondition & fStructural)
os << "[structural]";
if (fCondition & fSlack)
os << "[slack]";
if (fCondition & fDual)
os << "[dual]";
if (fCondition & fArtificial)
os << "[artificial]";
if (fCondition & fDesire)
os << "[desire]";
os << "),Obj(" << fObj << "),"
<< "PrevStruct(" << fPrevStruct << "),"
<< "NextStruct(" << fNextStruct << ")";
}
#endif

View File

@ -1,165 +0,0 @@
// Generated automatically from QcLinInEqColStateVector.ch by /home/pmoulder/usr/local/bin/ch2xx.
#ifndef QcLinInEqColStateVectorDCL
#define QcLinInEqColStateVectorDCL
#line 1 "QcLinInEqColStateVector.ch"
// $Id: QcLinInEqColStateVector.ch,v 1.5 2000/12/13 01:44:58 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include <qoca/QcLinEqColStateVector.H>
#include <qoca/QcLinInEqColState.hh>
class QcLinInEqColStateVector
: public QcLinEqColStateVector
{
public:
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcLinInEqColStateVector()
: QcLinEqColStateVector(), fStructVarList(0)
{
}
//-----------------------------------------------------------------------//
// Query functions. //
//-----------------------------------------------------------------------//
int GetCondition(unsigned i) const
{
qcAssertPre (i < fSize);
return ((QcLinInEqColState *)fStates[i])->getCondition();
}
numT GetObjValue(unsigned i) const
{
qcAssertPre (i < fSize);
return ((QcLinInEqColState *)fStates[i])->fObj;
}
bool IsArtificial(unsigned vi) const
{
qcAssertPre (vi < fSize);
return GetCondition(vi) & QcLinInEqColState::fArtificial;
}
bool IsConstrained(unsigned i) const
{
qcAssertPre (i < fSize);
return ((QcLinInEqColState *)fStates[i])->fIsConstrained;
}
bool IsDual(unsigned vi) const
{ return GetCondition(vi) & QcLinInEqColState::fDual; }
bool IsDesire(unsigned vi) const
{ return GetCondition(vi) & QcLinInEqColState::fDesire; }
bool IsError(unsigned vi) const
{ return GetCondition(vi) & QcLinInEqColState::fError; }
bool IsSlack(unsigned vi) const
{ return GetCondition(vi) & QcLinInEqColState::fSlack; }
bool IsStructural(unsigned vi) const
{ return GetCondition(vi) & QcLinInEqColState::fStructural; }
//-----------------------------------------------------------------------//
// Setter functions
//-----------------------------------------------------------------------//
void
SetCondition(unsigned i, int c);
#line 110 "QcLinInEqColStateVector.ch"
inline void
SetObjValue(unsigned i, numT v);
#line 117 "QcLinInEqColStateVector.ch"
inline void
SetConstrained(unsigned i, bool c);
#line 125 "QcLinInEqColStateVector.ch"
#ifndef NDEBUG
void
assertLinkageInvar() const;
#line 159 "QcLinInEqColStateVector.ch"
virtual void
virtualAssertLinkageInvar() const;
#line 165 "QcLinInEqColStateVector.ch"
#endif
virtual void
FixLinkage();
#line 191 "QcLinInEqColStateVector.ch"
private:
inline void
LinkStruct(QcLinInEqColState *state);
#line 211 "QcLinInEqColStateVector.ch"
inline void
UnlinkStruct(QcLinInEqColState *me);
#line 229 "QcLinInEqColStateVector.ch"
inline void
UnlinkStruct(unsigned i);
#line 239 "QcLinInEqColStateVector.ch"
protected:
virtual void
Alloc(QcState **start, QcState **finish);
#line 257 "QcLinInEqColStateVector.ch"
virtual void
AddToList(QcState **start, QcState **finish);
#line 282 "QcLinInEqColStateVector.ch"
virtual void
RemoveFromList(QcState **start, QcState **finish);
#line 304 "QcLinInEqColStateVector.ch"
private:
inline QcLinInEqColState *
getState(unsigned i) const;
#line 316 "QcLinInEqColStateVector.ch"
public:
/** head of linked list of structural variables. */
QcLinInEqColState *fStructVarList;
};
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/
#endif /* !QcLinInEqColStateVectorDCL */

View File

@ -1,203 +0,0 @@
// Generated automatically from QcLinInEqColStateVector.ch by /home/pmoulder/usr/local/bin/ch2xx.
#include "QcLinInEqColStateVector.hh"
#line 1 "QcLinInEqColStateVector.ch"
// $Id: QcLinInEqColStateVector.ch,v 1.5 2000/12/13 01:44:58 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include <qoca/QcLinInEqColState.hh>
#line 89 "QcLinInEqColStateVector.ch"
//-----------------------------------------------------------------------//
// Setter functions
//-----------------------------------------------------------------------//
void
QcLinInEqColStateVector::SetCondition(unsigned i, int c)
{
qcAssertPre( i < fSize);
QcLinInEqColState *state = getState( i);
if ((c ^ state->getCondition())
& QcLinInEqColState::fStructural)
{
if (c & QcLinInEqColState::fStructural)
LinkStruct( state);
else
UnlinkStruct( state);
}
state->setCondition( c);
}
#line 125 "QcLinInEqColStateVector.ch"
#ifndef NDEBUG
void
QcLinInEqColStateVector::assertLinkageInvar() const
{
unsigned nStructural = 0;
for (QcState **i = fStates + fSize; i-- != fStates;)
{
QcLinInEqColState const *state = CAST(QcLinInEqColState const *, *i);
if (state->getCondition() & QcLinInEqColState::fStructural)
nStructural++;
else
{
assert( state->fPrevStruct == 0);
assert( state->fNextStruct == 0);
}
}
assert( (fStructVarList == 0)
|| (fStructVarList->fPrevStruct == 0));
for (QcLinInEqColState *curr = fStructVarList;
curr != 0;
curr = curr->fNextStruct)
{
assert( curr->getCondition() & QcLinInEqColState::fStructural);
assert( (curr->fNextStruct == 0)
|| (curr->fNextStruct->fPrevStruct == curr));
assert( nStructural != 0);
nStructural--;
}
assert( nStructural == 0);
}
void
QcLinInEqColStateVector::virtualAssertLinkageInvar() const
{
assertLinkageInvar();
QcLinEqColStateVector::virtualAssertLinkageInvar();
}
#endif
void
QcLinInEqColStateVector::FixLinkage()
{
dbg(assertLinkageInvar());
#if 0 /* shouldn't be necessary any more. */
fStructVarList = 0;
for (unsigned i = 0; i < fSize; i++)
{
QcLinInEqColState *state = (QcLinInEqColState *)fStates[i];
state->fNextStruct = 0;
state->fPrevStruct = 0;
if (state->getCondition() & QcLinInEqColState::fStructural)
LinkStruct( state);
}
#endif
QcLinEqColStateVector::FixLinkage();
}
#line 242 "QcLinInEqColStateVector.ch"
void
QcLinInEqColStateVector::Alloc(QcState **start, QcState **finish)
{
qcAssertPre( fStates <= start);
qcAssertPre( start <= finish);
qcAssertPre( finish <= fStates + fCapacity);
for (unsigned i = start - fStates;
start != finish;
start++, i++)
*start = new QcLinInEqColState( i);
}
void
QcLinInEqColStateVector::AddToList(QcState **start, QcState **finish)
{
qcAssertPre( fStates <= start);
qcAssertPre( start < finish);
qcAssertPre( finish <= getAllocEnd());
QcLinEqColStateVector::AddToList( start, finish);
for(; start != finish; start++)
{
QcLinInEqColState *state = CAST(QcLinInEqColState *, *start);
assert( (state->fNextStruct == 0)
&& (state->fPrevStruct == 0)
&& (state->getCondition() == QcLinInEqColState::fStructural)
&& (!state->fIsConstrained)
&& (state->fObj == 0.0));
LinkStruct( state);
}
}
void
QcLinInEqColStateVector::RemoveFromList(QcState **start, QcState **finish)
{
qcAssertPre( fStates <= start);
qcAssertPre( start <= finish);
qcAssertPre( finish <= fStates + fSize);
for (QcState **i = start; i != finish; i++)
{
QcLinInEqColState *state = CAST(QcLinInEqColState *, *i);
if (state->getCondition() & QcLinInEqColState::fStructural)
UnlinkStruct( i - fStates);
state->setCondition( QcLinInEqColState::fStructural);
state->fIsConstrained = false;
state->fObj = 0.0;
}
QcLinEqColStateVector::RemoveFromList( start, finish);
}
#line 323 "QcLinInEqColStateVector.ch"
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/

View File

@ -1,330 +0,0 @@
// $Id: QcLinInEqColStateVector.ch,v 1.5 2000/12/13 01:44:58 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
//o[d] #include <qoca/QcLinEqColStateVector.H>
//o[i] #include <qoca/QcLinEqColStateVector.hh>
#include <qoca/QcLinInEqColState.hh>
//o[d] class QcLinInEqColStateVector
//o[d] : public QcLinEqColStateVector
//o[d] {
//o[d] public:
//begin o[d]
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcLinInEqColStateVector()
: QcLinEqColStateVector(), fStructVarList(0)
{
}
//-----------------------------------------------------------------------//
// Query functions. //
//-----------------------------------------------------------------------//
int GetCondition(unsigned i) const
{
qcAssertPre (i < fSize);
return ((QcLinInEqColState *)fStates[i])->getCondition();
}
numT GetObjValue(unsigned i) const
{
qcAssertPre (i < fSize);
return ((QcLinInEqColState *)fStates[i])->fObj;
}
bool IsArtificial(unsigned vi) const
{
qcAssertPre (vi < fSize);
return GetCondition(vi) & QcLinInEqColState::fArtificial;
}
bool IsConstrained(unsigned i) const
{
qcAssertPre (i < fSize);
return ((QcLinInEqColState *)fStates[i])->fIsConstrained;
}
bool IsDual(unsigned vi) const
{ return GetCondition(vi) & QcLinInEqColState::fDual; }
bool IsDesire(unsigned vi) const
{ return GetCondition(vi) & QcLinInEqColState::fDesire; }
bool IsError(unsigned vi) const
{ return GetCondition(vi) & QcLinInEqColState::fError; }
bool IsSlack(unsigned vi) const
{ return GetCondition(vi) & QcLinInEqColState::fSlack; }
bool IsStructural(unsigned vi) const
{ return GetCondition(vi) & QcLinInEqColState::fStructural; }
//end o[d]
//-----------------------------------------------------------------------//
// Setter functions
//-----------------------------------------------------------------------//
//cf
void
SetCondition(unsigned i, int c)
{
qcAssertPre( i < fSize);
QcLinInEqColState *state = getState( i);
if ((c ^ state->getCondition())
& QcLinInEqColState::fStructural)
{
if (c & QcLinInEqColState::fStructural)
LinkStruct( state);
else
UnlinkStruct( state);
}
state->setCondition( c);
}
inline void
SetObjValue(unsigned i, numT v)
{
qcAssertPre (i < fSize);
((QcLinInEqColState *)fStates[i])->fObj = v;
}
inline void
SetConstrained(unsigned i, bool c)
{
qcAssertPre (i < fSize);
((QcLinInEqColState *)fStates[i])->fIsConstrained = c;
}
#ifndef NDEBUG
//cf
void
assertLinkageInvar() const
{
unsigned nStructural = 0;
for (QcState **i = fStates + fSize; i-- != fStates;)
{
QcLinInEqColState const *state = CAST(QcLinInEqColState const *, *i);
if (state->getCondition() & QcLinInEqColState::fStructural)
nStructural++;
else
{
assert( state->fPrevStruct == 0);
assert( state->fNextStruct == 0);
}
}
assert( (fStructVarList == 0)
|| (fStructVarList->fPrevStruct == 0));
for (QcLinInEqColState *curr = fStructVarList;
curr != 0;
curr = curr->fNextStruct)
{
assert( curr->getCondition() & QcLinInEqColState::fStructural);
assert( (curr->fNextStruct == 0)
|| (curr->fNextStruct->fPrevStruct == curr));
assert( nStructural != 0);
nStructural--;
}
assert( nStructural == 0);
}
//cf
virtual void
virtualAssertLinkageInvar() const
{
assertLinkageInvar();
QcLinEqColStateVector::virtualAssertLinkageInvar();
}
#endif
//cf
virtual void
FixLinkage()
{
dbg(assertLinkageInvar());
#if 0 /* shouldn't be necessary any more. */
fStructVarList = 0;
for (unsigned i = 0; i < fSize; i++)
{
QcLinInEqColState *state = (QcLinInEqColState *)fStates[i];
state->fNextStruct = 0;
state->fPrevStruct = 0;
if (state->getCondition() & QcLinInEqColState::fStructural)
LinkStruct( state);
}
#endif
QcLinEqColStateVector::FixLinkage();
}
//o[d] private:
inline void
LinkStruct(QcLinInEqColState *state)
// Only accesses the current item and those linked to StructVarList.
// Other items may have invalid NextStruct and PrevStruct pointers.
{
qcAssertPre( state->fPrevStruct == 0);
qcAssertPre( state->fNextStruct == 0);
qcAssertPre( state != fStructVarList);
if (fStructVarList != 0)
{
state->fNextStruct = fStructVarList;
fStructVarList->fPrevStruct = state;
}
fStructVarList = state;
}
inline void
UnlinkStruct(QcLinInEqColState *me)
{
qcAssertPre( (me->fPrevStruct == 0)
== (fStructVarList == me));
if (me->fPrevStruct == 0)
fStructVarList = me->fNextStruct;
else
me->fPrevStruct->fNextStruct = me->fNextStruct;
if (me->fNextStruct != 0)
me->fNextStruct->fPrevStruct = me->fPrevStruct;
me->fPrevStruct = 0;
me->fNextStruct = 0;
}
inline void
UnlinkStruct(unsigned i)
{
qcAssertPre (i < fSize);
QcLinInEqColState *me = (QcLinInEqColState *)fStates[i];
UnlinkStruct( me);
}
//o[d] protected:
//cf
virtual void
Alloc(QcState **start, QcState **finish)
{
qcAssertPre( fStates <= start);
qcAssertPre( start <= finish);
qcAssertPre( finish <= fStates + fCapacity);
for (unsigned i = start - fStates;
start != finish;
start++, i++)
*start = new QcLinInEqColState( i);
}
//cf
virtual void
AddToList(QcState **start, QcState **finish)
{
qcAssertPre( fStates <= start);
qcAssertPre( start < finish);
qcAssertPre( finish <= getAllocEnd());
QcLinEqColStateVector::AddToList( start, finish);
for(; start != finish; start++)
{
QcLinInEqColState *state = CAST(QcLinInEqColState *, *start);
assert( (state->fNextStruct == 0)
&& (state->fPrevStruct == 0)
&& (state->getCondition() == QcLinInEqColState::fStructural)
&& (!state->fIsConstrained)
&& (state->fObj == 0.0));
LinkStruct( state);
}
}
//cf
virtual void
RemoveFromList(QcState **start, QcState **finish)
{
qcAssertPre( fStates <= start);
qcAssertPre( start <= finish);
qcAssertPre( finish <= fStates + fSize);
for (QcState **i = start; i != finish; i++)
{
QcLinInEqColState *state = CAST(QcLinInEqColState *, *i);
if (state->getCondition() & QcLinInEqColState::fStructural)
UnlinkStruct( i - fStates);
state->setCondition( QcLinInEqColState::fStructural);
state->fIsConstrained = false;
state->fObj = 0.0;
}
QcLinEqColStateVector::RemoveFromList( start, finish);
}
private:
inline QcLinInEqColState *
getState(unsigned i) const
{
qcAssertPre( i < fSize);
QcLinInEqColState *ret = CAST(QcLinInEqColState *, fStates[i]);
qcAssertPost( ret != 0);
return ret;
}
//begin o[d]
public:
/** head of linked list of structural variables. */
QcLinInEqColState *fStructVarList;
//end o[d]
//o[d] };
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/

View File

@ -1,143 +0,0 @@
// Generated automatically from QcLinInEqColStateVector.ch by /home/pmoulder/usr/local/bin/ch2xx.
#include "QcLinInEqColStateVector.H"
#ifndef QcLinInEqColStateVectorIFN
#define QcLinInEqColStateVectorIFN
#line 1 "QcLinInEqColStateVector.ch"
// $Id: QcLinInEqColStateVector.ch,v 1.5 2000/12/13 01:44:58 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include <qoca/QcLinEqColStateVector.hh>
#include <qoca/QcLinInEqColState.hh>
#line 89 "QcLinInEqColStateVector.ch"
//-----------------------------------------------------------------------//
// Setter functions
//-----------------------------------------------------------------------//
#line 110 "QcLinInEqColStateVector.ch"
inline void
QcLinInEqColStateVector::SetObjValue(unsigned i, numT v)
{
qcAssertPre (i < fSize);
((QcLinInEqColState *)fStates[i])->fObj = v;
}
inline void
QcLinInEqColStateVector::SetConstrained(unsigned i, bool c)
{
qcAssertPre (i < fSize);
((QcLinInEqColState *)fStates[i])->fIsConstrained = c;
}
#ifndef NDEBUG
#line 165 "QcLinInEqColStateVector.ch"
#endif
#line 193 "QcLinInEqColStateVector.ch"
inline void
QcLinInEqColStateVector::LinkStruct(QcLinInEqColState *state)
// Only accesses the current item and those linked to StructVarList.
// Other items may have invalid NextStruct and PrevStruct pointers.
{
qcAssertPre( state->fPrevStruct == 0);
qcAssertPre( state->fNextStruct == 0);
qcAssertPre( state != fStructVarList);
if (fStructVarList != 0)
{
state->fNextStruct = fStructVarList;
fStructVarList->fPrevStruct = state;
}
fStructVarList = state;
}
inline void
QcLinInEqColStateVector::UnlinkStruct(QcLinInEqColState *me)
{
qcAssertPre( (me->fPrevStruct == 0)
== (fStructVarList == me));
if (me->fPrevStruct == 0)
fStructVarList = me->fNextStruct;
else
me->fPrevStruct->fNextStruct = me->fNextStruct;
if (me->fNextStruct != 0)
me->fNextStruct->fPrevStruct = me->fPrevStruct;
me->fPrevStruct = 0;
me->fNextStruct = 0;
}
inline void
QcLinInEqColStateVector::UnlinkStruct(unsigned i)
{
qcAssertPre (i < fSize);
QcLinInEqColState *me = (QcLinInEqColState *)fStates[i];
UnlinkStruct( me);
}
#line 305 "QcLinInEqColStateVector.ch"
inline QcLinInEqColState *
QcLinInEqColStateVector::getState(unsigned i) const
{
qcAssertPre( i < fSize);
QcLinInEqColState *ret = CAST(QcLinInEqColState *, fStates[i]);
qcAssertPost( ret != 0);
return ret;
}
#line 323 "QcLinInEqColStateVector.ch"
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/
#endif /* !QcLinInEqColStateVectorIFN */

View File

@ -1,71 +0,0 @@
// Generated automatically from QcLinInEqRowColStateVector.ch by /home/pmoulder/usr/local/bin/ch2xx.
#ifndef QcLinInEqRowColStateVectorDCL
#define QcLinInEqRowColStateVectorDCL
#line 1 "QcLinInEqRowColStateVector.ch"
// $Id: QcLinInEqRowColStateVector.ch,v 1.1 2000/11/29 04:31:16 pmoulder Exp $
//============================================================================//
// Written by Alan Finlay and Sitt Sen Chok //
//----------------------------------------------------------------------------//
// The QOCA implementation is free software, but it is Copyright (C) //
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
// General Public License. See the file COPYING for copying permission. //
// //
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
// Library General Public License. See the file COPYING.LIB for copying //
// permissions for those files. //
// //
// If those licencing arrangements are not satisfactory, please contact us! //
// We are willing to offer alternative arrangements, if the need should arise.//
// //
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
// //
// Permission is hereby granted to use or copy this program for any purpose, //
// provided the above notices are retained on all copies. Permission to //
// modify the code and to distribute modified code is granted, provided the //
// above notices are retained, and a notice that the code was modified is //
// included with the above copyright notice. //
//============================================================================//
#include "qoca/QcLinEqRowColStateVector.hh"
#include "qoca/QcLinInEqColStateVector.H"
class QcLinInEqRowColStateVector
: public QcLinEqRowColStateVector
{
public:
//-----------------------------------------------------------------------//
// Constructor. //
//-----------------------------------------------------------------------//
QcLinInEqRowColStateVector()
: QcLinEqRowColStateVector(new QcLinInEqColStateVector()),
fColState((QcLinInEqColStateVector *)QcLinEqRowColStateVector::fColState)
{
}
//-----------------------------------------------------------------------//
// Manipulation functions. //
//-----------------------------------------------------------------------//
virtual void
SwapColumns(unsigned v1, unsigned v2);
#line 142 "QcLinInEqRowColStateVector.ch"
public:
QcLinInEqColStateVector *fColState;
};
/*
Local Variables:
mode:c++
c-file-style:"gnu"
fill-column:80
End:
vim: set filetype=c++ :
*/
#endif /* !QcLinInEqRowColStateVectorDCL */

Some files were not shown because too many files have changed in this diff Show More