struct state simulate_with_controller(struct state init_state, double time){ struct state state_x; state_x = init_state; int steps = time/SIM_STEP; struct controller_storage cs; cs.int_elevation = 0; cs.int_pitch = 0; cs.int_travel = 0; int k = 0; for (k = 0; k <steps; k++){ struct command U = controller_safety(sps, state_x, &cs); state_x = eval_state(state_x, U); if ( check_safety(state_x) == 0){ state_x.safe = 0; printf("sim2 nsafe: elevation: %lf, pitch: %lf, travel: %lf, d_elevation: %lf, d_pitch: %lf, d_travel: %lf\n", state_x.elevation, state_x.pitch, state_x.travel, state_x.d_elevation, state_x.d_pitch, state_x.d_travel); return state_x; } } state_x.safe = 1; printf("sim2 safe: elevation: %lf, pitch: %lf, travel: %lf, d_elevation: %lf, d_pitch: %lf, d_travel: %lf\n", state_x.elevation, state_x.pitch, state_x.travel, state_x.d_elevation, state_x.d_pitch, state_x.d_travel); return state_x; }
struct state simulate_fixed_control(struct state init_state, struct command U, double time){ struct state state_x; state_x = init_state; printf("comm u1:%lf u2:%lf\n", U.u1, U.u2); printf("sim1 init: elevation: %lf, pitch: %lf, travel: %lf, d_elevation: %lf, d_pitch: %lf, d_travel: %lf\n", init_state.elevation, init_state.pitch, init_state.travel, init_state.d_elevation, init_state.d_pitch, init_state.d_travel); int steps = time/SIM_STEP; int k = 0; for (k = 0; k <steps; k++){ state_x = eval_state(state_x, U); if(check_safety(state_x) == 0) { state_x.safe = 0; printf("sim1 nsafe: elevation: %lf, pitch: %lf, travel: %lf, d_elevation: %lf, d_pitch: %lf, d_travel: %lf, step: %d, tot_steps: %d\n", state_x.elevation, state_x.pitch, state_x.travel, state_x.d_elevation, state_x.d_pitch, state_x.d_travel, k , steps); return state_x; } } state_x.safe = 1; printf("sim1 safe: elevation: %lf, pitch: %lf, travel: %lf, d_elevation: %lf, d_pitch: %lf, d_travel: %lf\n", state_x.elevation, state_x.pitch, state_x.travel, state_x.d_elevation, state_x.d_pitch, state_x.d_travel); return state_x; }
G_MODULE_EXPORT void on_indep_var1_entry_editing_done(GtkEntry *cell_editable, gpointer user_data) { TableData *data = (TableData *) user_data; int code; status_bar_update (READY, data); code = eval_state (data); if (code==DOMAIN_ERROR) reset_table (data); status_bar_update (code, data); }
s3_cfg_state_t * s3_cfg_input_term(s3_cfg_t *_cfg, s3_cfg_state_t *_cur, s3_cfg_id_t _term) { int index; s3_cfg_state_t *state = NULL; assert(_cfg != NULL); index = s3_cfg_id2index(_term); state = (s3_cfg_state_t *)s3_arraylist_get(&_cur->expansions, index); if (state == NULL) return NULL; if (state->num_expanded == -1) eval_state(_cfg, state); return state; }
s3_cfg_state_t * s3_cfg_create_parse(s3_cfg_t *_cfg) { s3_cfg_state_t *state = NULL; s3_cfg_rule_t *rule = NULL; assert(_cfg != NULL); add_state(_cfg, NULL, S3_CFG_NIL_ITEM); /* to initialize the parser, we need to create the root state and add to * it the starting entry using the pseudo start rule * * 0.0 $PSTART -> $START #EOR# */ rule = s3_arraylist_get(&_cfg->rules, 0); add_entry(state, rule, 0, 0, rule->log_score, NULL, NULL); eval_state(_cfg, state); return state; }
Gamevalue solver(Gamestate s){ Gamevalue v, vmax; Plays plays; Hands p; /* a play */ Gamestate ns; int i; if(is_leaf(s)) return eval_state(s); vmax = gamevalue_zero(s.playernum); plays = plays_makecanonicals(s); for(i=0; i<plays.n; i++){ /* for each plays */ p = plays_getplay(plays, i); ns = next_state(s, p); v = solver(ns); vmax = gamevalue_merge(v, vmax); i++; } return vmax; }
processed_transaction database::push_proposal(const proposal_object& proposal) { try { transaction_evaluation_state eval_state(this); eval_state._is_proposed_trx = true; eval_state.operation_results.reserve(proposal.proposed_transaction.operations.size()); processed_transaction ptrx(proposal.proposed_transaction); eval_state._trx = &ptrx; size_t old_applied_ops_size = _applied_ops.size(); try { auto session = _undo_db.start_undo_session(true); for( auto& op : proposal.proposed_transaction.operations ) eval_state.operation_results.emplace_back(apply_operation(eval_state, op)); remove(proposal); session.merge(); } catch ( const fc::exception& e ) { if( head_block_time() <= HARDFORK_483_TIME ) { for( size_t i=old_applied_ops_size,n=_applied_ops.size(); i<n; i++ ) { ilog( "removing failed operation from applied_ops: ${op}", ("op", *(_applied_ops[i])) ); _applied_ops[i].reset(); } } else { _applied_ops.resize( old_applied_ops_size ); } elog( "e", ("e",e.to_detail_string() ) ); throw; } ptrx.operation_results = std::move(eval_state.operation_results); return ptrx; } FC_CAPTURE_AND_RETHROW( (proposal) ) }
processed_transaction database::_apply_transaction(const signed_transaction& trx) { try { uint32_t skip = get_node_properties().skip_flags; if( true || !(skip&skip_validate) ) /* issue #505 explains why this skip_flag is disabled */ trx.validate(); auto& trx_idx = get_mutable_index_type<transaction_index>(); const chain_id_type& chain_id = get_chain_id(); auto trx_id = trx.id(); FC_ASSERT( (skip & skip_transaction_dupe_check) || trx_idx.indices().get<by_trx_id>().find(trx_id) == trx_idx.indices().get<by_trx_id>().end() ); transaction_evaluation_state eval_state(this); const chain_parameters& chain_parameters = get_global_properties().parameters; eval_state._trx = &trx; if( !(skip & (skip_transaction_signatures | skip_authority_check) ) ) { auto get_active = [&]( account_id_type id ) { return &id(*this).active; }; auto get_owner = [&]( account_id_type id ) { return &id(*this).owner; }; trx.verify_authority( chain_id, get_active, get_owner, get_global_properties().parameters.max_authority_depth ); } //Skip all manner of expiration and TaPoS checking if we're on block 1; It's impossible that the transaction is //expired, and TaPoS makes no sense as no blocks exist. if( BOOST_LIKELY(head_block_num() > 0) ) { if( !(skip & skip_tapos_check) ) { const auto& tapos_block_summary = block_summary_id_type( trx.ref_block_num )(*this); //Verify TaPoS block summary has correct ID prefix, and that this block's time is not past the expiration FC_ASSERT( trx.ref_block_prefix == tapos_block_summary.block_id._hash[1] ); } fc::time_point_sec now = head_block_time(); FC_ASSERT( trx.expiration <= now + chain_parameters.maximum_time_until_expiration, "", ("trx.expiration",trx.expiration)("now",now)("max_til_exp",chain_parameters.maximum_time_until_expiration)); FC_ASSERT( now <= trx.expiration, "", ("now",now)("trx.exp",trx.expiration) ); } //Insert transaction into unique transactions database. if( !(skip & skip_transaction_dupe_check) ) { create<transaction_object>([&](transaction_object& transaction) { transaction.trx_id = trx_id; transaction.trx = trx; }); } eval_state.operation_results.reserve(trx.operations.size()); //Finally process the operations processed_transaction ptrx(trx); _current_op_in_trx = 0; for( const auto& op : ptrx.operations ) { eval_state.operation_results.emplace_back(apply_operation(eval_state, op)); ++_current_op_in_trx; } ptrx.operation_results = std::move(eval_state.operation_results); //Make sure the temp account has no non-zero balances const auto& index = get_index_type<account_balance_index>().indices().get<by_account_asset>(); auto range = index.equal_range( boost::make_tuple( GRAPHENE_TEMP_ACCOUNT ) ); std::for_each(range.first, range.second, [](const account_balance_object& b) { FC_ASSERT(b.balance == 0); }); return ptrx; } FC_CAPTURE_AND_RETHROW( (trx) ) }