Skip to content

Commit

Permalink
UPPERMARG and LOWERMARG can be set by user
Browse files Browse the repository at this point in the history
  • Loading branch information
ppdewolf committed Aug 28, 2024
1 parent 9cb1c63 commit fa0e1c5
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 140 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CP = cp -p
32BIT = true
#32BIT = false

SWIGDIR = D:/Peter-Paul/Documents/Thuiswerk/Programmatuur/swigwin-4.0.1
SWIGDIR = D:/Peter-Paul/Documents/Thuiswerk/Programmatuur/swigwin-4.0.2

ifeq ($(32BIT), false) # 64 bit assumed
BITS = -m64 -D_LP64
Expand Down
69 changes: 1 addition & 68 deletions src/Hitas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,95 +43,28 @@ CHitas::~CHitas()
{
}

/*
[Frequency rule]
MINCOUNT=3 ; Cell should contain at least (MINCOUNT + 1) contributants // SafeMinRec minus 1 in avdw's geval
[Dominance rule] // !!! is vervallen !!!!
DOMCOUNT=1 ; Largest DOMCOUNT should contribute less than
DOMPRO=0.7 ; DOMPRO times cellvalue
[Safety ranges]
LOWERMARG=0.99 ; lowerbound in case of marginal cell // zo laten
UPPERMARG=1.01 ; same for upperbound // zo laten
[Costs]
DISTANCE=0 ; 0 if cost specified in BTab.dat, 1 if distance is to be used // 0 geen afstandsfunctie, 1 Anco
D1=1 3 5 9 17 ; costs var1 distance=1, 2, 3, 4, 5 (=max cost)
D2=1 3 5 9 17 ; costs var2 distance=1, 2, 3, 4, 5 (=max cost)
D3=1 3 5 17 17 ; costs var3 distance=1, 2, 3, 4, 5 (=max cost)
[Misc]
MINTABVAL=0 ; Each cell is non-negative // ondergrens
MAXTABVAL=150000000 ; and less than MAXTABVAL // totaal generaal van Resp (Shadow? Anco)
OUTDIR=c:/knb/hitas/test/ ; Will contain ouput-files (= TEMP-dir?) // werkdirectory
*/


bool CHitas::WriteParameterFile(FILE *fd, CTable& tab)
{
fprintf(fd, "[Frequency rule]\n");
fprintf(fd, "MINCOUNT=%d\n\n", tab.SafeMinRec);

/*
fprintf(fd, "[Dominance rule]\n");
fprintf(fd, "DOMCOUNT=%d\n", tab.DominanceNumber);
fprintf(fd, "DOMPRO=0.%d\n\n", tab.DominancePerc);
*/

fprintf(fd, "[Safety ranges]\n");
fprintf(fd, "LOWERMARG=0.99\n");
fprintf(fd, "UPPERMARG=1.01\n\n");

fprintf(fd, "[Misc]\n");
fprintf(fd, "MINTABVAL=0\n");
fprintf(fd, "MAXTABVAL=%.0f\n\n", tab.GetCell(0L)->GetResp() * 1.5); // should be enough
// MakeTempPath(); Wordt nu door TAU doorgegeven.
// fprintf(fd, "OUTDIR=%s\n\n", (LPCTSTR) TempPath);

fprintf(fd, "[Costs]\n");
fprintf(fd, "DISTANCE=0\n");

return true;
}

/*
3 // aantal dimensies tabel
c:\knb\hitas\test3\data\SBI3.txt // naam bestand met opspanvariabele 1
c:\knb\hitas\test3\data\GK3.txt // naam bestand met opspanvariabele 2
c:\knb\hitas\test3\data\Regio3.txt // naam bestand met opspanvariabele 3
c:\knb\hitas\test3\data\BTab.dat // naam bestand met basistabel
c:\knb\hitas\test\status3.dat // naam bestand met resultaat (alleen secundaire cellen)
*/

bool CHitas::WriteFilesFile(FILE *fd, CTable &tab, CVariable *var)
{
int i;
// string fname/*, varname*/;
//char fname[MAX_PATH];
//char varname[10];
string fname;
string varname;
fprintf(fd, "%ld\n", tab.nDim); // dimensies
fprintf(fd, "%ld\n", tab.nDim); // number of dimensions

// name files with codelists
for (i = 0; i < tab.nDim; i++) {
//sprintf(fname, "%shitasv%d.txt", TempPath.c_str(), i + 1);
fname = TempPath + "hitasv" + std::to_string(i+1) + ".txt";
varname = "Var_" + std::to_string(i+1);
fprintf(fd, "%s\n", fname.c_str());
var[tab.ExplVarnr[i]].WriteCodelist(fname.c_str(), ".", varname.c_str(), true);
}

// name file with table
//sprintf(fname, "%s%s", TempPath.c_str(), NameTabFile.c_str());
fname = TempPath + NameTabFile;
fprintf(fd, "%s\n", fname.c_str());
// write cells
WriteCellFile(fname.c_str(), tab, var);

// name file for result with secondary cell dimensions
//sprintf(fname, "%s%s", TempPath.c_str(), NameSecFile.c_str());
fname = TempPath + NameSecFile;
fprintf(fd, "%s\n", fname.c_str());

Expand Down
2 changes: 1 addition & 1 deletion src/Hitas.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CHitas
bool WriteCellDim(FILE *fd, CTable &tab, CVariable *var, long *dimsCell, long *dimsCodeList, int niv);
bool WriteCellFile(LPCTSTR FileName, CTable &tab, CVariable *var);
bool WriteFilesFile(FILE *fd, CTable& tab, CVariable *var);
bool WriteParameterFile(FILE *fd, CTable& tab);
//bool WriteParameterFile(FILE *fd, CTable& tab);
std::string TempPath;
CHitas();
virtual ~CHitas();
Expand Down
106 changes: 52 additions & 54 deletions src/Table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void CTable:: operator = (CTable &table2)
ApplyPeeper = table2.ApplyPeeper;
ApplyZeroRule = table2.ApplyZeroRule;
EmptyCellsAsNSEmpty = table2.EmptyCellsAsNSEmpty;

HasRecode = table2.HasRecode ;
}

Expand Down Expand Up @@ -941,60 +941,58 @@ bool CTable::GetIndicesFromCellNr(long CellNr, long *Indices)
// cells that are secondary unsafe are reset to safe.
void CTable::UndoSecondarySuppress(long SortSuppress)
{
long i;
CDataCell *dc;
// set realized upper and upper to initial values
for (i = 0; i < nCell; i++) {
dc = GetCell(i);
dc->SetRealizedUpperValue(0);
dc->SetRealizedLowerValue(0);
dc->SetCTAValue(0);
switch (SortSuppress) {
case WITHOUT_SINGLETON:
switch (dc->GetStatus()) {
case CS_SECONDARY_UNSAFE:
if (dc->GetFreq() == 0 ) {
dc->SetStatus (CS_EMPTY_NONSTRUCTURAL);}
else {
dc->SetStatus(CS_SAFE);};
break;
case CS_SECONDARY_UNSAFE_MANUAL:
dc->SetStatus(CS_SAFE_MANUAL);
break;
}
break;
case WITH_SINGLETON:
switch (dc->GetStatus()) {
case CS_UNSAFE_SINGLETON:
dc->SetStatus(CS_SAFE);
break;
case CS_UNSAFE_SINGLETON_MANUAL:
dc->SetStatus(CS_SAFE_MANUAL);
break;
}
break;

case BOTH:
switch (dc->GetStatus()) {
case CS_SECONDARY_UNSAFE:
if (dc->GetFreq() == 0 ) {
dc->SetStatus (CS_EMPTY_NONSTRUCTURAL);}
else {
dc->SetStatus(CS_SAFE);};
break;
case CS_SECONDARY_UNSAFE_MANUAL:
dc->SetStatus(CS_SAFE_MANUAL);
break;
case CS_UNSAFE_SINGLETON:
dc->SetStatus(CS_SAFE);
break;
case CS_UNSAFE_SINGLETON_MANUAL:
dc->SetStatus(CS_SAFE_MANUAL);
break;
}

}
long i;
CDataCell *dc;
// set realized lower and upper to initial values
for (i = 0; i < nCell; i++) {
dc = GetCell(i);
dc->SetRealizedUpperValue(0);
dc->SetRealizedLowerValue(0);
dc->SetCTAValue(0);
switch (SortSuppress){
case WITHOUT_SINGLETON:
switch (dc->GetStatus()) {
case CS_SECONDARY_UNSAFE:
if (dc->GetFreq() == 0 ) {
dc->SetStatus (CS_EMPTY_NONSTRUCTURAL);}
else {
dc->SetStatus(CS_SAFE);};
break;
case CS_SECONDARY_UNSAFE_MANUAL:
dc->SetStatus(CS_SAFE_MANUAL);
break;
}
break;
case WITH_SINGLETON:
switch (dc->GetStatus()) {
case CS_UNSAFE_SINGLETON:
dc->SetStatus(CS_SAFE);
break;
case CS_UNSAFE_SINGLETON_MANUAL:
dc->SetStatus(CS_SAFE_MANUAL);
break;
}
break;
case BOTH:
switch (dc->GetStatus()) {
case CS_SECONDARY_UNSAFE:
if (dc->GetFreq() == 0 ) {
dc->SetStatus (CS_EMPTY_NONSTRUCTURAL);}
else {
dc->SetStatus(CS_SAFE);};
break;
case CS_SECONDARY_UNSAFE_MANUAL:
dc->SetStatus(CS_SAFE_MANUAL);
break;
case CS_UNSAFE_SINGLETON:
dc->SetStatus(CS_SAFE);
break;
case CS_UNSAFE_SINGLETON_MANUAL:
dc->SetStatus(CS_SAFE_MANUAL);
break;
}
}
}
}

// Get Status and Cost per Explanatory variable
Expand Down
6 changes: 3 additions & 3 deletions src/Table.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ class CTable
long PeepMinFreqHold;


int SafeMinRec; //Minimaal aantal bijdragers
int SafeMinHoldings; // minimum aantal holdings
int SafeMinRec; // Minimum number of contributors
int SafeMinHoldings; // Minimum number of holdings
/// Safety Margins

long CellFreqSafetyPerc;
Expand All @@ -129,7 +129,7 @@ class CTable
long NSEmptySafetyRange;
long SingletonSafetyRangePerc;
double ZeroSafetyRange;

// Operations

// have to make the operator =
Expand Down
12 changes: 6 additions & 6 deletions src/TauArgus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ bool TauArgus::DoRecode(long VarIndex, const char* RecodeString, long nMissing,
m_var[v].Recode.sCode.push_back(""); // for Total

// another time, now compute list of dest codes
ParseRecodeString(v, RecodeString, ErrorType, ErrorLine, ErrorPos, DESTCODE);
if (m_var[v].Recode.sCode.size() < 2){
ParseRecodeString(v, RecodeString, ErrorType, ErrorLine, ErrorPos, DESTCODE);
if (m_var[v].Recode.sCode.size() < 2){
*ErrorType = E_EMPTYSPEC;
*ErrorLine = 1;
*ErrorPos = 1;
Expand All @@ -377,8 +377,8 @@ bool TauArgus::DoRecode(long VarIndex, const char* RecodeString, long nMissing,
// m_var[v].Recode.nCode = m_var[v].Recode.sCode.GetSize();

// again, now compute dest codes and link between dest and src
oke = ParseRecodeString(v, RecodeString, ErrorType, ErrorLine, ErrorPos, SRCCODE);
if (!oke){
oke = ParseRecodeString(v, RecodeString, ErrorType, ErrorLine, ErrorPos, SRCCODE);
if (!oke){
return false; // missing to valid codes, a terrible shame
}

Expand Down Expand Up @@ -1627,7 +1627,7 @@ bool TauArgus::SetTableSafety(long Index, bool DominanceRule,
//Hitas for secondary supressions
bool TauArgus::PrepareHITAS(long TableIndex, const char* NameParameterFile, const char* NameFilesFile, const char* TauTemp)
{
m_hitas.TempPath = TauTemp; // Temp doorgeven vanuit de TAU ipv zlf bepalen.
m_hitas.TempPath = TauTemp; // Use Temp directory passed by TAU

long t = TableIndex;

Expand All @@ -1648,7 +1648,7 @@ bool TauArgus::PrepareHITAS(long TableIndex, const char* NameParameterFile, cons
return false;
}

if (!m_hitas.WriteParameterFile(fdParameter, m_tab[t]) ) goto error;
//if (!m_hitas.WriteParameterFile(fdParameter, m_tab[t]) ) goto error; // Is now taken care of in tau-argus GUI (Java)
if (!m_hitas.WriteFilesFile(fdFiles, m_tab[t], m_var) ) goto error;

fclose(fdParameter);
Expand Down
2 changes: 1 addition & 1 deletion src/Variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class CVariable
double MaxValue; // maximum in data file


std::vector<std::string> sCode; // For categorical variables: list of codes generated from microfile or from a file
std::vector<std::string> sCode; // For categorical variables: list of codes generated from microfile or from a file
std::vector<unsigned char> hLevel; // Levels hierarchical codelist, nCodes long
std::vector<unsigned char> hLevelBasic; // Basic code hierarchical codelist, nCodes long

Expand Down
8 changes: 4 additions & 4 deletions src/Versioninfo.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/* Version number is also stated in defines.h. Needs to be adjusted manually. */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
1 VERSIONINFO
FILEVERSION 1,1,4,11
PRODUCTVERSION 1,1,4,11
FILEVERSION 1,1,4,12
PRODUCTVERSION 1,1,4,12
FILETYPE 2
BEGIN
BLOCK "StringFileInfo"
Expand All @@ -12,12 +12,12 @@ BEGIN
BEGIN
VALUE "CompanyName", ""
VALUE "FileDescription", "Data Engine TauArgus"
VALUE "FileVersion", "1.1.4.11"
VALUE "FileVersion", "1.1.4.12"
VALUE "InternalName", ""
VALUE "LegalCopyright", ""
VALUE "OriginalFilename", "TauArgusJava.dll"
VALUE "ProductName", "TauArgusJava.dll"
VALUE "ProductVersion", "1.1.4.11"
VALUE "ProductVersion", "1.1.4.12"
END
END
BLOCK "VarFileInfo"
Expand Down
4 changes: 2 additions & 2 deletions src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
#ifndef __TAUARGUSDEFINESH
#define __TAUARGUSDEFINESH

#define VERSIONNUMBER "1.1.4.11"
#define VERSIONNUMBER "1.1.4.12"

#define MAXCODEWIDTH 100
#define MAXRECORDLENGTH 32000
#define SEPARATOR "\r\n"
#define MAXMEMORYUSE 50000000
//#define MAXMEMORYUSE 50000000 // Not used????

#define FIREPROGRESS 1000
#define MAXDIM 10
Expand Down

0 comments on commit fa0e1c5

Please sign in to comment.