Print Implikant algoritmus geschrieben aber. funktionniert. Keine Fehler

bei der Compilierung aber die Kuller auftreten nicht
This commit is contained in:
gaeltp3 2013-12-23 02:51:37 +01:00
parent aeb5cbfe34
commit 10269bcd65
4 changed files with 114 additions and 47 deletions

View file

@ -9,6 +9,8 @@ extern uint dimension;
extern uint numElements;
extern bool KNF;
using namespace std;
void KV::Clear()
{
@ -162,7 +164,7 @@ void KV::PrintCellValues() // Erstellt die Werte der jeweiligen Zellen: ▯▯
void KV::PrintPrimImplikanten()
{
srand(time(NULL)+rand());
srand(time(NULL) + rand());
for (uint i = 0; i < this->globalPic->size(); i++)
{
PrimImplikant* currentPI = this->globalPic->at(i);
@ -170,35 +172,35 @@ void KV::PrintPrimImplikanten()
/*uint overflow = 0; // at which sides the PrimImplikant overlaps
for (uint j = 0; j < currentPI->implikanten.size(); j++)
{
uint currentI = currentPI->implikanten[j];
uint w = (currentI & ((0x1 << (this->numVarX)) - 1)); // get all bits that make X (=w)
w ^= w / 2;
uint h = (currentI >> this->numVarX); // get all bits that make Y (=h)
h ^= h / 2;
uint currentI = currentPI->implikanten[j];
uint w = (currentI & ((0x1 << (this->numVarX)) - 1)); // get all bits that make X (=w)
w ^= w / 2;
uint h = (currentI >> this->numVarX); // get all bits that make Y (=h)
h ^= h / 2;
if (w == 0)
overflow |= 0x1; // left side
else if (w == this->numFieldX - 1)
overflow |= 0x2; // right side
else
overflow |= 0x4;
if (w == 0)
overflow |= 0x1; // left side
else if (w == this->numFieldX - 1)
overflow |= 0x2; // right side
else
overflow |= 0x4;
if (h == 0)
overflow |= 0x10; // upper side
else if (h == this->numFieldY - 1)
overflow |= 0x20; // lower side
else
overflow |= 0x40;
if (h == 0)
overflow |= 0x10; // upper side
else if (h == this->numFieldY - 1)
overflow |= 0x20; // lower side
else
overflow |= 0x40;
}
switch (overflow)
{
case 0x33: // all 4 edges
break;
break;
case 0x30: // overflows from top to bottom
break;
break;
case 0x03: // overflows from left to right
break;
break;
default:
*/
@ -207,24 +209,70 @@ void KV::PrintPrimImplikanten()
uint X1 = -1, X2 = 0, Y1 = -1, Y2 = 0; // find coordinates for Rechteck
for (uint j = 0; j < currentPI->PI_groupCollection.size(); j++)
// uint X1 = -1, X2 = 0, Y1 = -1, Y2 = 0; // find coordinates for Rechteck
for (uint j = 0; j < currentPI->PI_groupCollection.size(); j++)
{
vector<Implikant_localisation*>* kullers = currentPI->PI_groupCollection[j];
for (uint k = 0; k < kullers->size(); k++)
{
vector<Implikant_localisation*>* kuller = currentPI->PI_groupCollection[j];
for (uint j = 0; j < kuller->size(); j++)
for (vector<Implikant_localisation*>::iterator it = kullers->begin(); it < kullers->end(); it++)
{
uint x1 = (*kuller)->w * (this->edgeLength + 1) + this->VarY_Length; // Upper coord
uint X1 = -1, X2 = 0, Y1 = -1, Y2 = 0;
uint x1 = (*it)->w * (this->edgeLength + 1) + this->VarY_Length; // Upper coord
uint x2 = x1 + this->edgeLength; // Lower coord
uint y1 = h * (this->edgeLength + 1) + this->VarX_Length; // Left coord
uint y1 = (*it)->h * (this->edgeLength + 1) + this->VarX_Length; // Left coord
uint y2 = y1 + this->edgeLength; // Right coo
X1 = min(X1, x1);
X2 = max(X2, x2);
Y1 = min(Y1, y1);
Y2 = max(Y2, y2);
if (currentPI->name.find("|") != string::npos)
{
this->Rechteck(X1 + 12, Y1 + 9, X2 - 12, Y2 - 9, RED, TRANS);
}
else
{
uint random = rand() % 10;
X1 += random;
X2 -= random;
Y1 += random;
Y2 -= random;
if (currentPI->implikanten.size() == 1)
this->Rechteck(X1, Y1, X2, Y2, GREEN, TRANS);
else
this->Rechteck(X1, Y1, X2, Y2, BLUE, TRANS);
}
}
}
}
}
}
/*
uint w = currentPI->PI_groupCollection // get all bits that make X (=w)
w ^= w / 2;
uint h = (currentI >> this->numVarX); // get all bits that make Y (=h)
@ -264,7 +312,7 @@ void KV::PrintPrimImplikanten()
//------------------------------------------------------------------
*/

View file

@ -44,6 +44,7 @@ public:
bool PrimImplikant::valueAt(uint position);
void PrimImplikant::parser(string input);

View file

@ -15,21 +15,21 @@ void PrimImplikantCollection::add(string input)
PrimImplikant* PI = new PrimImplikant(input);
PI->id = this->size();
setgroupCollection1(PI);
this->setgroupCollection1(PI);
this->add(PI);
}
void PrimImplikantCollection::add(uint input)
{
PrimImplikant* PI = new PrimImplikant(input);
PI->id = this->size();
setgroupCollection1(PI);
this->setgroupCollection1(PI);
this->add(PI);
}
void PrimImplikantCollection::add(uint input1, uint input2)
{
PrimImplikant* PI = new PrimImplikant(input1, input2);
PI->id = this->size();
setgroupCollection1(PI);
this->setgroupCollection1(PI);
this->add(PI);
}
@ -80,12 +80,14 @@ void PrimImplikantCollection::setgroupCollection1(PrimImplikant* &currentPI)
static int Linie_mitte;
uint numVarY = (uint)ceil(dimension / 2.0f);
//PrimImplikant* currentPI = currentPI; // Zuweisung diese Adresse an einem ZeigerObjekt denselben Namen.
for (it1 = currentPI->I_Vector.begin(); it1 < currentPI->I_Vector.end(); it1++)
{
if ((((*it1)->h) = (numVarY / 2) - 1) || (((*it1)->h) = (numVarY / 2)))
if ((((*it1)->h) == (numVarY / 2) - 1) || (((*it1)->h) == (numVarY / 2)))
{
Linie_mitte++; // test zu wissen ob die MitteLinie h der KV diagramm erreicht ist.
// Test zu wissen , wieviele Implikanten in Mitte_tiefe sind
@ -121,32 +123,40 @@ void PrimImplikantCollection::setgroupCollection1(PrimImplikant* &currentPI)
}
setgroupCollection2(currentPI,groupA);
setgroupCollection2(currentPI,groupB);
if (groupA.size())
{
setgroupCollection2(currentPI, groupA);
}
if (groupB.size())
{
setgroupCollection2(currentPI, groupB);
}
}
}
void PrimImplikantCollection::setgroupCollection2(PrimImplikant* &currentPI, vector<Implikant_localisation*>&group)
void PrimImplikantCollection::setgroupCollection2(PrimImplikant* &currentPI, vector<Implikant_localisation*> &group)
{
vector<Implikant_localisation*> hilfVec1, hilfVec2;
vector<Implikant_localisation*>::iterator it1;
uint numVarX = (uint)floor(dimension / 2.0f);
static int Linie_mitte; // Zustand 0--> wird h überprüft im Vector
// Zustand 1-->wird w überprüft im Vector.
// Ohne Zuweisung hat schalter am Anfang den Wert 0
static int Linie_mitte; // Zustand 0--> wird w überprüft im Vector
// Zustand 1 oder >1 -->wird w überprüft im Vector.
for (it1 = group.begin(); it1 < group.end(); it1++)
{
if ((((*it1)->h) = (numVarX / 2) - 1) || (((*it1)->h) = (numVarX / 2)))
if ((((*it1)->h) == (numVarX / 2) - 1) || (((*it1)->h) == (numVarX / 2)))
{
Linie_mitte++; // test zu wissen ob die MitteLinie h der KV diagramm erreicht ist.
// Test zu wissen , wieviele Implikanten in Mitte_tiefe sind
//schalter = 1;
Linie_mitte++; // test zu wissen ob die MitteLinie w der KV diagramm erreicht ist.
// Test zu wissen , wieviele Implikanten in Mitte_tiefe sind
}
continue;
}
@ -162,8 +172,8 @@ void PrimImplikantCollection::setgroupCollection2(PrimImplikant* &currentPI, vec
for (it1 = group.begin(); it1 < group.end(); it1++)
{
if (((*it1)->w < (numVarX / 2) - 1)) // die Implikanten, deren h <= numVary/2 -1 sind im groupA
{ // gespeichert.
if (((*it1)->w < (numVarX / 2) - 1)) // die Implikanten, deren w <= numVarX/2 -1 sind im groupA
{ // gespeichert. wenn w größer, dann wird im hilfVec2 gespeichert
hilfVec1.push_back(*it1);
@ -173,9 +183,17 @@ void PrimImplikantCollection::setgroupCollection2(PrimImplikant* &currentPI, vec
else { hilfVec2.push_back(*it1); }
}
if (hilfVec1.size())
{
currentPI->PI_groupCollection.push_back(&hilfVec1);
}
if (hilfVec2.size())
{
currentPI->PI_groupCollection.push_back(&hilfVec2);
}
currentPI->PI_groupCollection.push_back(&hilfVec1);
currentPI->PI_groupCollection.push_back(&hilfVec2);
}
}

View file

@ -23,7 +23,7 @@ public:
PrimImplikantCollection primImplikantenAt(uint position);
bool contains(PrimImplikant* foreign);
void setgroupCollection1(PrimImplikant* &currentPI);
void setgroupCollection2(PrimImplikant* &currentPI,vector<Implikant_localisation*>&group);
void setgroupCollection2(PrimImplikant* &currentPI,vector<Implikant_localisation*> &group);
bool Anwesenheit(Implikant_localisation* &I, vector<Implikant_localisation*> &group);
void Dispose();