Skip to content

Commit e0c7879

Browse files
pwofpwof
authored andcommitted
Dealing with issue 40
1 parent 9fa14b6 commit e0c7879

8 files changed

Lines changed: 2041 additions & 2003 deletions

File tree

Ghmiter.cpp

Lines changed: 502 additions & 501 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ifeq ($(PLATFORM),Linux)
1717
SWIGDIR = /usr/local/bin
1818
JAVADIR = /home/argus/jdk1.7.0_25
1919
else
20-
GNUDIR = C:/mingw/bin
20+
GNUDIR = C:/MinGW/bin
2121
SWIGDIR = C:/swigwin-3.0.10
2222
JAVADIR = C:/Progra~2/Java/jdk1.7.0_80
2323
endif
@@ -33,8 +33,8 @@ JAVAPACKAGE = tauargus.extern.dataengine
3333

3434
BUILDDIR = build
3535
DISTDIR = dist
36-
debug=yes
37-
ifdef debug
36+
37+
ifdef debug # NB: does not set CONF correctly from within Netbeans IDE
3838
CONF = Debug
3939
else
4040
CONF = Release
@@ -68,9 +68,9 @@ ifeq ($(PLATFORM),Linux)
6868
CFLAGS += -fPIC
6969
endif
7070
ifdef debug
71-
CFLAGS += -D_DEBUG -g
71+
CFLAGS += -D_DEBUG -g
7272
else
73-
CFLAGS += -DNDEBUG -O2
73+
CFLAGS += -DNDEBUG -O2 -fno-strict-aliasing
7474
endif
7575
LDFLAGS = -shared
7676
ifeq ($(PLATFORM),Linux)
@@ -108,15 +108,16 @@ clean :
108108
rm -rf $(OBJDIR) $(LIBDIR)
109109
rm -f $(SRCDIR)/*_wrap.*
110110

111+
$(BUILDDIR) $(BUILDDIR)/$(CONF) $(OBJDIR) $(DISTDIR) $(DISTDIR)/$(CONF) $(LIBDIR) :
112+
mkdir -p $@
113+
111114
$(TARGET) : $(OBJECTS)
112115
$(LINK) $(LDFLAGS) -o $@ $^
116+
cp -p $(TARGET) $(SRCDIR)/../tauargus/TauArgusJava.dll
113117
# cp -p $(TARGET) /opt/lib
114118
# ln -sf /opt/lib/$(LIBFILENAME) /opt/lib/$(SONAME)
115119
# ln -sf /opt/lib/$(SONAME) /opt/lib/$(LIBBASENAME)
116120

117-
$(BUILDDIR) $(BUILDDIR)/$(CONF) $(OBJDIR) $(DISTDIR) $(DISTDIR)/$(CONF) $(LIBDIR) :
118-
mkdir -p $@
119-
120121
# pull in dependency info for *existing* .o files
121122
-include $(wildcard $(addsuffix .d, ${OBJECTS}))
122123

TauArgus.cpp

Lines changed: 66 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,42 +1639,46 @@ long TauArgus::SetHierarchicalCodelist(long VarIndex, const char* FileName, cons
16391639
}
16401640

16411641
// Gets a code if given an index and a variable number
1642-
bool TauArgus::GetVarCode(long VarIndex, long CodeIndex, long *CodeType, const char** CodeString,
1642+
//bool TauArgus::GetVarCode(long VarIndex, long CodeIndex, long *CodeType, const char **CodeString,
1643+
// long *IsMissing, long *Level)
1644+
bool TauArgus::GetVarCode(long VarIndex, long CodeIndex, long *CodeType, std::string *CodeString,
16431645
long *IsMissing, long *Level)
16441646
{
1645-
int v = VarIndex, nCodes;
1647+
int v = VarIndex, nCodes;
16461648

1647-
if (v < 0 || v >= m_nvar) {
1648-
return false;
1649-
}
1649+
if (v < 0 || v >= m_nvar) {
1650+
return false;
1651+
}
16501652

1651-
nCodes = m_var[v].GetnCode();
1652-
if (CodeIndex < 0 || CodeIndex >= nCodes) {
1653-
return false;
1654-
}
1653+
nCodes = m_var[v].GetnCode();
1654+
if (CodeIndex < 0 || CodeIndex >= nCodes) {
1655+
return false;
1656+
}
16551657

16561658
/*if (m_Using MicroData) {
16571659
if (m_fname[0] == 0) return false;
16581660
}*/
1659-
if (!m_CompletedCodeList) {
1660-
return false;
1661-
}
1661+
if (!m_CompletedCodeList) {
1662+
return false;
1663+
}
16621664

1663-
if (m_var[v].IsHierarchical) {
1664-
if (m_var[v].GethCode()[CodeIndex].IsParent) *CodeType = CTY_TOTAL;
1665-
else *CodeType = CTY_BASIC;
1666-
*Level = m_var[v].GethCode()[CodeIndex].Level;
1667-
} else {
1668-
if (m_var[v].IsCodeBasic(CodeIndex) ) *CodeType = CTY_BASIC;
1669-
else *CodeType = CTY_TOTAL;
1670-
*Level = (CodeIndex == 0 ? 0 : 1);
1671-
}
1665+
if (m_var[v].IsHierarchical) {
1666+
if (m_var[v].GethCode()[CodeIndex].IsParent) *CodeType = CTY_TOTAL;
1667+
else *CodeType = CTY_BASIC;
1668+
*Level = m_var[v].GethCode()[CodeIndex].Level;
1669+
}
1670+
else {
1671+
if (m_var[v].IsCodeBasic(CodeIndex) ) *CodeType = CTY_BASIC;
1672+
else *CodeType = CTY_TOTAL;
1673+
*Level = (CodeIndex == 0 ? 0 : 1);
1674+
}
16721675

1673-
// Gets a pointer to an internal buffer. It is still safe because the referenced object keeps living
1674-
*CodeString = m_var[v].GetCode(CodeIndex).c_str();
1675-
*IsMissing = (CodeIndex >= m_var[v].GetnCode() - m_var[v].GetnMissing());
1676+
// Gets a pointer to an internal buffer. It is still safe because the referenced object keeps living
1677+
//*CodeString = m_var[v].GetCode(CodeIndex).c_str();
1678+
*CodeString = m_var[v].GetCode(CodeIndex);
1679+
*IsMissing = (CodeIndex >= m_var[v].GetnCode() - m_var[v].GetnMissing());
16761680

1677-
return true;
1681+
return true;
16781682
}
16791683

16801684
long TauArgus::GetVarHierarchyDepth(long VarIndex, bool Recoded)
@@ -1688,8 +1692,10 @@ long TauArgus::GetVarHierarchyDepth(long VarIndex, bool Recoded)
16881692
}
16891693

16901694
// return the codes for unsafe variables
1695+
//bool TauArgus::UnsafeVariableCodes(long VarIndex, long CodeIndex, long *IsMissing, long *Freq,
1696+
// const char **Code, long *Count, long *UCArray)
16911697
bool TauArgus::UnsafeVariableCodes(long VarIndex, long CodeIndex, long *IsMissing, long *Freq,
1692-
const char **Code, long *Count, long *UCArray)
1698+
std::string *Code, long *Count, long *UCArray)
16931699
{
16941700
int t;
16951701

@@ -1747,7 +1753,8 @@ bool TauArgus::UnsafeVariableCodes(long VarIndex, long CodeIndex, long *IsMissin
17471753
}
17481754
}
17491755

1750-
*Code = m_var[VarIndex].GetCode(CodeIndex).c_str();
1756+
//*Code = m_var[VarIndex].GetCode(CodeIndex).c_str();
1757+
*Code = m_var[VarIndex].GetCode(CodeIndex);
17511758
*IsMissing = (CodeIndex >= nCodes - m_var[VarIndex].GetnMissing() );
17521759

17531760
// TRACE("Var %d Code [%s] Freq = %d, unsafe %d %d %d\n", VarIndex + 1, (LPCTSTR) m_var[VarIndex].GetCode(CodeIndex), *Freq, UCArray[0], UCArray[1], UCArray[2]);
@@ -1756,10 +1763,9 @@ bool TauArgus::UnsafeVariableCodes(long VarIndex, long CodeIndex, long *IsMissin
17561763
}
17571764

17581765
// return properties given a Variable and Code Index
1759-
bool TauArgus::GetVarCodeProperties(long VarIndex, long CodeIndex,
1760-
long *IsParent, long *IsActive,
1761-
long *IsMissing, long *Level,
1762-
long *nChildren, const char** Code)
1766+
bool TauArgus::GetVarCodeProperties(long VarIndex, long CodeIndex, long *IsParent,
1767+
long *IsActive, long *IsMissing, long *Level,
1768+
long *nChildren, const char** Code)
17631769
{
17641770
int v = VarIndex, c = CodeIndex;
17651771

@@ -3368,7 +3374,7 @@ void TauArgus::FillTables(char *str)
33683374
CDataCell dc;
33693375
string tempPeepCode;
33703376
vector<char *> VarCodes;
3371-
bool readingFreeFormatResult;
3377+
bool readingFreeFormatResult=false; // Just to initialize PWOF 20170127
33723378

33733379
if (!InFileIsFixedFormat) {
33743380
readingFreeFormatResult = ReadVariablesFreeFormat(str, VarCodes);
@@ -4546,7 +4552,7 @@ void TauArgus::WriteFirstLine(FILE *fd, LPCTSTR FirstLine)
45464552
void TauArgus::WriteSBSStaart(FILE *fd, CTable *tab, long *Dim, char ValueSep, long SBSCode)
45474553
{
45484554
CDataCell *dc = tab->GetCell(Dim);
4549-
double X, X1, X2, XS;
4555+
double X=0, X1=0, X2=0, XS=0; // Just to initialize PWOF 20170127
45504556
//bool DomRule = tab->DominanceRule;
45514557
bool PQRule = tab->PQRule;
45524558
int f1 = dc->GetFreq();
@@ -4901,9 +4907,10 @@ void TauArgus::AdjustTable(CTable *tab)
49014907
long DimNr[MAXDIM];
49024908
AdjustNonBasalCells(tab,d,DimNr,0);
49034909
}
4904-
for (int i = 0; i < tab->nCell; i++) {
4905-
CDataCell *dctemp = tab->GetCell(i);
4906-
}
4910+
//Why is this needed? Does nothing???
4911+
//for (int i = 0; i < tab->nCell; i++) {
4912+
// CDataCell *dctemp = tab->GetCell(i);
4913+
//}
49074914
}
49084915

49094916
// Is good table is false if the table is not additive
@@ -5010,10 +5017,10 @@ void TauArgus::AdjustNonBasalCells(CTable *tab, long TargetDim, long *DimNr, lon
50105017
{
50115018
vector<unsigned int> Children;
50125019
CDataCell *dc;
5013-
CDataCell *dctemp, *dcramya;
5020+
CDataCell *dctemp;//, *dcramya;
50145021
CDataCell *addcell;
50155022
long tempDimNr;
5016-
double sum,test;
5023+
double sum;//,test;
50175024

50185025

50195026
if (niv == tab->nDim) {
@@ -5071,7 +5078,7 @@ void TauArgus::AdjustNonBasalCells(CTable *tab, long TargetDim, long *DimNr, lon
50715078
sum = 0;
50725079
tempDimNr = tab->GetCellNrFromIndices(DimNr);
50735080
dctemp = tab->GetCell(DimNr);
5074-
test = dctemp->GetResp();
5081+
//test = dctemp->GetResp(); // Is not used ??? PWOF 20170127
50755082
//fprintf(fd, "0.0 %d : %d (-1) ", nCode, GetCellNrFromIndices(tab->nDim, DimNr, tdp) );
50765083
addcell = new CDataCell(tab->NumberofMaxScoreCell, tab->NumberofMaxScoreCell,
50775084
tab->ApplyHolding, tab->ApplyWeight);
@@ -5100,7 +5107,8 @@ void TauArgus::AdjustNonBasalCells(CTable *tab, long TargetDim, long *DimNr, lon
51005107

51015108
delete addcell;
51025109
}
5103-
dcramya = tab->GetCell(tempDimNr);
5110+
// Does not do anything ??? PWOF 20170127
5111+
//dcramya = tab->GetCell(tempDimNr);
51045112
}
51055113

51065114
}
@@ -5136,7 +5144,7 @@ bool TauArgus::ReadVariablesFreeFormat(char *Str, vector<char *> &VarCodes)
51365144
char *startpos = Str;
51375145
char *endpos;
51385146
for (int varIndex = 0; varIndex <= m_maxBPos; varIndex++) {
5139-
CVariable *var = &(m_var[varIndex]);
5147+
//CVariable *var = &(m_var[varIndex]); // Not used ???? PWOF 20170127
51405148
endpos = strchr(startpos, separator);
51415149
if (endpos == NULL) {
51425150
if (varIndex != m_maxBPos)
@@ -5179,12 +5187,12 @@ bool TauArgus::TestSubCodeList()
51795187
return false;
51805188
}
51815189
// just to see sub codes are filled
5182-
for (long l = 0; l<var->NumSubCodes; l++) {
5183-
for (long k = 0; k < var->m_SubCodes[l].NumberOfSubCodes(); k++) {
5184-
long test = var->m_SubCodes[l].
5185-
GetSubCodeIndex(k);
5190+
/* Does not do anything. Will crash if sub codes are not filled? PWOF 20170127
5191+
for (long l = 0; l<var->NumSubCodes; l++) {
5192+
for (long k = 0; k < var->m_SubCodes[l].NumberOfSubCodes(); k++) {
5193+
long test = var->m_SubCodes[l].GetSubCodeIndex(k);
51865194
}
5187-
}
5195+
}*/
51885196
}
51895197
}
51905198
return true;
@@ -5229,10 +5237,10 @@ bool TauArgus::SubTableTupleForSubTable(long TableIndex, long SubTableIndex,
52295237
long TauArgus::WriteCellInTempFile(long UnsafeCellNum, long TableIndex, long CellNum, FILE *fdtemp, double MaxScale) //long *CellDimension)
52305238
{
52315239
long i,j,k,l;
5232-
long SubTableIndex = -1;
5240+
// long SubTableIndex = -1; // Not used PWOF 20170127
52335241
long nCellSubTable;
52345242
CTable *tab = &(m_tab[TableIndex]);
5235-
bool found = false;
5243+
// bool found = false; // Not used PWOF 20170127
52365244
long SubTableCellNum;
52375245
long teller = UnsafeCellNum;
52385246
CVariable *var;
@@ -5509,7 +5517,7 @@ bool TauArgus::WriteAllSubTablesInAMPL(FILE *fd, long tabind)
55095517
for (i =0; i<NumSubTables; i++) {
55105518
SubTableTupleForSubTable(tabind,i,SubTableTuple);
55115519
long NumSubTableCells = FindNumberOfElementsInSubTable(SubTableTuple,tabind);
5512-
marginal = 0; long sum = 0;
5520+
marginal = 0; //long sum = 0; Not used PWOF 20170127
55135521
for (j= 0; j<NumSubTableCells; j++) {
55145522
// just print cell
55155523
FindCellIndexForSubTable(TableCellIndex,tabind,SubTableTuple,j, SubTableCellIndex);
@@ -5681,7 +5689,7 @@ bool TauArgus::WriteHierTableInAMPL(FILE *fd, long tabind, const string &TempDir
56815689
long *DimNr = new long [tab->nDim];
56825690
long *RowColIndex = new long [tab->nDim];
56835691
long i;
5684-
long nDec = 8;
5692+
//long nDec = 8;
56855693
fprintf(fd,"%s\n", "# AMPL generated By TauArgus");
56865694
fprintf(fd,"%s\n", "#");
56875695
// The number of sub tables
@@ -5694,8 +5702,9 @@ bool TauArgus::WriteHierTableInAMPL(FILE *fd, long tabind, const string &TempDir
56945702
fprintf (fd,"%s\n", "param M := ");
56955703
CVariable *var0 = &(m_var[tab->ExplVarnr[0]]);
56965704
CVariable *var1 = &(m_var[tab->ExplVarnr[1]]);
5697-
for (i = 0; i < var0->NumSubCodes; i++) {
5698-
fprintf(fd,"%ld %ld\n", i, var0->m_SubCodes[i].NumberOfSubCodes());
5705+
//for (i = 0; i < var0->NumSubCodes; i++) {
5706+
for (unsigned long j = 0; j < var0->NumSubCodes; j++) {
5707+
fprintf(fd,"%ld %ld\n", j, var0->m_SubCodes[j].NumberOfSubCodes());
56995708
}
57005709
fprintf(fd,"%s\n", ";");
57015710

@@ -5733,7 +5742,8 @@ bool TauArgus::WriteHierTableInAMPL(FILE *fd, long tabind, const string &TempDir
57335742
fseek( fdtempr, 0L, SEEK_SET );
57345743
for (i=0; i<nUnsafe; i++) {
57355744
char str[MAXRECORDLENGTH];
5736-
int res = ReadMicroRecord(fdtempr, str);
5745+
//int res = ReadMicroRecord(fdtempr, str);
5746+
ReadMicroRecord(fdtempr, str);
57375747
fprintf(fd,"%s\n",str);
57385748
}
57395749
fprintf(fd,"%s\n", ";");
@@ -5788,12 +5798,12 @@ bool TauArgus::testampl(long ind)
57885798
return false;
57895799
}
57905800
// just to see sub codes are filled
5801+
/* Does not really do anything PWOF 20170127
57915802
for (long l = 0; l < var->NumSubCodes; l++) {
57925803
for (long k = 0; k < var->m_SubCodes[l].NumberOfSubCodes(); k++) {
5793-
long test = var->m_SubCodes[l].
5794-
GetSubCodeIndex(k);
5804+
long test = var->m_SubCodes[l].GetSubCodeIndex(k);
57955805
}
5796-
}
5806+
}*/
57975807
}
57985808

57995809
FILE *fd = fopen ("E:/Temp/Hierampl.txt", "w");

0 commit comments

Comments
 (0)