/// <summary> /// Fix the constants in the equations representing the edit constraints. /// </summary> /// <remarks> /// Each of the non-required edits will be represented by an equation /// of the form: /// v = c + eplus - eminus /// where v is the variable with the edit, c is the previous edit value, /// and eplus and eminus are slack variables that hold the error in /// satisfying the edit constraint. We are about to change something, /// and we want to fix the constants in the equations representing /// the edit constraints. If one of eplus and eminus is basic, the other /// must occur only in the expression for that basic error variable. /// (They can't both be basic.) Fix the constant in this expression. /// Otherwise they are both non-basic. Find all of the expressions /// in which they occur, and fix the constants in those. See the /// UIST paper for details. /// (This comment was for ResetEditConstants(), but that is now /// gone since it was part of the screwey vector-based interface /// to resolveing. --02/16/99 gjb) /// </remarks> protected void DeltaEditConstant(double delta, ClAbstractVariable plusErrorVar, ClAbstractVariable minusErrorVar) { ClLinearExpression exprPlus = RowExpression(plusErrorVar); if (exprPlus != null) { exprPlus.IncrementConstant(delta); if (exprPlus.Constant < 0.0) { InfeasibleRows.Add(plusErrorVar); } return; } ClLinearExpression exprMinus = RowExpression(minusErrorVar); if (exprMinus != null) { exprMinus.IncrementConstant(-delta); if (exprMinus.Constant < 0.0) { InfeasibleRows.Add(minusErrorVar); } return; } var columnVars = Columns[minusErrorVar]; foreach (ClAbstractVariable basicVar in columnVars) { ClLinearExpression expr = RowExpression(basicVar); //Assert(expr != null, "expr != null"); double c = expr.CoefficientFor(minusErrorVar); expr.IncrementConstant(c * delta); if (basicVar.IsRestricted && expr.Constant < 0.0) { InfeasibleRows.Add(basicVar); } } }
/// <summary> /// Replace all occurrences of oldVar with expr, and update column cross indices /// oldVar should now be a basic variable. /// </summary> protected void SubstituteOut(ClAbstractVariable oldVar, ClLinearExpression expr) { var varset = _columns[oldVar]; foreach (var v in varset) { var row = _rows[v]; row.SubstituteOut(oldVar, expr, v, this); if (v.IsRestricted && row.Constant < 0.0) { InfeasibleRows.Add(v); } } if (oldVar.IsExternal) { ExternalRows.Add((ClVariable)oldVar); ExternalParametricVars.Remove((ClVariable)oldVar); } _columns.Remove(oldVar); }