本文整理汇总了C++中state::domain方法的典型用法代码示例。如果您正苦于以下问题:C++ state::domain方法的具体用法?C++ state::domain怎么用?C++ state::domain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类state
的用法示例。
在下文中一共展示了state::domain方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: zero
typename traj_simu<scalar_type>::state_jump_results traj_simu<scalar_type>::state_jump_intervals_derivative(
const state_functor & f, const state_matrix_functor & Jac,
const state & xinit, scalar_type tinit, scalar_type tmax,
std::vector<typename lin_constraint_system::const_ptr> & guards,
typename lin_constraint_system::const_ptr orig_invariant) const {
// reorder_state_functor<scalar_type> f= reorder_state_functor<scalar_type>(f_i)
assert(xinit.domain()==f.map(xinit).domain());
using namespace math;
using namespace numeric;
unsigned int gn = guards.size();
state_jump_results res;
scalar_type tdeb_k[gn]; //if jump_ok[i] then tdeb_k[i] time the root occurred
unsigned int tdeb_index[gn]; // GF: the index in the current trajectory?
bool jump_ok[gn]; //is the jump OK at current time ?
scalar_type xp; //scalar used for initialisation
state xinitprim;
scalar_type zero(0);
ode_solver solver;
// ---------------------------------------------------------------------
// prepare the affine maps corresponding to the root functions
// ---------------------------------------------------------------------
// every guard consists of a set of constraints.
// every constraint is considered a root function.
// the state is in the guard if all root functions are nonpositive.
// z_map[0] is the invariant
// z_map[1] ... z_map[gn] are the guards
std::vector<typename affine_map::const_ptr> z_map(gn + 1);
// @todo choose a domain for the solver and stick with it (use it everywhere)
// current : domain of xinit chosen.
// to bring lin_constraint_system to domain of solver
// + convert to affine map form for functor
matrix<scalar_type> A;
vector<scalar_type> b;
positional_vdomain dom;
positional_vdomain codom;
// Note: The canonic matrix form is Ax<=b, to the associated root function
// must be the affine map Ax-b==0.
lin_constraint_system invariant(*orig_invariant);
invariant.reorder(xinit.domain());
canonic_matrix_form(A, b, dom, invariant);
codom = positional_vdomain();
for (int k = 0; k < invariant.size(); k++)
codom.add_variable(variable("traj_simu_dummy" + to_string(k)));
z_map[0] = typename affine_map::ptr(
new affine_map(vdom_matrix<scalar_type> (codom, dom, A),
state(codom, -b)));
// Reorder the guard constraints and prepare the root functions
for (int i = 0; i < gn; i++) {
typename lin_constraint_system::ptr reordered_guard =
typename lin_constraint_system::ptr(
new lin_constraint_system(*(guards[i])));
reordered_guard->reorder(xinit.domain());
guards[i] = reordered_guard;
canonic_matrix_form(A, b, dom, *(guards[i]));
codom = positional_vdomain();
for (int k = 0; k < guards[i]->size(); k++)
codom.add_variable(variable("traj_simu_dummy" + to_string(k)));
z_map[i + 1] = typename affine_map::ptr(
new affine_map(vdom_matrix<scalar_type> (codom, dom, A),
state(codom, -b)));
}
// ---------------------------------------------------------------------
// checking invariant + which guard is satified and which is'nt.
// guards are assumed of the form ax<=b (calcul = ax - b<=O)
// verification of invariant
bool invariant_satisfied = true;
bool invariant_atomic = false;
// Check for each constraint in the invariant whether it is satisfied or not
for (typename lin_constraint_system::const_iterator it = invariant.begin(); invariant_satisfied
&& it != invariant.end(); ++it) {
// Check whether x violates the constraint or is on the border
xp = it->normal_eval(xinit);
// For better numerics, don't compare xp to zero, but
// xp-inh_coeff to -inh_coeff. That way we take into account the relative error
scalar_type inh_coeff = it->get_canonic_inh_coeff();
if (definitely(is_GT(xp, -inh_coeff))) {
// The invariant constraint is violated.
LOGGER_OS(DEBUG7,"state_jump_intervals_safe")
<< "inv violated with " << xp << " > " << -inh_coeff;
invariant_satisfied = false;
} else if (!definitely(is_LT(xp, -inh_coeff))) {
// The invariant constraint is on the border.
// Check the derivative to see the whether the invariant function is increasing or decreasing.
// The derivative is f(x). If a^Tf(x)>0, then the function is increasing, and so the invariant is atomic.
scalar_type dxp = it->normal_eval(f.map(xinit));
//.........这里部分代码省略.........