solveStepBruteForce

Method of continuousTimeMdss.

Solve the algebraic mode problem of a hybrid mdss model at a fixed state and input.

Source: src/simulator/@continuousTimeMdss/solveStepBruteForce.m

What is solved

At fixed state x0x_0 and input uu, find the state derivatives ẋ\dot x, algebraic signals yy and binaries zz that satisfy

F=Φeqm(ẋ,x0,u,y,z)=0,G=Φineqm(ẋ,x0,u,y,z)0, F = \Phi_{\mathrm{eq}}\, m(\dot x, x_0, u, y, z) = 0, \qquad G = \Phi_{\mathrm{ineq}}\, m(\dot x, x_0, u, y, z) \le 0 ,

where Φ=Φc+Φ+1Φ1\Phi = \Phi_c + \Phi_{+1} - \Phi_{-1} is the parameter-matrix split.

The monomial vector mm

mRm\in\mathbb R^{R} has one entry per monomial (one per column of the structure matrix). Each entry is a product of one factor per signal:

mk=nφ(tnk,fnk,cnk;vn), m_k \;=\; \prod_{n} \varphi\!\big(t_{nk}, f_{nk}, c_{nk};\, v_n\big),

so the residual F=ΦeqmF=\Phi_{\mathrm{eq}}m is just a weighted sum of those monomials. The solver never forms mm from scratch — it starts at m=𝟏m=\mathbf 1 and, each time one signal’s value vnv_n becomes known, multiplies that signal’s factor into every column at once (the \odot is elementwise over the RR columns):

mm(1+tnfn+tn(v1)fnv)true/false part(1|cn|+cnv)continuous part. m \;\leftarrow\; m \;\odot\; \underbrace{\big(1 + t_n f_n + t_n(v-1) - f_n v\big)}_{\text{true/false part}}\;\odot\;\underbrace{\big(1 - |c_n| + c_n v\big)}_{\text{continuous part}} .

What one factor evaluates to

For a single column, the entries tn,fn,cnt_n, f_n, c_n say how signal nn enters that monomial, and the factor collapses to:

structure entry in that column meaning factor value
tn=1t_n = 1 (true) signal appears as vv vv
fn=1f_n = 1 (false) signal appears as its complement 1v1 - v
tn=fn=cn=0t_n = f_n = c_n = 0 signal absent from this monomial 11 (column unchanged)
cn0c_n \neq 0 (continuous) scaled/normalized entry 1|cn|+cnv1 - \lvert c_n\rvert + c_n v

So substituting a value only touches the columns where that signal is present; absent columns are multiplied by 11 and stay as they are.

Example. Take two states x1,x2x_1, x_2 and a monomial x1x2x_1 x_2 (both appear as true). Its column starts at 11. Folding in x1=0.5x_1 = 0.5 multiplies it by 0.50.5; folding in x2=4x_2 = 4 multiplies it by 44; the column now equals 0.54=2=x1x20.5\cdot 4 = 2 = x_1 x_2. A different column that does not contain x1x_1 is multiplied by 11 when x1x_1 is substituted and is left untouched. Once every signal has been folded in, each mkm_k holds the numeric value of its monomial.

Algorithm

The known x0x_0 and uu are folded into mm first. The routine then walks the solving order. Each row is one of three cases.

Explicit continuous unknown (ẋn\dot x_n or yny_n): its equation ee is affine in that single unknown, Fe=Av+BF_e = A\,v + B, so

v=BA,A=Φe[(tnfn+cn)m],B=Φe[(1|cn+tnfntn|)m], v = -\frac{B}{A},\quad A=\Phi_e\!\left[(t_n-f_n+c_n)\odot m\right],\quad B=\Phi_e\!\left[\big(1-|c_n+t_nf_n-t_n|\big)\odot m\right],

and vv is folded into mm.

Explicit binary znz_n: evaluate its equation value at the previous value zn0z_n^0 and flip on a positive value,

F0=Φem|zn=zn0,zn={zn0,sign(F0)0,¬zn0,otherwise. F_0 = \Phi_e\, m\big|_{z_n=z_n^0},\qquad z_n = \begin{cases} z_n^0, & \operatorname{sign}(F_0)\le 0,\\[2pt] \lnot\, z_n^0, & \text{otherwise.}\end{cases}

Coupled subproblem: delegated to solveSubProblemVariableZ, which enumerates the block’s binaries while solving its continuous unknowns.

After the whole order is processed, F=ΦeqmF=\Phi_{\mathrm{eq}}m and G=ΦineqmG=\Phi_{\mathrm{ineq}}m are returned.

Inputs / outputs

[xp, y, z, F, G] = solveStepBruteForce(sys, x0, u, solvingOrder, yguess, xpguess, zguess) — returns the state-derivative row xp (ẋ\dot x), algebraic row y, binary row z, and the equality/inequality function-value rows F, G.

See also

continuousTimeMdss · solveSubProblemVariableZ · eventTotalDerivative · msim


MyToolbox Documentation | Generated automatically by CI/CD pipeline