MCPcopy Create free account
hub / github.com/avaneev/biteopt / generateSol3

Method generateSol3

biteopt.h:918–954  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

916 */
917
918 void generateSol3( CBiteRnd& rnd )
919 {
920 ptype* const Params = TmpParams;
921
922 const CBitePop& ParPop = selectParPop( 2, rnd );
923 const int ParPopSize = ParPop.getCurPopSize();
924
925 const ptype* const rp1 = ParPop.getParamsOrdered(
926 getMinSolIndex( 3, rnd, ParPopSize ));
927
928 const ptype* const rp2 = ParPop.getParamsOrdered(
929 rnd.getSqrIntInv( ParPopSize ));
930
931 const int Mode = select( Gen3ModeSel, rnd );
932 int i;
933
934 if( Mode == 0 )
935 {
936 for( i = 0; i < ParamCount; i++ )
937 {
938 Params[ i ] = rp1[ i ] + ( rp1[ i ] - rp2[ i ]);
939 }
940 }
941 else
942 {
943 static const double CentProb[ 4 ] = { 0.0, 0.25, 0.5, 0.75 };
944 const double p = CentProb[ Mode ];
945
946 const ptype* const cp = getCentroid();
947
948 for( i = 0; i < ParamCount; i++ )
949 {
950 Params[ i ] = ( rnd.get() < p ? cp[ i ] :
951 rp1[ i ] + ( rp1[ i ] - rp2[ i ]));
952 }
953 }
954 }
955
956 /**
957 * "Entropy bit mixing"-based solution generator. Performs crossing-over

Callers

nothing calls this directly

Calls 4

getCurPopSizeMethod · 0.80
getParamsOrderedMethod · 0.80
getSqrIntInvMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected