void set_matte_node_t::do_calc_bounds( const render::context_t& context) { if( get_value<bool>( param( "premultiply"))) set_bounds( ImathExt::intersect( input_as<image_node_t>( 0)->bounds(), input_as<image_node_t>( 1)->bounds())); else set_bounds( input_as<image_node_t>( 0)->bounds()); }
void set_matte_node_t::do_calc_bounds( const render::render_context_t& context) { if( get_value<bool>( param( "premultiply"))) set_bounds( intersect( input(0)->bounds(), input(1)->bounds())); else set_bounds( input(0)->bounds()); }
void invert_node_t::do_calc_bounds( const render::context_t& context) { int alpha = get_value<int>( param( "channels")); if( alpha) set_bounds( format()); else set_bounds( input_as<image_node_t>()->bounds()); }
void keyer3d_node_t::do_calc_bounds( const render::context_t& context) { image_node_t *in0 = input_as<image_node_t>( 0); if( input( 1) && !is_active()) set_bounds( Imath::intersect( in0->bounds(), input_as<image_node_t>( 1)->bounds())); else set_bounds( in0->bounds()); }
void copy_channels_node_t::do_calc_bounds( const render::render_context_t& context) { Imath::Box2i rod1 = input(0)->bounds(); Imath::Box2i rod2 = input(1)->bounds(); int ch_r = get_value<int>( param( "red")); int ch_g = get_value<int>( param( "green")); int ch_b = get_value<int>( param( "blue")); int ch_a = get_value<int>( param( "alpha")); // use alpha from input 1 if( ch_a == copy_source) { set_bounds( rod1); return; } // alpha comes from input2 if( ch_a != set_one && ch_a != set_zero) { set_bounds( rod2); return; } // alpha is zero or one, look at the other channels Imath::Box2i rod; if( ch_r == copy_source) rod = rod1; else { if( ch_r != set_zero && ch_r != set_one) rod = rod2; } if( ch_g == copy_source) rod.extendBy( rod1); else { if( ch_g != set_zero && ch_r != set_one) rod.extendBy( rod2); } if( ch_b == copy_source) rod.extendBy( rod1); else { if( ch_b != set_zero && ch_r != set_one) rod.extendBy( rod2); } if( rod.isEmpty()) rod = rod1; set_bounds( rod); }
void node_t::do_calc_bounds( const render::render_context_t& context) { if( num_inputs() != 0) { if( input()) { set_bounds( input()->bounds()); return; } } // as a fallback set the domain to the default set_bounds( domain()); }
void distortx_node_t::do_calc_bounds( const render::context_t& context) { Imath::V2f amplitude = get_value<Imath::V2f>( param( "amplitude")); Imath::Box2i b( input_as<image_node_t>( 0)->bounds()); if( !b.isEmpty()) { b.min.x -= amplitude.x; b.min.y -= amplitude.y; b.max.x += amplitude.x; b.max.y += amplitude.y; if( input( 1)) { Imath::Box2i b2( input_as<image_node_t>( 1)->bounds()); b2.min.x -= amplitude.x; b2.min.y -= amplitude.y; b2.max.x += amplitude.x; b2.max.y += amplitude.y; b2.extendBy( input_as<image_node_t>( 0)->bounds()); b = Imath::intersect( b, b2); } } set_bounds( b); }
void layer_node_t::do_calc_bounds( const render::context_t& context) { Imath::Box2i bbox; float opacity = get_value<float>( param( "opacity")); if( opacity == 1.0f) { switch( get_value<int>( param( "layer_mode"))) { case comp_mult: case comp_min: case comp_mix: bbox = ImathExt::intersect( input_as<image_node_t>( 0)->bounds(), input_as<image_node_t>( 1)->bounds()); break; case comp_sub: bbox = input_as<image_node_t>( 0)->bounds(); break; default: bbox = input_as<image_node_t>( 0)->bounds(); bbox.extendBy( input_as<image_node_t>( 1)->bounds()); } } else { bbox = input_as<image_node_t>( 0)->bounds(); bbox.extendBy( input_as<image_node_t>( 1)->bounds()); } set_bounds( bbox); }
/** * @see problem::base constructors. */ gtoc_1::gtoc_1():base(8),Delta_V(8),rp(6),t(8) { // Set bounds. const double lb[8] = {3000,14,14,14,14,100,366,300}; const double ub[8] = {10000,2000,2000,2000,2000,9000,9000,9000}; set_bounds(lb,lb+8,ub,ub+8); //Defining the problem data up the problem parameters problem.type = asteroid_impact; problem.mass = 1500.0; // Satellite initial mass [Kg] problem.Isp = 2500.0; // Satellite specific impulse [s] problem.DVlaunch = 2.5; // Launcher DV in km/s int sequence_[8] = {3,2,3,2,3,5,6,10}; // sequence of planets std::vector<int> sequence(8); problem.sequence.insert(problem.sequence.begin(), sequence_, sequence_+8); const int rev_[8] = {0,0,0,0,0,0,1,0}; // sequence of clockwise legs std::vector<int> rev(8); problem.rev_flag.insert(problem.rev_flag.begin(), rev_, rev_+8); problem.asteroid.keplerian[0] = 2.5897261; // Asteroid data problem.asteroid.keplerian[1] = 0.2734625; problem.asteroid.keplerian[2] = 6.40734; problem.asteroid.keplerian[3] = 128.34711; problem.asteroid.keplerian[4] = 264.78691; problem.asteroid.keplerian[5] = 320.479555; problem.asteroid.epoch = 53600; }
void box::adjust_bound(vector<box> const & box_stack) { if (!is_empty() && box_stack.size() > 0) { box bound(*this); bound.hull(box_stack); set_bounds(bound.get_values()); } }
Vorbis::Vorbis(const functional::Audio<sound::Sound>& sounds, uint8_t channels, uint32_t bitrate) { THROW_IF(sounds.count() >= security::kMaxSampleCount, Unsafe); THROW_IF(channels != 1 && channels != 2, InvalidArguments); THROW_IF(find(kSampleRate.begin(), kSampleRate.end(), sounds.settings().sample_rate) == kSampleRate.end(), InvalidArguments); // Adjust bitrate if requested bitrate is larger than the allowed maximum for (uint32_t i = 0; i < kMaxBitrates.size(); ++i) { if (sounds.settings().sample_rate < kMaxBitrates[i].min_sample_rate) { THROW_IF(i == 0, Unsupported); uint32_t max_bitrate = (channels == 1) ? kMaxBitrates[i - 1].mono : kMaxBitrates[i - 1].stereo; bitrate = min(bitrate, max_bitrate); break; } } _this.reset(new _Vorbis(sounds.settings().sample_rate, channels, bitrate)); _this->sounds = sounds; uint32_t index = 0; for (auto sound: _this->sounds) { queue<Sample> samples; _this->encode_pcm((uint32_t)(index++), samples); set_bounds(0, b() + (int)samples.size()); } // Update settings _settings = _this->sounds.settings(); _settings.codec = settings::Audio::Codec::Vorbis; _settings.channels = channels; _settings.bitrate = bitrate; }
void flip_node_t::do_calc_bounds( const render::context_t& context) { calc_transform_matrix(); Imath::Box2i xfbounds( input_as<image_node_t>()->bounds()); xfbounds = ImathExt::transform( xfbounds, xform_); set_bounds( xfbounds); }
/** * Constructor of antibodies meta-problem * * Note: This problem is not intended to be used by itself. Instead use the * cstrs_immune_system algorithm if you want to solve constrained problems. * * @param[in] problem base::problem to be used to set up the boundaries * @param[in] method method_type to used for the distance computation. * Two posssibililties are available: HAMMING, EUCLIDEAN. */ antibodies_problem::antibodies_problem(const base &problem, const algorithm::cstrs_immune_system::distance_method_type method): base((int)problem.get_dimension(), problem.get_i_dimension(), problem.get_f_dimension(), 0, 0, 0.), m_original_problem(problem.clone()), m_pop_antigens(), m_method(method) { if(m_original_problem->get_c_dimension() <= 0){ pagmo_throw(value_error,"The original problem has no constraints."); } // check that the dimension of the problem is 1 if(m_original_problem->get_f_dimension() != 1) { pagmo_throw(value_error,"The original fitness dimension of the problem must be one, multi objective problems can't be handled with co-evolution meta problem."); } // encoding for hamming distance m_bit_encoding = 25; m_max_encoding_integer = int(std::pow(2., m_bit_encoding)); set_bounds(m_original_problem->get_lb(),m_original_problem->get_ub()); }
void node_t::calc_bounds( const render::render_context_t& context) { if( is_valid_ && !ignored()) { do_calc_bounds( context); return; } if( ignored() && ( num_inputs() != 0) && input()) { set_bounds( input()->bounds()); return; } set_bounds( domain()); }
mga_target_event::mga_target_event( const kep_toolbox::plantes::planet_ptr start, const kep_toolbox::planet::planet_ptr end, const kep_toolbox::epoch t_end, double T_max, bool discount_launcher ):base(6), m_start(start), m_end(end), m_t_end(t_end), m_T_max(T_max), m_discount_launcher(discount_launcher) { // We check that all planets have equal central body if (start->get_mu_central_body() != end->get_mu_central_body()) { pagmo_throw(value_error,"The planets do not all have the same mu_central_body"); } // We check that T_max is positive if (T_max <= 0) { pagmo_throw(value_error,"T_max must be larger than zero"); } // Now setting the problem bounds decision_vector lb(6,0.0), ub(6,1.0); lb[0] = 1.; lb[5] = 1e-5; ub[0] = T_max; ub[2] = 12000.0; ub[5] = 1-1e-5; set_bounds(lb,ub); }
/** * Instantiates the sample_return problem */ sample_return::sample_return(const ::kep_toolbox::planet::base &asteroid, const double &Tmax):base(12), m_target(asteroid.clone()), m_leg1(total_DV_rndv,EA,2,0,0,0,0,0), m_leg2(total_DV_rndv,AE,2,0,0,0,0,0),x_leg1(6),x_leg2(6),m_Tmax(Tmax) { ::kep_toolbox::epoch start_lw(2020,1,1); ::kep_toolbox::epoch end_lw(2035,1,1); const double lb[12] = {start_lw.mjd2000(),0 ,0,0,0.1 ,0.001, 20 ,0,0,0,0.1 ,0.001}; const double ub[12] = {end_lw.mjd2000() ,5.5,1,1,0.7, 0.999, 50 ,6,1,1,1 ,0.999}; set_bounds(lb,lb+12,ub,ub+12); for (int i = 0;i<6;++i) { m_leg1.asteroid.keplerian[i] = m_target->compute_elements(::kep_toolbox::epoch(0))[i]; m_leg2.asteroid.keplerian[i] = m_target->compute_elements(::kep_toolbox::epoch(0))[i]; } //convert to JPL unit format .... (check mgadsm) m_leg1.asteroid.keplerian[0] /= ASTRO_AU; m_leg2.asteroid.keplerian[0] /= ASTRO_AU; for (int i = 2;i<6;++i) { m_leg1.asteroid.keplerian[i] *= ASTRO_RAD2DEG; m_leg2.asteroid.keplerian[i] *= ASTRO_RAD2DEG; } m_leg1.asteroid.epoch = ::kep_toolbox::mjd20002mjd(0); m_leg2.asteroid.epoch = ::kep_toolbox::mjd20002mjd(0); }
/** * This setter changes the problem bounds as to define a minimum and a maximum allowed total time of flight * * @param[in] tof vector of times of flight */ void mga_incipit_cstrs::set_tof(const std::vector<std::vector<double> >& tof) { if (tof.size() != (m_seq.size())) { pagmo_throw(value_error,"The time-of-flight vector (tof) has the wrong length"); } m_tof = tof; for (size_t i=0; i< m_seq.size(); ++i) { set_bounds(3+4*i,tof[i][0],tof[i][1]); } }
template <typename FT> void EnumerationDyn<FT>::process_solution(enumf newmaxdist) { FPLLL_TRACE("Sol dist: " << newmaxdist << " (nodes:" << nodes << ")"); for (int j = 0; j < d; ++j) fx[j] = x[j]; _evaluator.eval_sol(fx, newmaxdist, maxdist); set_bounds(); }
/** * Will construct the tension compression string problem * */ tens_comp_string::tens_comp_string():base(3,0,1,4,4,__constraint_tolerances__(4,4)) { // initialize best solution initialize_best(); // set the bounds for the current problem const double lb[] = {0.05,0.25,2.}; const double ub[] = {2.,1.3,15.}; set_bounds(lb,ub); }
H264_BYTESTREAM::H264_BYTESTREAM(common::Data32&& data) : _this(new _H264_BYTESTREAM(move(data))) { CHECK(data.count()); if (_this->finish_initialization()) { set_bounds(0, (uint32_t)_this->samples.size()); } else { _this->sps_pps.reset(NULL); THROW_IF(true, Uninitialized); } }
/** * Will construct the welded beam problem * */ welded_beam::welded_beam():base(4,0,1,7,7,__constraint_tolerances__(7,7)) { // initialize best solution initialize_best(); // set the bounds for the current problem const double lb[] = {0.1,0.1,0.1,0.1}; const double ub[] = {2.,10.,10.,2.}; set_bounds(lb,ub); }
local void upward_pass(kdxptr kd, int cell) { kdnode *ntab = kd->ntab; if (ntab[cell].dim != -1) { // not a terminal node? upward_pass(kd, Lower(cell)); upward_pass(kd, Upper(cell)); combine_nodes(&ntab[cell], &ntab[Lower(cell)], &ntab[Upper(cell)]); } else // scan bodies in node set_bounds(&ntab[cell].bnd, kd->bptr, ntab[cell].first, ntab[cell].last); }
/// Copy Constructor. Performs a deep copy mga_incipit_cstrs::mga_incipit_cstrs(const mga_incipit_cstrs &p) : base(p.get_dimension(),p.get_i_dimension(),p.get_f_dimension(),p.get_c_dimension(),p.get_ic_dimension(),p.get_c_tol()), m_tof(p.m_tof), m_tmax(p.m_tmax), m_dmin(p.m_dmin) { for (std::vector<kep_toolbox::planets::planet_ptr>::size_type i = 0; i < p.m_seq.size();++i) { m_seq.push_back(p.m_seq[i]->clone()); } set_bounds(p.get_lb(),p.get_ub()); }
/** * Instantiates the rosetta problem*/ sagas::sagas():base(12), problem(time2AUs,sequence,3,0,0,0,0,0) { //Setting the objective parameters problem.AUdist = 50.0; problem.DVtotal = 6.782; problem.DVonboard = 1.782; const double lb[12] = {7000, 0, 0, 0, 50, 300, 0.01, 0.01, 1.05, 8, -M_PI, -M_PI}; const double ub[12] = {9100, 7, 1, 1, 2000, 2000, 0.9, 0.9 ,7 ,500 ,M_PI,M_PI}; set_bounds(lb,lb+12,ub,ub+12); }
long __declspec(dllexport) WINAPI _set_bounds(lprec *lp, long column, double lower, double upper) { long ret; if (lp != NULL) { freebuferror(); ret = set_bounds(lp, column, lower, upper); } else ret = 0; return(ret); }
/** * Instantiates one of the possible TandEM problems * \param[in] probid This is an integer number from 1 to 24 encoding the fly-by sequence to be used (default is EVEES). Check http://www.esa.int/gsp/ACT/inf/op/globopt/TandEM.htm for more information * \param[in] tof_ (in years) This is a number setting the constraint on the total time of flight (10 from the GTOP database). If -1 (default) an unconstrained problem is instantiated */ tandem::tandem(const int probid, const double tof_):base(18), problem(orbit_insertion,sequence,5,0,0,0,0.98531407996358,80330.0), tof(tof_),copy_of_x(18) { if (probid < 1 || probid > 24) { pagmo_throw(value_error,"probid needs to be an integer in [1,24]"); } if (tof_ > 20 && tof_ <5 && tof_!=-1) { pagmo_throw(value_error,"time of flight constraint needs to be a number in [5,20] (years)"); } for (int i =0; i<5; i++) { problem.sequence[i] = Data[probid-1][i]; } const double lbunc[18] = {5475, 2.50001, 0, 0, 20 , 20 , 20 , 20 , 0.01, 0.01, 0.01, 0.01, 1.05, 1.05, 1.05, -M_PI, -M_PI, -M_PI}; const double ubunc[18] = {9132, 4.9, 1, 1, 2500 , 2500, 2500, 2500, 0.99, 0.99, 0.99, 0.99, 10, 10, 10, M_PI, M_PI, M_PI}; const double lbcon[18] = {5475, 2.50001, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 1.05, 1.05, 1.05, -M_PI, -M_PI, -M_PI}; const double ubcon[18] = {9132, 4.9, 0.99, 0.99, 0.99, 0.99, 0.99, 0.99, 0.99, 0.99, 0.99, 0.99, 10, 10, 10, M_PI, M_PI, M_PI}; if (tof_==-1) set_bounds(lbunc,lbunc+18,ubunc,ubunc+18); else set_bounds(lbcon,lbcon+18,ubcon,ubcon+18); }
/** * Constructs a global optimization problem (box-bounded, continuous) representing an interplanetary trajectory modelled * as a Multiple Gravity Assist trajectory that allows one only Deep Space Manouvre between each leg. * * @param[in] seq std::vector of kep_toolbox::planet_ptr containing the encounter sequence for the trajectoty (including the initial planet) * @param[in] t0_l kep_toolbox::epoch representing the lower bound for the launch epoch * @param[in] t0_u kep_toolbox::epoch representing the upper bound for the launch epoch * @param[in] tof time-of-flight vector containing lower and upper bounds (in days) for the various legs time of flights * @param[in] Tmax maximum time of flight * @param[in] Dmin minimum distance from Jupiter (for radiation protection) * * @throws value_error if the planets in seq do not all have the same central body gravitational constant * @throws value_error if tof has a size different from seq.size() */ mga_incipit_cstrs::mga_incipit_cstrs( const std::vector<kep_toolbox::planets::planet_ptr> seq, const kep_toolbox::epoch t0_l, const kep_toolbox::epoch t0_u, const std::vector<std::vector<double> > tof, double Tmax, double Dmin) : base(4*seq.size(),0,1,2,2,1E-3), m_tof(tof), m_tmax(Tmax), m_dmin(Dmin) { // We check that all planets have equal central body std::vector<double> mus(seq.size()); for (std::vector<kep_toolbox::planets::planet_ptr>::size_type i = 0; i< seq.size(); ++i) { mus[i] = seq[i]->get_mu_central_body(); } if ((unsigned int)std::count(mus.begin(), mus.end(), mus[0]) != mus.size()) { pagmo_throw(value_error,"The planets do not all have the same mu_central_body"); } // We check the consistency of the time of flights if (tof.size() != seq.size()) { pagmo_throw(value_error,"The time-of-flight vector (tof) has the wrong length"); } for (size_t i = 0; i < tof.size(); ++i) { if (tof[i].size()!=2) pagmo_throw(value_error,"Each element of the time-of-flight vector (tof) needs to have dimension 2 (lower and upper bound)"); } // Filling in the planetary sequence data member. This requires to construct the polymorphic planets via their clone method for (std::vector<kep_toolbox::planets::planet_ptr>::size_type i = 0; i < seq.size(); ++i) { m_seq.push_back(seq[i]->clone()); } // Now setting the problem bounds size_type dim(4*m_tof.size()); decision_vector lb(dim), ub(dim); // First leg lb[0] = t0_l.mjd2000(); ub[0] = t0_u.mjd2000(); lb[1] = 0; lb[2] = 0; ub[1] = 1; ub[2] = 1; lb[3] = m_tof[0][0]; ub[3] = m_tof[0][1]; // Successive legs for (std::vector<kep_toolbox::planets::planet_ptr>::size_type i = 1; i < m_tof.size(); ++i) { lb[4*i] = - 2 * boost::math::constants::pi<double>(); ub[4*i] = 2 * boost::math::constants::pi<double>(); lb[4*i+1] = 1.1; ub[4*i+1] = 30; lb[4*i+2] = 1e-5; ub[4*i+2] = 1-1e-5; lb[4*i+3] = m_tof[i][0]; ub[4*i+3] = m_tof[i][1]; } // Adjusting the minimum and maximum allowed fly-by rp to the one defined in the kep_toolbox::planet class for (std::vector<kep_toolbox::planets::planet_ptr>::size_type i = 0; i < m_tof.size()-1; ++i) { lb[4*i+5] = m_seq[i]->get_safe_radius() / m_seq[i]->get_radius(); ub[4*i+5] = (m_seq[i]->get_radius() + 2000000) / m_seq[i]->get_radius(); //from gtoc6 problem description } set_bounds(lb,ub); }
void rotated::configure_new_bounds() { for(base::size_type i = 0; i < get_lb().size(); i++){ double mean_t = (m_original_problem->get_ub()[i] + m_original_problem->get_lb()[i]) / 2; double spread_t = m_original_problem->get_ub()[i] - m_original_problem->get_lb()[i]; // careful, if zero needs to be acounted for later m_normalize_translation.push_back(mean_t); // Center to origin m_normalize_scale.push_back(spread_t/2); // Scale to [-1, 1] centered at origin } // Expand the box to cover the whole original search space. We may here call directly // the set_bounds(const double &, const double &) as all dimensions are now equal set_bounds(-sqrt(2), sqrt(2)); }
PCM::PCM(const functional::Audio<Sample>& track) : functional::DirectAudio<PCM, sound::Sound>(), _this(new _PCM(track.settings())) { THROW_IF(!track(0).keyframe, InvalidArguments); THROW_IF(track.count() >= security::kMaxSampleCount, Unsafe); _settings = (settings::Audio) { settings::Audio::Codec::Unknown, track.settings().timescale, track.settings().sample_rate, track.settings().channels, 0, }; _this->init(track); set_bounds(0, (uint32_t)_this->sound_to_sample_mapping.size()); }
earth_planet::earth_planet(int segments, std::string target, const double &ctol) : base(base_format(1,segments,1000).size(), 0, 1, 6 + segments + 1 +1, segments+2,ctol), encoding(1,segments,1000), vmax(3000),n_segments(segments) { std::vector<double> lb_v(get_dimension()); std::vector<double> ub_v(get_dimension()); //Start lb_v[encoding.leg_start_epoch_i(0)[0]] = 0; ub_v[encoding.leg_start_epoch_i(0)[0]] = 1000; //End lb_v[encoding.leg_end_epoch_i(0)[0]] = 500; ub_v[encoding.leg_end_epoch_i(0)[0]] = 1500; //Start Velocity std::vector<int> tmp = encoding.leg_start_velocity_i(0); for (std::vector<int>::size_type i = 0; i < tmp.size() ; ++i) { lb_v[tmp[i]] = -3; ub_v[tmp[i]] = 3; } //End Velocity tmp = encoding.leg_end_velocity_i(0); for (std::vector<int>::size_type i = 0; i < tmp.size() ; ++i) { lb_v[tmp[i]] = 0; ub_v[tmp[i]] = 0; } //I Throttles for (int j = 0; j<encoding.n_segments(0); ++j) { tmp = encoding.segment_thrust_i(0,j); for (std::vector<int>::size_type i = 0; i < tmp.size() ; ++i) { lb_v[tmp[i]] = -1; ub_v[tmp[i]] = 1; } } set_bounds(lb_v,ub_v); //traj_fb constructor std::vector<planet_ptr> sequence; sequence.push_back(planet_ptr(new planet_ss("earth"))); sequence.push_back(planet_ptr(new planet_ss(target))); trajectory = fb_traj(sequence,segments,1000,0.05,boost::numeric::bounds<double>::highest()); }