next up previous contents
Next: Simulators Up: Source code Previous: Main functions   Contents

Optimization algorithms


Slop.cc
3 #include "mystdinclude.h"
4 #include "myenum.h"
5 #include "print.h"
6 #include "slop.h"
7 
8  ///
9 Slop::Slop( const Circuit& circuit, const Options& options, EvaluationAlgorithm& simulation )
10 :
11 OptimizationAlgorithm( circuit, options, simulation ),
12 TMat(0), TMatOld(0), GMat(0), T(0), SaveW(0)
13 
14 print_log( "Creating Slop instance..." );
15 TMat = new double * [ NumPath ];
16 TMatOld = new double * [ NumPath ];
17 GMat = new double * [ NumPath ];
18 T = new double [ NumPath ];
19 SaveW = new double[ NumTran ];
20 if ( ( !TMat ) || ( !TMatOld ) || ( !GMat ) || ( !T ) || ( !SaveW ) )
21 
22 print_log( "FATAL ERROR:" );
23 print_log( ReturnMessage[ NO_MEM ] );
24 error( NO_MEM, errno, "HEY! " );
25 
26 for ( unsigned int i = 0; i < NumPath; i++ )
27 
28 TMat[ i ] = new double [ NumTran ];
29 TMatOld[ i ] = new double [ NumTran ];
30 GMat[ i ] = new double [ NumTran ];
31 if ( ( !TMat[ i ] ) || ( !TMatOld[ i ] ) || ( !GMat[ i ] ) )
32 
33 print_log( "FATAL ERROR:" );
34 print_log( ReturnMessage[ NO_MEM ] );
35 error( NO_MEM, errno, "HEY! " );
36 
37 
38 
39 
40  ///
41 Slop:: Slop()
42 
43 for ( unsigned int i = 0; i < NumPath; i++ )
44 
45 delete[] TMat[ i ];
46 delete[] GMat[ i ];
47 
48 delete[] TMat;
49 delete[] TMatOld;
50 delete[] GMat;
51 delete[] SaveW;
52 
53 
54  ///
55 int Slop::Run()
56 
57 int Wbig;
58 int RetCode;
59 for ( unsigned int i = 0; i < NumTran; i++ )
60 SaveW[ i ] = Width[ i ];
61 double max = 0;
62 double TMax = 0;
63 unsigned int jmax;
64 double dummy;
65 unsigned int end_acc = 0;
66 for ( Steps = 1; ( Steps < options.GetOptOption( MAXSTEPS ) )
67 && (max >= 0.0)
68 && ( InternalSteps < options.GetOptOption( MAXSTEPS ) )
69 && (end_acc == 0); Steps++ )
70 
71 
72 for ( unsigned int i = 0; i < NumTran; i++ )
73 Width[ i ] = SaveW[ i ];
74 dummy = SlopNormSim( Width, RetCode);
75 if ((RetCode != OK) && (RetCode != CONT) && (RetCode != MAX_STEPS) && (RetCode != END_ACC))
76 return RetCode;
77 else if ((RetCode == MAX_STEPS) || (RetCode == END_ACC))
78 end_acc = 1;
79 TMax = 0.0;
80 jmax = 0;
81 for ( unsigned int i = 0; i < NumPath; i++ )
82 
83 T[ i ] = CPDelay[ i ];
84 for ( unsigned int j = 0; j < NumTran; j++ )
85 TMatOld[ i ][ j ] = T[ i ];
86 if ( T[ i ] > TMax )
87 
88 TMax = T[ i ];
89 jmax = i;
90 
91 
92 for ( unsigned int i = 0; i < NumTran; i++ )
93 
94 Width[ i ] += options.GetOptOption( DELTA );
95 if (options.GetOptOption( WMAX ) > 0)
96 if ( Width[ i ] >= options.GetOptOption( WMAX ) )
97 Width[ i ] = options.GetOptOption( WMAX );
98 dummy = SlopNormSim( Width, RetCode);
99 if ((RetCode != OK) && (RetCode != CONT) && (RetCode != MAX_STEPS) && (RetCode != END_ACC))
100 return RetCode;
101 else if ((RetCode == MAX_STEPS) || (RetCode == END_ACC))
102 end_acc = 1;
103 Width[ i ] = SaveW[ i ];
104 if ( options.GetOptOption( CONSTRAINS ) )
105 
106 if ( ( CPDelay[ i ] <= options.GetOptOption( MAXDELAY ) ) &&
107 ( CPPower[ i ] <= options.GetOptOption( MAXPOWER ) ) &&
108 ( CPNoise[ i ] <= options.GetOptOption( MAXNOISE ) ) &&
109 ( Area <= options.GetOptOption( MAXAREA ) ) )
110 for ( unsigned int j = 0; j < NumPath; j++ )
111 
112 T[ j ] = CPDelay[ j ];
113 TMat[ j ][ i ] = T[ j ];
114 
115 
116 else
117 for ( unsigned int j = 0; j < NumPath; j++ )
118 
119 T[ j ] = CPDelay[ j ];
120 TMat[ j ][ i ] = T[ j ];
121 
122 
123 Wbig = -1;
124 max = 0.0;
125 for ( unsigned int i = 0; i < NumPath; i++ )
126 
127 for ( unsigned int j = 0; j < NumTran; j++ )
128 
129 GMat[ i ][ j ] = TMatOld[ i ][ j ] - TMat[ i ][ j ];
130 if ( ( GMat[ i ][ j ] > max ) && ( i == jmax ) )
131 
132 max = GMat[ i ][ j ];
133 Wbig = j;
134 
135 TMatOld[ i ][ j ] = TMat[ i ][ j ];
136 
137 
138 if ( Wbig != -1 )
139 SaveW[ Wbig ] += options.GetOptOption( DELTA );
140 else
141 max = -1.0;  // so max < 0
142 
143 
144 for ( unsigned int i = 0; i < NumTran; i++ )
145 
146 Width[ i ] = SaveW[ i ];
147 
148 dummy = SlopNormSim( Width, RetCode);
149 return RetCode;
150 

SlopNorm.cc
3 #include "mystdinclude.h"
4 #include "myenum.h"
5 #include "print.h"
6 #include "slop.h"
7 
8 
9  ///
10 double Slop::SlopNormSim( const double* NewWidth, int& RetCode)
11 
12 return NormSim( NewWidth, RetCode);
13 

Slop2.cc
3 #include "mystdinclude.h"
4 #include "myenum.h"
5 #include "print.h"
6 #include "slop2.h"
7 
8  ///
9 Slop2::Slop2( const Circuit& circuit, const Options& options, EvaluationAlgorithm& simulation )
10 :
11 OptimizationAlgorithm( circuit, options, simulation ),
12 TMat(0), TMatOld(0), GMat(0), SaveW(0)
13 
14 print_log( "Creating Slop2 instance..." );
15 TMat = new double * [ NumPath ];
16 TMatOld = new double * [ NumPath ];
17 GMat = new double * [ NumPath ];
18 SaveW = new double[ NumTran ];
19 if ( ( !TMat ) || ( !TMatOld ) || ( !GMat ) || ( !SaveW ) )
20 
21 print_log( "FATAL ERROR:" );
22 print_log( ReturnMessage[ NO_MEM ] );
23 error( NO_MEM, errno, "HEY! " );
24 
25 for ( unsigned int i = 0; i < NumPath; i++ )
26 
27 TMat[ i ] = new double [ NumTran ];
28 TMatOld[ i ] = new double [ NumTran ];
29 GMat[ i ] = new double [ NumTran ];
30 if ( ( !TMat[ i ] ) || ( !TMatOld[ i ] ) || ( !GMat[ i ] ) )
31 
32 print_log( "FATAL ERROR:" );
33 print_log( ReturnMessage[ NO_MEM ] );
34 error( NO_MEM, errno, "HEY! " );
35 
36 
37 
38 
39  ///
40 Slop2:: Slop2()
41 
42 for ( unsigned int i = 0; i < NumPath; i++ )
43 
44 delete[] TMat[ i ];
45 delete[] GMat[ i ];
46 
47 delete[] TMat;
48 delete[] TMatOld;
49 delete[] GMat;
50 delete[] SaveW;
51 
52 
53  ///
54 int Slop2::Run()
55 
56 int Wbig;
57 int RetCode;
58 for ( unsigned int i = 0; i < NumTran; i++ )
59 SaveW[ i ] = Width[ i ];
60 double max = 0;
61 double dummy;
62 for ( unsigned int i = 0; i < NumTran; i++ )
63 Width[ i ] = SaveW[ i ];
64 dummy = Slop2NormSim( Width, RetCode);
65 if ( (RetCode != OK ) && (RetCode != CONT))
66 return RetCode;
67 for ( unsigned int i = 0; i < NumPath; i++ )
68 
69 for ( unsigned int j = 0; j < NumTran; j++ )
70 TMatOld[ i ][ j ] = dummy;
71 
72 unsigned int end_acc = 0;
73 for ( Steps = 1; ( Steps < options.GetOptOption( MAXSTEPS ) )
74 && ( max >= 0.0 )
75 && ( InternalSteps < options.GetOptOption( MAXSTEPS )
76 && (end_acc == 0)); Steps++ )
77 
78 
79 for ( unsigned int i = 0; i < NumTran; i++ )
80 Width[ i ] = SaveW[ i ];
81 for ( unsigned int i = 0; i < NumTran; i++ )
82 
83 Width[ i ] += options.GetOptOption( DELTA );
84 if (options.GetOptOption( WMAX ) > 0)
85 if ( Width[ i ] >= options.GetOptOption( WMAX ) )
86 Width[ i ] = options.GetOptOption( WMAX );
87 dummy = Slop2NormSim( Width, RetCode);
88 if ((RetCode != OK) && (RetCode != CONT) && (RetCode != MAX_STEPS) && (RetCode != END_ACC))
89 return RetCode;
90 else if ((RetCode == MAX_STEPS) || (RetCode == END_ACC))
91 end_acc = 1;
92 Width[ i ] = SaveW[ i ];
93 for ( unsigned int j = 0; j < NumPath; j++ )
94 
95 TMat[ j ][ i ] = dummy;
96 
97 
98 Wbig = -1;
99 max = 0.0;
100 for ( unsigned int i = 0; i < NumPath; i++ )
101 for ( unsigned int j = 0; j < NumTran; j++ )
102 
103 GMat[ i ][ j ] = TMatOld[ i ][ j ] - TMat[ i ][ j ];
104 if ( GMat[ i ][ j ] > max )
105 
106 max = GMat[ i ][ j ];
107 Wbig = j;
108 
109 TMatOld[ i ][ j ] = TMat[ i ][ j ];
110 
111 if ( Wbig != -1 )
112 SaveW[ Wbig ] += options.GetOptOption( DELTA );
113 else
114 max = -1.0;  // so max < 0
115 
116 
117 for ( unsigned int i = 0; i < NumTran; i++ )
118 Width[ i ] = SaveW[ i ];
119 dummy = Slop2NormSim( Width, RetCode);
120 return RetCode;
121 

Slop2Norm.cc
3 #include "mystdinclude.h"
4 #include "myenum.h"
5 #include "print.h"
6 #include "slop2.h"
7 
8 
9  ///
10 double Slop2::Slop2NormSim( const double* NewWidth, int& RetCode)
11 
12 return NormSim( NewWidth, RetCode);
13 

TestEv.cc
3 #include "mystdinclude.h"
4 #include "myenum.h"
5 #include "print.h"
6 #include "test.h"
7 
8  ///
9 TestEval::TestEval( const Circuit& circuit, const Options& options, EvaluationAlgorithm& simulation )
10 :
11 OptimizationAlgorithm( circuit, options, simulation ) ,
12 TryW(0)
13 
14 print_log( "Creating TestEval instance..." );
15 TryW = new double[ NumTran ];
16 if ( !TryW )
17 
18 print_log( "FATAL ERROR:" );
19 print_log( ReturnMessage[ NO_MEM ] );
20 error( NO_MEM, errno, "HEY! " );
21 
22 
23 
24  ///
25 TestEval:: TestEval()
26 
27 delete[] TryW;
28 
29 
30  ///
31 int TestEval::Run()
32 
33 int RetCode;
34 double dummy;
35 for ( unsigned int i = 0; i < NumTran; i++ )
36 TryW[ i ] = options.GetOptOption( WMIN );
37 for ( Steps = 1; Steps < options.GetOptOption( MAXSTEPS ) ; Steps++ )
38 
39 
40 dummy = TestEvalNormSim( TryW, RetCode);
41 if ( (RetCode != OK ) && (RetCode != CONT))
42 return RetCode;
43  // if (Steps $ <=$ NumTran)
44  // TryW[(Steps - 1)] += options.GetOptOption( DELTA );
45  // else
46  // TryW[(Steps - 1) % NumTran] += options.GetOptOption(DELTA);
47 for (int i = 0; i < NumTran; i++)
48 TryW[i] += options.GetOptOption( DELTA );
49 
50 return OK;
51 

TestNorm.cc
3 #include "mystdinclude.h"
4 #include "myenum.h"
5 #include "print.h"
6 #include "test.h"
7 
8 
9  ///
10 double TestEval::TestEvalNormSim( const double* NewWidth, int& RetCode)
11 
12 return NormSim( NewWidth, RetCode);
13 


next up previous contents
Next: Simulators Up: Source code Previous: Main functions   Contents
marco+site@equars.com