solveSubProblemVariableZ

Method of continuousTimeMdss.

Solve one coupled subproblem for its continuous unknowns and its binary signals.

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

What is solved

A coupled subproblem is a block of equations from the solving order that cannot be solved one variable at a time and must be solved jointly. Its unknowns are some continuous signals w=[ẋs;ys]w=[\dot x_s;\, y_s] (state derivatives and algebraic variables) and some binary signals zsz_s. Let

nz=the number of binary signals in this subproblem. n_z = \text{the number of binary signals in this subproblem.}

The block must satisfy its equality rows and stay inequality-feasible:

Fs=Φeq,sm(w,zs)=0,Gs=Φineq,sm(w,zs)0, F_s = \Phi_{\mathrm{eq},s}\, m(w, z_s) = 0, \qquad G_s = \Phi_{\mathrm{ineq},s}\, m(w, z_s) \le 0,

where Φ=Φc+Φ+1Φ1\Phi=\Phi_c+\Phi_{+1}-\Phi_{-1} is the parameter-matrix split and mm is the norm-1 monomial vector — the running product obtained by folding each known signal value into the columns of the structure matrix (the update rule is described on solveStepBruteForce).

Algorithm

Each binary can only be 00 or 11, so there are 2nz2^{n_z} possible binary vectors. The method enumerates all of them, ordered by ascending Hamming distance to the current zz (the vector closest to the incumbent — fewest switched bits — is tried first, because a mode usually changes as little as possible):

z(k){0,1}nz,k=1,,2nz. z^{(k)} \in \{0,1\}^{n_z},\qquad k = 1,\dots,2^{n_z}.

For each candidate z(k)z^{(k)}:

1. Fold z(k)z^{(k)} into mm (the binaries are now known), which leaves a continuous-only solve for ww.

2. Solve the block’s equality rows Fs(w)=Φeq,sm(w)=0F_s(w)=\Phi_{\mathrm{eq},s}\,m(w)=0 for ww, according to the block’s type flag.

Linear (type = -1): FsF_s is affine in ww, Fs=Aw+bF_s = A\,w + b, solved by w=A1bw=-A^{-1}b, with

A:,j=Φeq,s[(tjfj+cj)m],b=Φeq,s[mj(1|cj|)(1tj)]. A_{:,j} = \Phi_{\mathrm{eq},s}\big[(t_j - f_j + c_j)\odot m\big], \qquad b = \Phi_{\mathrm{eq},s}\Big[m\odot\textstyle\prod_j (1-|c_j|)(1-t_j)\Big].

Nonlinear (type = 0): lsqnonlin (Levenberg–Marquardt) drives Fs(w)0F_s(w)\to 0 using the analytic product-rule Jacobian Fs/w\partial F_s/\partial w.

3. Check inequality feasibility. The candidate is accepted as soon as

maxi(Gs)i<ε, \max_i (G_s)_i < \sqrt{\varepsilon},

and its ẋs,ys,z(k)\dot x_s, y_s, z^{(k)} are written out.

(tj,fj,cjt_j, f_j, c_j are the true/false/continuous structure rows of unknown jj.) If no binary vector yields a feasible solution, a No Solution found warning is raised.

This method is called by solveStepBruteForce whenever a coupled subproblem contains binary signals.

Input arguments

Argument Description
sys The continuousTimeMdss simulation object (carries the mdss model and solver constants).
solvingOrderSubProblem The solving-order rows of this block [varIdx, eqIdx, type, subset, subproblem].
EqXUZ The running monomial vector mm, with all upstream blocks already folded in.
xpInit Initial values / guess for the block’s state derivatives.
yInit Initial values / guess for the block’s algebraic variables.
y0 Algebraic seed used to start the nonlinear solve.
zInit Current binary values (the reference for the nearest-first enumeration order).

Output arguments

Output Description
xp Solved state derivatives ẋs\dot x_s.
y Solved algebraic variables.
z The accepted binary combination.
G Inequality function values.
F Equality function values.
EqXUZ The monomial vector mm updated with the solved block.

See also

continuousTimeMdss · solveStepBruteForce · solveSubProblemFixZ · msim


MyToolbox Documentation | Generated automatically by CI/CD pipeline