Here is your 'class' after clean up:
#ifdef _AFX_ENABLE_INLINES
#define _AFX_INLINE AFX_INLINE
#if !defined(_AFX_CORE_IMPL) || !defined(_AFXDLL) || defined(_DEBUG)
#define _AFX_PUBLIC_INLINE AFX_INLINE
#else
#define _AFX_PUBLIC_INLINE
#endif
#endif
public enum Options{find_Optimal_Solution, find_realizable_solution};
typedef CArray<bool,bool> CTruthArray;
typedef CPtrArray<uint*,uint*>CResultArray;
struct NODE
{
UINT* R;
UINT* C;
UINT* B;
}
struct TEST
{
UINT* Dr;
UINT* Dc;
UINT* Db;
}
struct MATRIX
{
UINT* row;
UINT* col;
}
class CMMKP : public Script, CObject
{
DECLARE_DYNACREATE(CMMKP)
public:
CMMKP();
protected:
int n;
int m;
UINT* Gain;
UINT* R, C, B, Dr, Dc, Db, Gn, Lr;
NODE node1, node2, node3;
TEST test1, test2, test3;
MATRIX matATruths;
MATRIX matBTruths;
MATRIX matResults;
CTruthArray* Atruths;
CTruthArray* Btruths;
CUintArray* Kvalues;
void Linear(MMKP* pMMKP, UINT index, UINT mode, UINT type);
void GetSolution(Option& opt);
void ApplyConstrains();
void InitTruthArray();
MATRIX GetMatrix(UINT** results);
public:
~CMMKP();
void Serialize(CArchive&);
#ifdef _DEBUG
void Dump(CDumpContext&) const;
void AssertValid() const;
#endif
}
IntArgs, IntVarArray, and IntVar are not C++ predefined types. Also IRT_NQ is also a #define that is not defined in C++, unless you do define it someplace, or it is defined within the Gecode includes. Presuming:
IRT_NQ is = 'Integer Return Type of Not Equal';
IntArgs is = 'Integer Value Type Arguments';
IntVar is = 'Integer Type Variable';
IntVarArray = 'Integer Variable Type Array';
While I am not sure about what 'linear' is supposed to do, the above is a 'prototype' that declares it as a function of class CMMKP. So then below you would implement this in a *.cpp matching file, or outside the class definition, in the same file.
Then here below out of the class definition, you can implement it:
CMMKP::CMMKP()
{
Atruths = new CTruthArray();
Btruths = new CTruthArray();
Kvalues = new CUintArray();
}
CMMKP::~CMMKP()
{
if(Atruths != NULL)
delete Atruths;
if(Btruths != NULL)
delete Btruths;
if(Kvalues != NULL)
delete Kvalues ;
}
void CMMKP::GetSolution(Option& opt)
{
switch (opt.model())
{
case find_Optimal_Solution:
Gn = {4,20,30,40,50};
for (int i = 0; i < n; i++)
{
linear(*this, Gn, X.row(i), IRT_EQ, Gain);
}
for ( int i=0; i<n;i++)>
{
for ( int j =0; j<m;j++)>
{
Results(i,j)=X(i,j);
}
}
break;
case find_realizable_solution:
for ( int i=0; i<n;i++)>
{
for ( int j =0; j<m;j++)>
{
Results(i,j)=X(i,j);
}
}
break;
}
void CMMKP::Linear(MMKP* pMMKP, UINT index, UINT mode, UINT type)
{
}
void MMKP::InitArrays()
{
UINT num = n*m;
Atruths->SetSize(num,-1);
matATruths = GetMatrix(Atruths);
Kvalues->SetSize(num,-1);
matResults = GetMatrix(Kvalues);
Btruths->SetSize(num,-1);
matBTruths = GetMatrix(Btruths);
node1.R = {4,10,15,20,40};
node1.C = {4,20,25,30,40};
node1.B = {4,20,30,35,40};
test1.Dr = {4,5,10,15,25};
test1.Dc = {4,15,20,35,37};
test1.Db = {4,10,15,20,35};
}
void CMMKP::ApplyConstrains()
{
for ( int j=0; j<n;j++)>
{
linear(*this , X.row(j),IRT_EQ,1);
}
for (int i=0; i<m;i++)>
{
for ( int j =0; j<n mode="hold" /> {
XDual(i,j)=X(j,i);
}
}
for (int j = 0; j < m; j++)
{
linear(*this, Dr,XDual.row(j),IRT_NQ, R[j]);
}
for (int j = 0; j < m; j++)
{
linear (*this, Dc, XDual.row(j), IRT_NQ,C[j]);
}
for (int j = 0; j < m; j++)
{
linear (*this, Db, XDual.row(j), IRT_NQ,B[j]);
}
}
So that should help a little ...