src/socp/shooting.cpp
// Solve Shooting for any other real data Rdata with continuation step continuationStep
Solve Shooting for any other real data Rdata with continuation step continuationStep
Solve Shooting for any other real data Rdata with continuation step continuationStep
int shooting::SolveShootingContinuation(real const& continuationStep, real & Rdata, real const& Rgoal) const
{
	real Rstart = Rdata; 
	int numParam = data->numParam;
	real bStep = continuationStep;
	real b = (std::min<real>)(continuationStep,1.0);  
	real b_prec = 0;
	Rdata = (1-b)*Rstart + b*Rgoal;
	for (int k=0;k<numParam;k++){
		data->tab_param_temp[k] = data->tab_param[k];
	}
	for (int i = 0; i<data->numMulti + 1; i++) {
		data->time[i] = data->timed[i];
		for (int j = 0; j<data->dim; j++) data->X[i][j] = data->Xd[i][j];
	}
	bool condition = true;
	int ret;
	while(condition){
		ret = SolveShootingFunction(numParam, data->tab_param_temp);
		if (ret != 1){
			if (fabs(b-b_prec)<data->continuationStepMin){
				condition = false;
			}
			b = b_prec + (b-b_prec)/2;
			for (int k=0;k<numParam;k++){
				data->tab_param_temp[k] = data->tab_param[k];
			}
			Rdata = (1-b)*Rstart + b*Rgoal;
		}
		if(ret == 1){
			if (b==1){
				condition = false;
			}else{
				b_prec = b;
				b = (std::min<real>)(b+bStep,1.0);
				for (int k=0;k<numParam;k++){
					data->tab_param[k] = data->tab_param_temp[k];
				}
				Rdata = (1-b)*Rstart + b*Rgoal;
			}
		}
	}
	if(ret == 1){
		for (int k=0;k<numParam;k++){
			data->tab_param[k] = data->tab_param_temp[k];
		}
	}
	return ret;
}
int shooting :: SolveShootingContinuation ( real const & continuationStep , real & Rdata , real const & Rgoal ) const { real Rstart = Rdata ; int numParam = data -> numParam ; real bStep = continuationStep ; real b = ( std :: min < real > ) ( continuationStep , 1.0 ) ; real b_prec = 0 ; Rdata = ( 1 - b ) * Rstart + b * Rgoal ; for ( int k = 0 ; k < numParam ; k ++ ) { data -> tab_param_temp [ k ] = data -> tab_param [ k ] ; } for ( int i = 0 ; i < data -> numMulti + 1 ; i ++ ) { data -> time [ i ] = data -> timed [ i ] ; for ( int j = 0 ; j < data -> dim ; j ++ ) data -> X [ i ] [ j ] = data -> Xd [ i ] [ j ] ; } bool condition = true ; int ret ; while ( condition ) { ret = SolveShootingFunction ( numParam , data -> tab_param_temp ) ; if ( ret != 1 ) { if ( fabs ( b - b_prec ) < data -> continuationStepMin ) { condition = false ; } b = b_prec + ( b - b_prec ) / 2 ; for ( int k = 0 ; k < numParam ; k ++ ) { data -> tab_param_temp [ k ] = data -> tab_param [ k ] ; } Rdata = ( 1 - b ) * Rstart + b * Rgoal ; } if ( ret == 1 ) { if ( b == 1 ) { condition = false ; } else { b_prec = b ; b = ( std :: min < real > ) ( b + bStep , 1.0 ) ; for ( int k = 0 ; k < numParam ; k ++ ) { data -> tab_param [ k ] = data -> tab_param_temp [ k ] ; } Rdata = ( 1 - b ) * Rstart + b * Rgoal ; } } } if ( ret == 1 ) { for ( int k = 0 ; k < numParam ; k ++ ) { data -> tab_param [ k ] = data -> tab_param_temp [ k ] ; } } return ret ; }
Solve Shooting for any other real data Rdata with continuation step continuationStep
Solve Shooting for any other real data Rdata with continuation step continuationStep
// starting value // continuation parameter (discrete continuation algortihm) // 1 is the max step // initial data value // temporary values are initialized // time // state //printf("data = %lf \n",Rdata); //printf("b = %lf \n",b); // solve the shooting problem // continuation do not give satisfactory results //std::cout << "bmin reached (b = " << b << ")" << std::endl; // continuation parameters is decreased // data->tab_param_temp[k] is re-initialized // *Rdata is updated // continuation worked // continuation is not finished // update data // return