コード例 #1
0
        public FRealCurve?FindCurve(FName rowName, bool bWarnIfNotFound = true)
        {
            if (rowName.IsNone)
            {
                if (bWarnIfNotFound)
                {
                    Log.Warning("UCurveTable::FindCurve : NAME_None is invalid row name for CurveTable '{0}'.", GetPathName());
                }
                return(null);
            }

            if (!RowMap.TryGetValue(rowName, out var foundCurve))
            {
                if (bWarnIfNotFound)
                {
                    Log.Warning("UCurveTable::FindCurve : Row '{0}' not found in CurveTable '{1}'.", rowName.ToString(), GetPathName());
                }
                return(null);
            }

            return(CurveTableMode switch
            {
                ECurveTableMode.SimpleCurves => new FSimpleCurve(foundCurve),
                ECurveTableMode.RichCurves => new FRichCurve(foundCurve),
                _ => null
            });
コード例 #2
0
ファイル: CellMap.cs プロジェクト: zhoujit/koogra
        internal OXCell GetCell(uint row, uint col)
        {
            OXCell ret = null;

            ColMap cols;

            if (_rows.TryGetValue(row, out cols))
            {
                cols.TryGetValue(col, out ret);
            }

            return(ret);
        }
コード例 #3
0
        public object[] AddData(object[] values)
        {
            if (Parent != null)
            {
                if (Parent.CurrentRow == null)
                {
                    throw new InvalidOperationException("Row cannot be added when parent table has no current row");
                }

                foreach (var pk in _parentReferenceIndices)
                {
                    values[pk.Value] = Parent.CurrentRow[pk.Key];
                }
            }

            if (HashKey.HasValue)
            {
                values[HashKey.Value] = KeyFactory.CalculateKey(HashIndices.Select(ix => values[ix]));
            }


            //Facts with scope unique values (e.g. count only one visit for pages visited multiple times in a visit)
            foreach (var f in Schema.Facts)
            {
                var defered = values[f.Index] as IDeferedValue;
                if (defered != null)
                {
                    values[f.Index] = defered.GetValue(this, f, values);
                }
            }

            object[] row;
            if (RowMap.TryGetValue(values, out row))
            {
                MergeFacts(row, values);
            }
            else
            {
                RowMap.Add(values, row = values);
                ++RowsCreated;
            }

            return(row);
        }
コード例 #4
0
	/* Suggest a value for the given edit variable.

	This method should be used after an edit variable as been added to
	the solver in order to suggest the value for that variable.

	Throws
	------
	UnknownEditVariable
		The given edit variable has not been added to the solver.

	*/
	public void suggestValue(  Variable variable, double value )
	{
        if(!m_edits.ContainsKey(variable))
          throw new System.ArgumentException("UnknownEditVariable", "SolverImpl");


		//DualOptimizeGuard guard( *this );
		EditInfo info = m_edits[variable];
		double delta = value - info.constant;
		info.constant = value;

		// Check first if the positive error variable is basic.
	  Row trial;
		if( m_rows.TryGetValue(info.tag.marker,out trial) )
		{
			if( trial.add( -delta ) < 0.0 )
				m_infeasible_rows.Add(info.tag.marker );
            dualOptimize();
			return;
		}

		// Check next if the negative error variable is basic.
		if( m_rows.TryGetValue(info.tag.other,out trial)  )
		{
			if( trial.add( delta ) < 0.0 )
				m_infeasible_rows.Add( info.tag.other  );
               dualOptimize();
			return;
		}
        // Otherwise update each row where the error variables exist.
        foreach(KeyValuePair<Symbol,Row> r in m_rows)
        {
          double coeff = r.Value.coefficientFor( info.tag.marker );
         if( coeff != 0.0 &&
				r.Value.add( delta * coeff ) < 0.0 &&
				r.Key.type() != Symbol.Type.External )
				m_infeasible_rows.Add(r.Key );
        }
		dualOptimize();
	}