public void Initialize(IGenomeDecoder<NeatGenome, IBlackBox> genomeDecoder, IMapClusteringDataset dataset, MapClusteringEvaluator evaluator, int nbClusters) { this.dataset = dataset; this.nbClusters = nbClusters; this.decoder = genomeDecoder; this.evaluator = evaluator; samples = dataset.GetSamplesMatrix(); outputs = new double[nbClusters, samples.GetLength(1), samples.GetLength(2)]; this.nbInputs = samples.GetLength(0); maxValue = 0.0; for (var i = 0; i < samples.GetLength(0); i++) { for (var j = 0; j < samples.GetLength(1); j++) { for (var k = 0; k < samples.GetLength(2); k++) { var value = samples[i, j, k]; if (value > maxValue) maxValue = value; } } } maxValue *= 2; // margin }
public override void Initialize(string name, XmlElement xmlConfig) { base.Initialize(name, xmlConfig); _dataset = CreateDataset(); _dataset.LoadFromFile(DatasetFileName); samples = _dataset.GetSamplesMatrix(); nbInputs = _dataset.InputCount; n = samples.GetLength(1); m = samples.GetLength(2); }
public MapClusteringView(IGenomeDecoder<NeatGenome, IBlackBox> genomeDecoder, IMapClusteringDataset dataset, MapClusteringEvaluator evaluator, int nbClusters) : this() { this.dataset = dataset; this.nbClusters = nbClusters; this.decoder = genomeDecoder; this.evaluator = evaluator; samples = dataset.GetSamplesMatrix(); outputs = new double[nbClusters, samples.GetLength(1), samples.GetLength(2)]; inputView.LabelName = "Input"; outputView.LabelName = "Output"; inputView.SetDimensions(samples.GetLength(0), samples.GetLength(1), samples.GetLength(2)); outputView.SetDimensions(nbClusters, samples.GetLength(1), samples.GetLength(2)); maxValue = 0.0; minValue = double.PositiveInfinity; for (var i = 0; i < samples.GetLength(0); i++) { for (var j = 0; j < samples.GetLength(1); j++) { for (var k = 0; k < samples.GetLength(2); k++) { var value = samples[i, j, k]; if (value > maxValue) maxValue = value; if (value < minValue) minValue = value; } } } // Add some margin maxValue *= 2; minValue *= 2; inputView.OnClusterChanged += (id) => { currentInputIdx = id; RefreshInput(); }; outputView.OnClusterChanged += (id) => { currentClusterIdx = id; RefreshOutput(); }; RefreshInput(); }
/// <summary> /// Construct evaluator with the provided task arguments/variables. /// </summary> public MapClusteringEvaluator(IMapClusteringDataset dataset, int nbClusters, Phenotype phenotype) { this.nbClusters = nbClusters; this.phenotype = phenotype; // Build input layers (samples matrices) nbInputs = dataset.InputCount; samples = dataset.GetSamplesMatrix(); // Extract useful values n = samples.GetLength(1); // layers width m = samples.GetLength(2); // layers height nbInputsNN = samples.Length; nbOutputsNN = nbClusters * n * m; }
/// <summary> /// Construct evaluator with the provided task arguments/variables. /// </summary> public WindowMapClusteringEvaluator(IMapClusteringDataset dataset, int nbClusters, Phenotype phenotype, bool[,] filter) { this.nbClusters = nbClusters; this.phenotype = phenotype; this.filter = filter; Debug.Assert(filter.GetLength(0) % 2 != 0 && filter.GetLength(1) % 2 != 0); // Build input layers (samples matrices) nbInputs = dataset.InputCount; samples = dataset.GetSamplesMatrix(); // Extract useful values f = filter.GetLength(0); // filter width f2 = filter.Length; // f^2 t = (f - 1) / 2; // filter thickness nbInputsNN = nbInputs * f2; nbOutputsNN = nbClusters * f2; n = samples.GetLength(1); // layers width m = samples.GetLength(2); // layers height }
private static extern void CalcH20u8pH(ref int iInt, [MarshalAs(UnmanagedType.LPArray)] double[] faPermeability, [MarshalAs(UnmanagedType.LPArray)] double[,] faS, [MarshalAs(UnmanagedType.LPArray)] double[,,] faB, [MarshalAs(UnmanagedType.LPArray)] double[] faWeight, [MarshalAs(UnmanagedType.LPArray)] double[] faH);
protected static extern void CalcH8K(ref int iInt, [MarshalAs(UnmanagedType.LPArray)] double[,,] faE, [MarshalAs(UnmanagedType.LPArray)] double[,,] faB, [MarshalAs(UnmanagedType.LPArray)] double[] faWeight, [MarshalAs(UnmanagedType.LPArray)] double[] faK);
private static extern void CalcH8Forces(ref int iInt, [MarshalAs(UnmanagedType.LPArray)] double[,,] faB, [MarshalAs(UnmanagedType.LPArray)] double[] faWeight, [MarshalAs(UnmanagedType.LPArray)] double[,] faStresses, [MarshalAs(UnmanagedType.LPArray)] double[] faForces);
private static extern void CalcH8Strains(ref int iInt, [MarshalAs(UnmanagedType.LPArray)] double[,,] faB, [MarshalAs(UnmanagedType.LPArray)] double[] fau, [MarshalAs(UnmanagedType.LPArray)] double[,] faStrains);
protected static extern void CalcH8GaussMatrices(ref int iInt, [MarshalAs(UnmanagedType.LPArray)] double[,] faXYZ, [MarshalAs(UnmanagedType.LPArray)] double[] faWeight, [MarshalAs(UnmanagedType.LPArray)] double[,] faS, [MarshalAs(UnmanagedType.LPArray)] double[,] faDS, [MarshalAs(UnmanagedType.LPArray)] double[,,] faJ, [MarshalAs(UnmanagedType.LPArray)] double[] faDetJ, [MarshalAs(UnmanagedType.LPArray)] double[,,] faB);
/// <summary> /// Initializes a new instance of the <see cref="SimulatedRegressors"/> class. Uses the provided simulators to /// find out how many regressors there will be. /// <para/> /// The order of the simulators must stay the same and the /// number of regressors that they produce must stay the same. /// </summary> /// <param name="dates">The dates as which regressors will be stored.</param> /// <param name="nSims">The number of simulations.</param> /// <param name="regressorCount"></param> public SimulatedRegressors(List <Date> dates, int nSims, int regressorCount) { _dates = dates; _nSims = nSims; _regressors = new double[nSims, dates.Count, regressorCount]; }
/// <summary> /// Returns the contents of the chunk by its coordinates. /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> /// <returns></returns> public override byte[, ,] GetChunk(int x, int y, int z) { this.waterlevel = WaterLevel; heightcache = new byte[this.ChunkSize, this.ChunkSize]; x = x * this.ChunkSize; y = y * this.ChunkSize; z = z * this.ChunkSize; byte[, ,] chunk = new byte[this.ChunkSize, this.ChunkSize, this.ChunkSize]; for (int xx = 0; xx < this.ChunkSize; xx++) { for (int yy = 0; yy < this.ChunkSize; yy++) { heightcache[xx, yy] = GetHeight(x + xx, y + yy); } } interpolatednoise = NoiseTools.InterpolateNoise3d(x, y, z, this.ChunkSize); // chance of get hay fields bool IsHay = _rnd.NextDouble() < 0.005 ? false : true; for (int xx = 0; xx < this.ChunkSize; xx++) { for (int yy = 0; yy < this.ChunkSize; yy++) { for (int zz = 0; zz < this.ChunkSize; zz++) { chunk[xx, yy, zz] = IsHay ? (byte)GetBlock(x + xx, y + yy, z + zz, heightcache[xx, yy], 0, xx, yy, zz) : (byte)GetBlock(x + xx, y + yy, z + zz, heightcache[xx, yy], 1, xx, yy, zz); } } } for (int xx = 0; xx < this.ChunkSize; xx++) { for (int yy = 0; yy < this.ChunkSize; yy++) {/* for (int zz = 0; zz < chunksize - 1; zz++) { if (chunk[xx, yy, zz + 1] == TileIdGrass && chunk[xx, yy, zz] == TileIdGrass) { chunk[xx, yy, zz] = (byte)TileIdDirt; } }*/ int v = 1; for (int zz = this.ChunkSize - 2; zz >= 0; zz--) { if (chunk[xx, yy, zz] == WorldGeneratorTools.TileIdEmpty) { v = 0; } if (chunk[xx, yy, zz] == WorldGeneratorTools.TileIdGrass) { if (v == 0) { } else if (v < 4) { chunk[xx, yy, zz] = (byte)WorldGeneratorTools.TileIdDirt; } else { chunk[xx, yy, zz] = (byte)WorldGeneratorTools.TileIdStone; } v++; } } } } if (z == 0) { for (int xx = 0; xx < this.ChunkSize; xx++) { for (int yy = 0; yy < this.ChunkSize; yy++) { chunk[xx, yy, 0] = (byte)this.ChunkSize; } } } return chunk; }
public void initialise () { int i, j, k; /* Dummy counters */ double scrap, scrap2; /* Temporary storage */ /* Set scale factor for interpolation */ scale = datasizes [size]; /* Open data file */ String instr = Constants.INPUT.Trim (); char[] spt = new char[4]; spt [0] = ' '; spt [1] = '\n'; spt [2] = '\t'; spt [3] = '\r'; String[] intokenstmp = instr.Split (spt); List<String> intokens = new List<String> (); foreach (String ss in intokenstmp) { if (!String.IsNullOrEmpty (ss)) intokens.Add (ss); } //we just assume the file is good and go for it imaxin = Int32.Parse (intokens [0]); jmaxin = Int32.Parse (intokens [1]); int pfloc = 2; // Read data into temporary array // note: dummy extra row and column needed to make interpolation simple oldval = new double[nf, imaxin + 1, jmaxin + 1]; for (i = 0; i < imaxin; i++) { for (j = 0; j < jmaxin; j++) { for (k = 0; k < nf; k++) { oldval [k, i, j] = Double.Parse (intokens [pfloc]); ++pfloc; } } } //interpolate onto finer grid imax = (imaxin - 1) * scale + 1; jmax = (jmaxin - 1) * scale + 1; newval = new double[nf, imax, jmax]; for (k = 0; k < nf; k++) { for (i = 0; i < imax; i++) { for (j = 0; j < jmax; j++) { int iold = i / scale; int jold = j / scale; double xf = ((double)i % scale) / ((double)scale); double yf = ((double)j % scale) / ((double)scale); newval [k, i, j] = (1.0 - xf) * (1.0 - yf) * oldval [k, iold, jold] + (1.0 - xf) * yf * oldval [k, iold, jold + 1] + xf * (1.0 - yf) * oldval [k, iold + 1, jold] + xf * yf * oldval [k, iold + 1, jold + 1]; } } } //create arrays deltat = new double[imax + 1, jmax + 2]; opg = new double[imax + 2, jmax + 2]; pg = new double[imax + 2, jmax + 2]; pg1 = new double[imax + 2, jmax + 2]; sxi = new double[imax + 2, jmax + 2]; seta = new double[imax + 2, jmax + 2]; tg = new double[imax + 2, jmax + 2]; tg1 = new double[imax + 2, jmax + 2]; ug = new Statevector[imax + 2, jmax + 2]; a = new double[imax, jmax]; d = new Statevector[imax + 2, jmax + 2]; f = new Statevector[imax + 2, jmax + 2]; g = new Statevector[imax + 2, jmax + 2]; r = new Statevector[imax + 2, jmax + 2]; ug1 = new Statevector[imax + 2, jmax + 2]; xnode = new double[imax, jmax]; ynode = new double[imax, jmax]; for (i = 0; i < imax + 2; ++i) { for (j = 0; j < jmax + 2; ++j) { d [i, j] = new Statevector (); f [i, j] = new Statevector (); g [i, j] = new Statevector (); r [i, j] = new Statevector (); ug [i, j] = new Statevector (); ug1 [i, j] = new Statevector (); } } /* Set farfield values (we use normalized units for everything */ cff = 1.0; vff = 0.0; pff = 1.0 / gamma; rhoff = 1.0; tff = pff / (rhoff * rgas); // Copy the interpolated data to arrays for (i = 0; i < imax; i++) { for (j = 0; j < jmax; j++) { xnode [i, j] = newval [0, i, j]; ynode [i, j] = newval [1, i, j]; ug [i + 1, j + 1].a = newval [2, i, j]; ug [i + 1, j + 1].b = newval [3, i, j]; ug [i + 1, j + 1].c = newval [4, i, j]; ug [i + 1, j + 1].d = newval [5, i, j]; scrap = ug [i + 1, j + 1].c / ug [i + 1, j + 1].a; scrap2 = ug [i + 1, j + 1].b / ug [i + 1, j + 1].a; tg [i + 1, j + 1] = ug [i + 1, j + 1].d / ug [i + 1, j + 1].a - (0.5 * (scrap * scrap + scrap2 * scrap2)); tg [i + 1, j + 1] = tg [i + 1, j + 1] / Cv; pg [i + 1, j + 1] = rgas * ug [i + 1, j + 1].a * tg [i + 1, j + 1]; } } /* Calculate grid cell areas */ for (i = 1; i < imax; ++i) { for (j = 1; j < jmax; ++j) a [i, j] = 0.5 * ((xnode [i, j] - xnode [i - 1, j - 1]) * (ynode [i - 1, j] - ynode [i, j - 1]) - (ynode [i, j] - ynode [i - 1, j - 1]) * (xnode [i - 1, j] - xnode [i, j - 1])); } // throw away temporary arrays oldval = newval = null; }
// maximize x'*Q*x + C'*x subject to Ax >= B public ProblemInput Transform(int day, int roomTypes, int categoryTypes, int mealTypes, IEnumerable <ChildRooms> childRooms, double[, ,] a, double[, ,] b, double[,] h, double[, ,] L, double[, ,] U, double[] R, double w, PriceRelation[] T, bool withACondition = true) { var allTypes = roomTypes * categoryTypes * mealTypes; var allTypes2 = allTypes; int minusIndex = 0; int[, ,] minusIndexes = new int[roomTypes, categoryTypes, mealTypes]; var skipedIndexes = GetSkipedIndexes(roomTypes, categoryTypes, mealTypes, a, b, L, U, R); for (var i = 0; i < roomTypes; ++i) { for (var j = 0; j < categoryTypes; ++j) { for (var k = 0; k < mealTypes; ++k) { if (skipedIndexes.Any(s => s.i == i && s.j == j && s.k == k)) { minusIndex++; } else { minusIndexes[i, j, k] = minusIndex; } } } } allTypes2 -= minusIndex; var n = 2 * allTypes2; var m = 4 * allTypes2 + roomTypes + (T.Length + (childRooms.Count() + childRooms.Select(v => v.Parent).Distinct().Count()) * mealTypes) * categoryTypes; var result = new ProblemInput(n, m); result.D = day; result.SkipedIndexes = skipedIndexes; var q = result.Quadratic; var c = result.Linear; var A = result.ConstraintMatrix; // A var B = result.ConstraintValues; // B double[] debug = new double[allTypes2]; minusIndex = 0; for (var i = 0; i < roomTypes; ++i) { B[3 * allTypes2 + i] = -R[i]; for (var j = 0; j < categoryTypes; ++j) { for (var k = 0; k < mealTypes; ++k) { if (!skipedIndexes.Any(s => s.i == i && s.j == j && s.k == k)) { var offset = i * categoryTypes * mealTypes + j * mealTypes + k - minusIndex; q[offset, offset] = 2 * b[i, j, k]; c[offset] = a[i, j, k] - b[i, j, k] * h[i, k]; c[allTypes2 + offset] = -w; A[offset, offset] = 1; A[offset, allTypes2 + offset] = 1; var lowerBound = L[i, j, k] > h[i, k] ? L[i, j, k] : h[i, k]; B[offset] = lowerBound > 0 ? lowerBound : 0; A[allTypes2 + offset, offset] = -1; A[allTypes2 + offset, allTypes2 + offset] = 1; B[allTypes2 + offset] = -U[i, j, k]; if (withACondition) { A[(2 * allTypes2 + offset), offset] = b[i, j, k]; B[2 * allTypes2 + offset] = -a[i, j, k]; } //Group rooms restriction with vacant rooms number B[3 * allTypes2 + i] += a[i, j, k]; A[3 * allTypes2 + i, offset] = -b[i, j, k]; if (childRooms.Any(v => v.Parent == i)) { var childs = childRooms.Where(v => v.Parent == i).ToList(); var total = childs.Sum(v => v.Quantity); foreach (var child in childs) { if (!skipedIndexes.Any(s => s.i == child.Child && s.j == j && s.k == k)) { var koef = ((double)child.Quantity) / (childRooms.Where(v => v.Child == child.Child).Sum(v => v.Quantity) * total); B[3 * allTypes2 + i] += koef * (a[child.Child, j, k] + (child.Quantity * R[i] - R[child.Child])); var newOffset = child.Child * categoryTypes * mealTypes + j * mealTypes + k - minusIndexes[child.Child, j, k]; A[3 * allTypes2 + i, newOffset] = -b[child.Child, j, k] * koef; } } } else if (childRooms.Any(v => v.Child == i)) { foreach (var parent in childRooms.Where(v => v.Child == i)) { if (!skipedIndexes.Any(s => s.i == parent.Parent && s.j == j && s.k == k)) { B[3 * allTypes2 + i] += parent.Quantity * a[parent.Parent, j, k]; var newOffset = parent.Parent * categoryTypes * mealTypes + j * mealTypes + k - minusIndexes[parent.Parent, j, k]; A[3 * allTypes2 + i, newOffset] = -b[parent.Parent, j, k] * parent.Quantity; } } } B[3 * allTypes2 + roomTypes + offset] = 0; A[3 * allTypes2 + roomTypes + offset, allTypes2 + offset] = 1; } else { minusIndex++; } } } } int index = 1; for (var i = 0; i < T.Length; ++i) { for (var j = 0; j < categoryTypes; ++j) { if (!skipedIndexes.Any(s => (s.i == T[i].R1 || s.i == T[i].R2) && s.j == j && (s.k == T[i].M1 || s.k == T[i].M2))) { A[m /*- T.Length * categoryTypes*/ - index, T[i].R2 * categoryTypes * mealTypes + j * mealTypes + T[i].M2 - minusIndexes[T[i].R2, j, T[i].M2]] = 1.0; A[m - index, T[i].R1 * categoryTypes * mealTypes + j * mealTypes + T[i].M1 - minusIndexes[T[i].R1, j, T[i].M1]] = -1.0; B[m - index] = 0; index++; } } } //price restrictions for group rooms for (var j = 0; j < categoryTypes; ++j) { for (var k = 0; k < mealTypes; ++k) { foreach (var child in childRooms) { A[m - index, child.Child *categoryTypes *mealTypes + j * mealTypes + k - minusIndexes[child.Child, j, k]] = -1; A[m - index, child.Parent *categoryTypes *mealTypes + j * mealTypes + k - minusIndexes[child.Parent, j, k]] = 1; B[m - index] = 0; index++; } foreach (var parent in childRooms.Select(v => v.Parent).Distinct().ToList()) { A[m - index, parent *categoryTypes *mealTypes + j * mealTypes + k - minusIndexes[parent, j, k]] = -1; foreach (var child in childRooms.Where(v => v.Parent == parent).ToList()) { A[m - index, child.Child *categoryTypes *mealTypes + j * mealTypes + k - minusIndexes[child.Child, j, k]] = 1; } B[m - index] = 0; index++; } } } return(result); }
public ProblemInput TransformForW(int day, int roomTypes, int categoryTypes, int mealTypes, double[,,] a, double[,,] b, double[,] h, double[,,] L, double[,,] U, double[] R, bool withACondition = true) { var allTypes = roomTypes * categoryTypes * mealTypes; var allTypes2 = allTypes; int minusIndex = 0; int[,,] minusIndexes = new int[roomTypes, categoryTypes, mealTypes]; var skipedIndexes = GetSkipedIndexes(roomTypes, categoryTypes, mealTypes, a, b, L, U, R); for (var i = 0; i < roomTypes; ++i) { for (var j = 0; j < categoryTypes; ++j) { for (var k = 0; k < mealTypes; ++k) { if (skipedIndexes.Any(s => s.i == i && s.j == j && s.k == k)) { minusIndex++; } else { minusIndexes[i, j, k] = minusIndex; } } } } allTypes2 -= minusIndex; var n = allTypes2; var m = 3 * allTypes2; var result = new ProblemInput(n, m); result.D = day; result.SkipedIndexes = skipedIndexes; var q = result.Quadratic; var c = result.Linear; var A = result.ConstraintMatrix; // A var B = result.ConstraintValues; // B minusIndex = 0; for (var i = 0; i < roomTypes; ++i) { for (var j = 0; j < categoryTypes; ++j) { for (var k = 0; k < mealTypes; ++k) { if (!skipedIndexes.Any(s => s.i == i && s.j == j && s.k == k)) { var offset = i * categoryTypes * mealTypes + j * mealTypes + k - minusIndex; q[offset, offset] = 2 * b[i, j, k]; c[offset] = a[i, j, k] - b[i, j, k] * h[i, k]; A[offset, offset] = 1; var koef = h[i, k]; B[offset] = koef > 0 ? koef : 0; A[(allTypes2 + offset), offset] = -1; B[allTypes2 + offset] = -10000000; if (withACondition) { if (a[i, j, k] <= 0) { A[(2 * allTypes2 + offset), offset] = 1; B[2 * allTypes2 + offset] = 0; } else { A[(2 * allTypes2 + offset), offset] = b[i, j, k]; B[2 * allTypes2 + offset] = -a[i, j, k]; } } } else { minusIndex++; } } } } return(result); }
public override void GetError(double[,,] error_out, double[,,] diff, double[,,] inarray, double[,,] input) { int a = 0; int depth1 = input_size[0]; int height1 = input_size[1]; int width1 = input_size[2]; int depth2 = error_out.GetLength(0); int height2 = error_out.GetLength(1); int width2 = error_out.GetLength(2); for (int z1 = 0; z1 < depth1; z1++) { for (int y1 = 0; y1 < height1; y1++) { for (int x1 = 0; x1 < width1; x1++) { double val = 0; for (int z2 = 0; z2 < depth2; z2++) { for (int y2 = 0; y2 < height2; y2++) { for (int x2 = 0; x2 < width2; x2++) { val += weights[z2, y2, x2, z1, y1, x1] * error_out[z2, y2, x2]; } } } input[z1, y1, x1] = val * diff[z1, y1, x1]; } } } }
public Tensor(double[,,] rhs) : this(rhs.GetLength(0), rhs.GetLength(1), rhs.GetLength(2), MemorySpace.Device, MathDomain.Double) { ReadFrom(rhs); }
public NetworkVisualizer(Network network, double[,,] input) { this.network = network; this.input = input; }
private void UpdateUI() { if (DataSource == null) return; var dataSource = DataSource; sizeX = DataSource.Width; sizeY = DataSource.Height; sizeZ = DataSource.Depth; model.Geometry = mesh; potential = Potential; Visual3DModel = model; Task.Factory.StartNew(() => { data = dataSource.DataToArray(); MarchingCubes(dataSource, potential); Dispatcher.BeginInvoke(() => OnCompletion()); }); }
//結構物設置 //public bool tBarCheck = false; //public bool bridgePierCheck = false; //public bool groundsillWorkCheck = false; //public bool sedimentationWeirCheck = false; //public int tBarNum = 0; //public int bridgePierNum = 0; //public int groundsillWorkNum = 0; //public int sedimentationWeirNum = 0; // private int _dryBedNum = 0; //private List<Point>[] _tBarPts = null; //private List<Point>[] _bridgePierPts = null; //private List<Point>[] _groundsillWorkPts = null; //private List<Point>[] _sedimentationWeirPts = null; //public List<Point>[] TBarSets //{ // get { return _tBarSets; } // set { _tBarSets = (List<Point>[])value.Clone(); } //} //浸沒邊界資訊 //private int _immersedBoundaryNum = 0; //private List<Point>[] _immersedBoundaryPts = null; //public bool sidewallBoundarySlip = false; //4.1.3.1 private void Initialization() { //模組特殊功能高程 dimensionType = DimensionType.None; //維度選擇 modelingType = ModelingType.None; //模組選擇 //Special Functions //水理 closeDiffusionEffectFunction = false; //關閉移流擴散效應 secondFlowEffectFunction = false; //二次流效應 structureSetFunction = false; //結構物設置 sideInOutFlowFunction = false; //側出入流 waterHighSandContentEffectFunction = false; //水理高含砂效應 //動床 bedrockFunction = false; //岩床 quayStableAnalysisFunction = false; //岩壁穩定分析 movableBedHighSandContentEffectFunction = false; //動床高含砂效應 //全域參數 inputGrid = null; importSource = ImportSource.None; coorType = TWD97; verticalLevelNumber = 19; //0.1.1 垂向格網分層數目 levelProportion = null; //0.1.1.1 分層比例 陣列大小_verticalLevelNumber //水理參數 flowType = FlowType.None; //1.0 定/變量流 //1.1 數值參數 ========================================= //1.1.1 時間 totalSimulationTime = 0; //1.1.1.1 總模擬時間 timeSpan2d = 0; //1.1.1.2 二維時間間距 outputFrequency = 0; //1.1.1.3 輸出頻率 steppingTimesInVertVslcTime = 10; //1.1.1.4 垂直方向計算時間步進次數 //1.1.2 收斂條件 waterModelingConvergenceCriteria2d = 0.0001; //1.1.2.1 二維水理收斂標準 waterModelingConvergenceCriteria3d = 0.0001; //1.1.2.2 三維水理收斂標準 waterModelingMaxIterationTimes = 10000; //1.1.2.3 水理最大疊代次數 //1.1.3 輸出控制 //2D outputControlInitialBottomElevation = false; //1.1.3 輸出控制 初始底床高程 outputControlLevel = false; //1.1.3 輸出控制 水位 outputControlDepth = false; //1.1.3 輸出控制 水深 outputControlAverageDepthFlowRate = false; //1.1.3 輸出控制 水深平均流速 outputControlFlow = false; //1.1.3 輸出控制 流量 outputControlBottomShearingStress = false; //1.1.3 輸出控制 底床剪應力 //3D outputControlVelocityInformation3D = false; //1.1.3 輸出控制 三維流速資訊 minWaterDeoth = 0.0001; //1.1.4 最小水深 單一數值 m 0.0001 實數(>0) 實數 8 格 (隱藏版功能) viscosityFactorAdditionInMainstream = 1; //1.1.5 主流方向黏滯係數加成比例 單一數值 1 實數(>=0) 實數 8 格 (隱藏版功能) viscosityFactorAdditionInSideDirection = 1; //1.1.6 側方向黏滯係數加成比例 單一數值 1 實數(>=0) 實數 8 格 (隱藏版功能) //1.2 物理參數 ========================================= roughnessType = RoughnessType.None; //1.2.1 糙度係數 二選一 整數 8 格 manningN = new TwoInOne(TwoInOne.ValueType.Double, TwoInOne.ArrayType.TwoDim); //1.2.1.1 Manning n 二選一 -- 均一值 chezy = new TwoInOne(TwoInOne.ValueType.Double, TwoInOne.ArrayType.TwoDim); //1.2.1.2 Chezy 二選一 -- 均一值 roughnessHeightKs = new TwoInOne(TwoInOne.ValueType.Double, TwoInOne.ArrayType.TwoDim); //1.2.1.3 粗糙高度 ks mm -- 均一值 turbulenceViscosityType = TurbulenceViscosityType.None; //1.2.2 紊流黏滯係數 四選一 整數 8 格 //1.2.2.1 使用者輸入 模擬功能為二維或三維都可選擇此項輸入 //1.2.2.1.1 紊流黏滯係數 Ns/m2 實數(>0) 實數 8 格 tvInMainstreamDirection = 0; //需確認 tvInSideDirection = 0; //需確認 zeroEquationType = ZeroEquationType.Constant; //1.2.2.2 零方程 五選一 總共 5 種選項 //1.2.2.3 單方程 -- //1.2.2.4 雙方程(k-ε) 三維 only,僅一項,不用下拉選單。 //1.2.3 其他 gravityConstant = 9.81; //1.2.3.1 重力常數 單一數值 m/s2 9.81 實數 Free waterDensity = 1000; //1.2.3.2 水密度 單一數值 kg/m3 1000 實數(>0) Free //1.3 二次流效應 二維 only curvatureRadiusType = 0; //1.3.1 曲率半徑 是否自動計算 curvatureRadius = null; //1.3.1 曲率半徑 矩陣(I,J) m 0 實數 Free //1.4 結構物設置 四種結構物:丁壩、橋墩、固床工、攔河堰。 tBarSet = false; //丁壩設置 bridgePierSet = false; //橋墩設置 groundsillWorkSet = false; //固床工設置 sedimentationWeirSet = false; //攔河堰設置 //1.4.1 結構物數量 tBarNumber = 0; //丁壩數量 bridgePierNumber = 0; //橋墩數量 groundsillWorkNumber = 0; //固床工數量 sedimentationWeirNumber = 0; //攔河堰數量 //1.4.1.1 格網位置 tBarSets = null; //丁壩位置集合 bridgePierSets = null; //橋墩位置集合 groundsillWorkSets = null; //固床工位置集合 sedimentationWeirSets = null; //攔河堰位置集合 //1.6 高含砂效應 供使用者輸入 6 個常數:α1、β1、c 1、α2、β2、c 2 highSandEffectAlpha1 = 0; highSandEffectBeta1 = 0; highSandEffectC1 = 0; highSandEffectAlpha2 = 0; highSandEffectBeta2 = 0; highSandEffectC2 = 0; //動床參數 //2.1 數值參數 ========================================= waterTimeSpan = 0; //2.1.1 時間間距 waterOutputFrequency = 0; //2.1.2 輸出頻率 //2.1.3 輸出控制 //2D outputControlBottomElevation = false; //2.1.3 輸出控制 初始底床高程 outputControlAverageDepthDensity = false; //2.1.3 輸出控制 水深平均流速 outputControlErosionDepth = false; //2.1.3 沖淤深度 //3D outputControlDensityInformation3D = false; //2.1.3 輸出控制 三維流速資訊 //2.1.4 選擇擴散公式 diffusionFormulaUse = false;; //2.1.4 擴散公式 diffusionFormula = DiffusionFormulaType.None; //2.1.4 擴散公式 diffusionBonusProportionalInMainstream = 1.0; //2.1.5 主流方向擴散係數加成比例單一數值 1 實數(>=0) 實數8 格三維 only (隱藏版功能) diffusionBonusProportionalInSideflow = 1.0; //2.1.6 側方向擴散係數加成比例單一數值 1 實數(>=0) 實數8 格三維 only (隱藏版功能) diffusionBonusProportionalInSurface = 1.0; //2.1.7 水面擴散係數加成比例單一數值 1 實數(>=0) 實數8 格三維 only (隱藏版功能) diffusionBonusProportionalInBottom = 1.0; //2.1.8 底床擴散係數加成比例單一數值 1 實數(>=0) 實數8 格三維 only (隱藏版功能) //2.2 物理參數 kinematicViscosityCoefficient = 1.12e-6; //2.2.1 動力黏滯係數單一數值 秒 1.12e-6 實數(>=0) 實數16 格 sedimentPoreRatio = 0.4; //2.2.2 泥砂孔隙比單一數值 -- 0.4 實數(>=0) 實數8 格 sedimentDensity = 2700; //2.2.3 泥砂密度單一數值 Kg/m3 2700 實數(>=0) 實數8 格 sedimentParticlesNumber = 3; //2.2.4 泥砂顆粒數目單一數值K 3 整數(>2) 最優先設定 sedimentParticleSize = null; //2.2.4.1 泥砂粒徑矩陣(K) m 實數(>0) 實數16 格矩陣(K)為泥砂顆粒數目 //2.3 底床組成 bottomLevelNumber = 6; //2.3.1 底床分層數目單一數值 整數(>0) a. 使用者輸入底床分層數目後 bottomLevelArray = null; //2.3.1.1 底床分層厚度矩陣(L) m 實數(>0) 矩陣(L)為底床分層數目 sedimentCompositionArray = null; //2.3.1.2 泥砂組成比例矩陣(K,L) 實數(>0) 矩陣(K,L)為(泥砂顆粒數目, 底床分層數目) shenCohesiveSediment = false; //2.3.2 凝聚性沉滓option surfaceErosion = false; //2.3.2.1 表層沖刷 -- 實數(>0) 供者用者輸入係數及臨界剪應力(N/m2)兩個值 surfaceErosionCoefficient = 0; //2.3.2.1 表層沖刷 -- 實數(>0) 供者用者輸入係數及臨界剪應力(N/m2)兩個值 surfaceErosionCriticalShearStress = 0; //2.3.2.1 表層沖刷 -- 實數(>0) 供者用者輸入係數及臨界剪應力(N/m2)兩個值 massiveErosion = false; //2.3.2.2 塊狀沖蝕 單一數值 N/m2。 -- 實數(>0) 供者用者輸入臨界剪應力(N/m2) massiveErosionCriticalShearStress = 0; //2.3.2.2 塊狀沖蝕 單一數值 N/m2。 -- 實數(>0) 供者用者輸入臨界剪應力(N/m2) noErosionElevationUse = false; //2.3.3 不可沖刷高程 二選一 m 實數 a. option 用 check box noErosionElevation = new TwoInOne(TwoInOne.ValueType.Double, TwoInOne.ArrayType.TwoDim); //b. 0:均一值,逐點給:-1 //2.4.2 高含砂輸砂公式 多選一 -- -- 整數 8 格 共 3 種選項 sandTransportEquation = SandTransportEquationType.None; waterJettingAlpha = 0; //2.5.1 水力沖刷 實數 供使用者輸入α及β兩個常數。 waterJettingBeta = 0; //2.5.1 水力沖刷 實數 供使用者輸入α及β兩個常數。 sedimentErosion = false; //2.5.2 泥砂磨蝕 sedimentErosionElasticModulusValue = 0; //2.5.2.1 彈性模數 二選一 pa 實數(>=0) a. 0:均一值,逐點給:-1 sedimentErosionElasticModulusArray = null; //2.5.2.1 彈性模數 二選一 pa 實數(>=0) a. 若為逐點給,則參數形式為矩陣(I,J) sedimentErosionTensileStrengthValue = 0; //2.5.2.2 張力強度 二選一 pa 實數(>=0) a. 0:均一值,逐點給:-1 sedimentErosionTensileStrengthArray = null; //2.5.2.2 張力強度 二選一 pa 實數(>=0) a. 若為逐點給,則參數形式為矩陣(I,J) bedrockElevation = false; //2.5.3 岩床高程 bedrockElevationValue = 0;; //2.5.3 岩床高程 二選一 m 實數 a. 0:均一值,逐點給:-1。 bedrockElevationArray = null; //2.5.3 岩床高程 二選一 m 實數 a. 為逐點給,則參數形式為矩陣(I,J) //2.6 岸壁穩定分析 option //2.6.1 分析位置 positionAnalysis = false; //2.6.1 分析位置 positionAnalysisType = PositionAnalysisType.None; //2.6.1 分析位置二選一 -- a. 僅供介面用,不用輸入到input 檔。此選項為提供全部模擬與局部模擬兩個選項 localBlockNumber = 0; //2.6.1.1 數值格網數目的表格供使用者填入欲分析位置數目IB,其中IB 的數目不可超過格網數目I。 localBlockArray = null; //2.6.1.1 局部區塊數目矩陣(2, IB) -- a. 矩陣(2, IB),1 代表左岸,2 代表右岸。僅為0、1 兩個數目字可供選擇,若1 為計算,若0 為不計算。 //2.6.2 入滲效應 infiltrationEffect = false; //2.6.2 入滲效應 option infiltrationEffectTimeFormat = InfiltrationEffectTimeFormat.Minute; //2.6.2.1 時間格式二選一 小時/分鐘,二選一。 infiltrationEffectTimeSpacing = 0; //2.6.2.2 間距單一數值 實數(>0) 使用者自行輸入數值ex:1.5 小時or 90 分鐘 rainfall = null; //2.6.2.2.1 降雨量矩陣 mm 實數(>0) Free a. 矩陣大小需計算:首先將間距換為秒,然後“總模擬時間” (秒)除於間距(秒),即為矩陣大小 //2.6.3 岸壁幾何條件 quayGeometry = false; //2.6.3 岸壁幾何條件 soilStratificationNumber = 0; //2.6.3.1 岸壁土壤分層數目單一數值 整數(>0) option layerThicknessArray = null; //2.6.3.1.1 分層厚度矩陣(LBK)m 實數(>0) 矩陣(LBK)為岸壁土壤分層數目 quayHeightArray = null; //2.6.3.2 岸壁高度矩陣(2, IB) m 實數 dikeToWharfLengthArray = null; //2.6.3.3 堤防到岸壁的長度矩陣(2, IB)m 實數(>0) //2.6.4 岸壁土壤性質 quaySoilProperties = false; //2.6.4 岸壁土壤性質 cohesion = 0; //2.6.4.1 凝聚力 二選一 pa 實數(>0) a. 0:均一值,逐點給:-1 cohesionArray = null; //2.6.4.1 凝聚力 若為逐點給,則參數形式為矩陣(2,IB,LBK) reposeAngle = 0; //2.6.4.2 安息角 二選一 deg 實數(>0) a. 0:均一值,逐點給:-1 reposeAngleArray = null; //2.6.4.2 安息角 若為逐點給,則參數形式為矩陣(2,IB,LBK) frictionAngle = 0; //2.6.4.3 內摩擦角 二選一 deg 實數(>0) a. 0:均一值,逐點給:-1 frictionAngleArray = null; //2.6.4.3 內摩擦角 若為逐點給,則參數形式為矩陣(2,IB,LBK) flowRateRatio = 0; //2.6.4.3 比流率 二選一 deg 實數(>0) a. 0:均一值,逐點給:-1 flowRateRatioArray = null; //2.6.4.3 比流率 若為逐點給,則參數形式為矩陣(2,IB,LBK) porosityRatio = 0; //2.6.4.5 孔隙率二選一 -- 實數(>0) a. 0:均一值,逐點給:-1 porosityRatioArray = null; //若為逐點給,則參數形式為矩陣(2,IB,LBK) soilProportion = 0; //2.6.4.6 土壤比重二選一 -- 實數(>0) a. 0:均一值,逐點給:-1 soilProportionArray = null; //若為逐點給,則參數形式為矩陣(2,IB,LBK) ShearStrengthAngle = 0; //2.6.4.7 岸壁未飽和基值吸力造成剪力強度增加所對應角度 二選一 deg 實數(>0) a. 0:均一值,逐點給:-1 ShearStrengthAngleArray = null; //2.6.4.7 岸壁未飽和基值吸力造成剪力強度增加所對應角度 若為逐點給,則參數形式為矩陣(2,IB,LBK) //3. 初始條件 //3.1 水理模組 ========================================= depthAverageFlowSpeedU = new TwoInOne(TwoInOne.ValueType.Double, TwoInOne.ArrayType.TwoDim); depthAverageFlowSpeedV = new TwoInOne(TwoInOne.ValueType.Double, TwoInOne.ArrayType.TwoDim); waterLevel = new TwoInOne(TwoInOne.ValueType.Double, TwoInOne.ArrayType.TwoDim); ; //3.1.4 水位 二選一 m 實數 實數 8 格a. 若為逐 點給,則參數形式為矩陣(I,J) verticalVelocitySlice = VerticalVelocitySliceType.None; //3.1.4 垂向流速剖面二選一 -- -- 整數8 格a. 三維only b. 0:關;1:開 //3.2 動床模組 depthAverageConcentration = new TwoInOne(TwoInOne.ValueType.ThreeDim, TwoInOne.ArrayType.ThreeDim); //3.2.1 水深平均濃度二選一 ppm -- 實數(>=0) 實數8 格a. 總共有K 個粒徑種類,每種粒徑都要輸入。 verticalConcentrationSlice = VerticalConcentrationSliceType.None; //3.2.2 垂向濃度剖面二選一 -- -- 整數8 格a. 三維only b. 0:關;1:開 //4. 邊界條件 //4.1 水理模組 boundaryTimeNumber = 0; //4.1.0 邊界時間數目 boundaryTime = null; //4.1.0 邊界時間 //4.1.1 上游 upFlowCondition = FlowConditionType.None; //4.1.1.1 流況設定 二選一 //4.1.1.1.1 超臨界流 //boundaryConditionNumber = 0; //4.1.1.1.2.0 邊界條件數目 T 整數(>1) 定量流不輸入 superMainFlowQuantity = new TwoInOne(TwoInOne.ValueType.TwoDim, TwoInOne.ArrayType.TwoDim); //4.1.1.1.2.1 流量 實數(>=0) 同 4.1.1.1.1.1 superSideFlowQuantity = new TwoInOne(TwoInOne.ValueType.TwoDim, TwoInOne.ArrayType.TwoDim); //4.1.1.1.2.1 流量 實數(>=0) 同 4.1.1.1.1.1 superWaterLevel = new TwoInOne(TwoInOne.ValueType.TwoDim, TwoInOne.ArrayType.TwoDim); //4.1.1.1.1.2 水位 m 實數 //4.1.1.1.2 亞臨界流 //subBoundaryConditionNumber = 0; //4.1.1.1.2.0 邊界條件數目 T 整數(>1) 定量流不輸入 subMainFlowQuantity = new TwoInOne(TwoInOne.ValueType.TwoDim, TwoInOne.ArrayType.TwoDim); //4.1.1.1.2.1 流量 實數(>=0) 同 4.1.1.1.1.1 subSideFlowQuantity = new TwoInOne(TwoInOne.ValueType.TwoDim, TwoInOne.ArrayType.TwoDim); //4.1.1.1.2.1 流量 實數(>=0) 同 4.1.1.1.1.1 verticalVelocityType = VerticalVelocityType.Auto; //4.1.1.2 垂向流速分布(3D) 矩陣(2,P) 實數(>=0) verticalVelocityDistributionArray = null; //4.1.1.2 垂向流速分布(3D) 矩陣(2,P) 實數(>=0) //4.1.2 下游 二選一 downFlowCondition = FlowConditionType.None; //4.1.2 下游 二選一 downSubWaterLevel = new TwoInOne(TwoInOne.ValueType.TwoDim, TwoInOne.ArrayType.TwoDim); //4.1.2.2.1 水位 實數 同 4.1.1.1.1.2,T 與前同(4.1.1.1.1.0 或4.1.1.1.2.0) //4.1.3 側壁 sidewallBoundarySlip = false; //4.1.3.1 側壁邊界滑移 -- 0 整數(>0) 整數 8 格 0:非滑移、1:滑移,check box //4.1.4 水面 三維 only。(”即時互動處”不放圖示) mainstreamWindShear = 0; //4.1.4.1 主流方向風剪 單一數值 N/m2 0 實數 實數 8 格 sideWindShear = 0; //4.1.4.2 側方向風剪 單一數值 N/m2 0 實數 實數 8 格 coriolisForce = 0; //4.1.4.3 科氏力 單一數值 N/m2 0 實數 實數 8 格 //4.1.5 底床 實數 三維 only。(”即時互動處”不放圖示) boundaryLayerThickness = 3; //4.1.5.1 邊界層厚度 三選一 3 整數(>0) 整數 8 格 1、2、3,三維 only,下拉選單。 seabedBoundarySlip = SeabedBoundarySlipType.NonSlip; //4.1.5.2 底床邊界滑移 三選一 -- 0 整數(>0) 整數 8 格 a. 三維 only,下拉選單 b. 0:非滑移、1:滑移、2:壁函數 //4.2 動床模組 //4.2.1 上游 //4.2.1.1 入流泥砂設定 bottomBedLoadFluxType = BottomBedLoadFluxType.Auto; //4.2.1.1.1 底床載通量 實數(>=0)“模式自動計算” bottomBedLoadFluxArray = new TwoInOne(TwoInOne.ValueType.ThreeDim, TwoInOne.ArrayType.ThreeDim); ; //4.2.1.1.1 底床載通量 實數(>=0)“自行輸入”,如果為“自行輸入”,則如圖4.2.1.1.1 所示 suspendedLoadDepthAvgConcentration = new TwoInOne(TwoInOne.ValueType.ThreeDim, TwoInOne.ArrayType.ThreeDim); //4.2.1.1.2 懸浮載水深平均濃度實數(>=0) 如圖 4.2.1.1.1 所示 boundaryUpVerticalDistributionNum = 0; boundaryUpVerticalDistribution = new TwoInOne(TwoInOne.ValueType.Double, TwoInOne.ArrayType.TwoDim); //4.2.1.1.3 垂向濃度分布(3D) 矩陣(2,PP) 均一值 實數(>=0) a. 可為均一值或自行輸入。 //4.2.1.2 上游邊界底床 upBoundaryElevationType = BottomBedLoadFluxType.Auto; //4.2.1.2.1 可採用初始上游邊界底床高程或自行輸入 upBoundaryElevationArray = null; //4.2.1.2.1 高程矩陣(T,J) m 初始實數 可採用初始上游邊界底床高程或自行輸入, bottomBedParticleSizeRatio = null; //4.2.1.2.2 底床粒徑比例實數(>=0) 如圖 4.2.1.1.3 所示 //4.2.2 下游 圖5,“即時互動處”不放圖示 movableBedDownType = BottomBedLoadFluxType.Auto; //4.2.2.1 通量實數(>=0) 如圖 2.2.2.1 所示 movableBedDownConcentration = null; //4.2.2.2 濃度 實數(>=0) 如圖 2.2.2.1 所示 boundaryDownVerticalDistributionNum = 0; boundaryDownVerticalDistribution = new TwoInOne(TwoInOne.ValueType.Double, TwoInOne.ArrayType.TwoDim); //4.2.1.1.3 垂向濃度分布(3D) 矩陣(2,PP) 均一值 實數(>=0) a. 可為均一值或自行輸入。 nearBedBoundaryType = NearBedBoundaryType.None; //4.2.3 近底床濃度邊界二選一 實數 a. 三維only concentrationCalculation = ConcentrationCalculationType.None; //4.2.3.1 濃度計算公式多選一 整數 8 格下拉式選單(總共2~3 種選項) inputConcentration = new TwoInOne(TwoInOne.ValueType.Double, TwoInOne.ArrayType.TwoDim); //4.2.3.2 通量/給定濃度二選一 a. 先令使用者選擇是通量或者是給定濃 stopFlah = false; }
/// <summary> /// フィールドの回転を取得する /// </summary> /// <param name="rotXFValues"></param> /// <param name="rotYFValues"></param> protected override void calcRotField(out Complex[] rotXFValues, out Complex[] rotYFValues) { base.calcRotField(out rotXFValues, out rotYFValues); rotXFValues = new Complex[NodeNumbers.Length]; rotYFValues = new Complex[NodeNumbers.Length]; const int ndim = Constants.CoordDim2D; //2; // 座標の次元数 const int vertexCnt = Constants.TriVertexCnt; //3; // 三角形の頂点の数(2次要素でも同じ) //const int nodeCnt = Constants.TriNodeCnt_SecondOrder; //6; // 三角形2次要素 int nodeCnt = NodeNumbers.Length; if (nodeCnt != Constants.TriNodeCnt_SecondOrder && nodeCnt != Constants.TriNodeCnt_FirstOrder) { return; } // 三角形の頂点を取得 double[][] pp = new double[vertexCnt][]; for (int ino = 0; ino < pp.GetLength(0); ino++) { FemNode node = _Nodes[ino]; System.Diagnostics.Debug.Assert(node.Coord.Length == ndim); pp[ino] = new double[ndim]; pp[ino][0] = node.Coord[0]; pp[ino][1] = node.Coord[1]; } // 面積座標の微分を求める // dldx[k, n] k面積座標Lkのn方向微分 double[,] dldx = null; double[] const_term = null; KerEMatTri.TriDlDx(out dldx, out const_term, pp[0], pp[1], pp[2]); // 形状関数の微分の係数を求める // dndxC[ino,n,k] ino節点のn方向微分のLk(k面積座標)の係数 // dNino/dn = dndxC[ino, n, 0] * L0 + dndxC[ino, n, 1] * L1 + dndxC[ino, n, 2] * L2 + dndxC[ino, n, 3] double[, ,] dndxC = null; if (nodeCnt == Constants.TriNodeCnt_FirstOrder) { dndxC = new double[Constants.TriNodeCnt_FirstOrder, ndim, vertexCnt + 1] { { { 0.0, 0.0, 0.0, dldx[0, 0] }, { 0.0, 0.0, 0.0, dldx[0, 1] }, }, { { 0.0, 0.0, 0.0, dldx[1, 0] }, { 0.0, 0.0, 0.0, dldx[1, 1] }, }, { { 0.0, 0.0, 0.0, dldx[2, 0] }, { 0.0, 0.0, 0.0, dldx[2, 1] }, }, }; } else { dndxC = new double[Constants.TriNodeCnt_SecondOrder, ndim, vertexCnt + 1] { { { 4.0 * dldx[0, 0], 0.0, 0.0, -1.0 * dldx[0, 0] }, { 4.0 * dldx[0, 1], 0.0, 0.0, -1.0 * dldx[0, 1] }, }, { { 0.0, 4.0 * dldx[1, 0], 0.0, -1.0 * dldx[1, 0] }, { 0.0, 4.0 * dldx[1, 1], 0.0, -1.0 * dldx[1, 1] }, }, { { 0.0, 0.0, 4.0 * dldx[2, 0], -1.0 * dldx[2, 0] }, { 0.0, 0.0, 4.0 * dldx[2, 1], -1.0 * dldx[2, 1] }, }, { { 4.0 * dldx[1, 0], 4.0 * dldx[0, 0], 0.0, 0.0 }, { 4.0 * dldx[1, 1], 4.0 * dldx[0, 1], 0.0, 0.0 }, }, { { 0.0, 4.0 * dldx[2, 0], 4.0 * dldx[1, 0], 0.0 }, { 0.0, 4.0 * dldx[2, 1], 4.0 * dldx[1, 1], 0.0 }, }, { { 4.0 * dldx[2, 0], 0.0, 4.0 * dldx[0, 0], 0.0 }, { 4.0 * dldx[2, 1], 0.0, 4.0 * dldx[0, 1], 0.0 }, }, }; } // 節点の面積座標 double[][] n_pts = null; if (nodeCnt == Constants.TriNodeCnt_FirstOrder) { n_pts = new double[Constants.TriNodeCnt_FirstOrder][] { new double[vertexCnt] { 1.0, 0.0, 0.0 }, new double[vertexCnt] { 0.0, 1.0, 0.0 }, new double[vertexCnt] { 0.0, 0.0, 1.0 }, }; } else { n_pts = new double[Constants.TriNodeCnt_SecondOrder][] { new double[vertexCnt] { 1.0, 0.0, 0.0 }, new double[vertexCnt] { 0.0, 1.0, 0.0 }, new double[vertexCnt] { 0.0, 0.0, 1.0 }, new double[vertexCnt] { 0.5, 0.5, 0.0 }, new double[vertexCnt] { 0.0, 0.5, 0.5 }, new double[vertexCnt] { 0.5, 0.0, 0.5 }, }; } for (int ino = 0; ino < nodeCnt; ino++) { double[] L = n_pts[ino]; double[] dNdx = new double[nodeCnt]; double[] dNdy = new double[nodeCnt]; for (int k = 0; k < nodeCnt; k++) { int direction; direction = 0; dNdx[k] = dndxC[k, direction, 0] * L[0] + dndxC[k, direction, 1] * L[1] + dndxC[k, direction, 2] * L[2] + dndxC[k, direction, 3]; direction = 1; dNdy[k] = dndxC[k, direction, 0] * L[0] + dndxC[k, direction, 1] * L[1] + dndxC[k, direction, 2] * L[2] + dndxC[k, direction, 3]; } rotXFValues[ino] = new Complex(); rotYFValues[ino] = new Complex(); for (int k = 0; k < nodeCnt; k++) { // (rot(Ez)x = dEz/dy rotXFValues[ino] += _FValues[k] * dNdy[k]; // (rot(Ez)y = - dEz/dx rotYFValues[ino] += -1.0 * _FValues[k] * dNdx[k]; } // rot(Ez)を磁界の値に変換する rotXFValues[ino] *= _FactorForRot / _media_Q[0, 0]; rotYFValues[ino] *= _FactorForRot / _media_Q[1, 1]; } }
private IEnumerable <MinusIndex> GetSkipedIndexes(int roomTypes, int categoryTypes, int mealTypes, double[, ,] a, double[, ,] b, double[, ,] L, double[, ,] U, double[] R) { List <CheckObject> objects = new List <CheckObject>(); List <MinusIndex> skipedIndexes = new List <MinusIndex>(); for (var i = 0; i < roomTypes; ++i) { for (var j = 0; j < categoryTypes; ++j) { for (var k = 0; k < mealTypes; ++k) { var index = new MinusIndex { i = i, j = j, k = k }; objects.Add(new CheckObject { index = index, value = a[i, j, k] + b[i, j, k] * 3 * U[i, j, k] }); var sum = objects.Sum(s => s.value); while (sum > R[i]) { if (!objects.Any()) { break; } var max = objects.Max(s => s.value); foreach (var obj in objects.Where(s => s.value == max).ToList()) { if (sum <= R[i]) { break; } sum -= max; objects.Remove(obj); if (!skipedIndexes.Contains(obj.index)) { skipedIndexes.Add(obj.index); } } } if ((a[i, j, k] <= 0 || (-a[i, j, k] / b[i, j, k]) <= L[i, j, k] || R[i] < 1) && !skipedIndexes.Any(s => s.i == i && s.j == j && s.k == k)) { skipedIndexes.Add(index); } } } } return(skipedIndexes); } //public ProblemInput TransformWithoutY(int roomTypes, int categoryTypes, double[,] a, double[,] b, double[] h,
/// <summary> /// Deserializes the object. /// </summary> /// <param name="info">the data necessary to deserialize this object</param> /// <param name="ctxt">specifies the serialization stream</param> public SerializableHmm(SerializationInfo info, StreamingContext ctxt) { name = (string)info.GetValue("name", typeof(string)); transitions = (double[,])info.GetValue("transitions", typeof(double[,])); mean = (double[,])info.GetValue("mean", typeof(double[,])); covariance = (double[,,])info.GetValue("covariance", typeof(double[,,])); probabilities = (double[])info.GetValue("probabilities", typeof(double[])); try { pca = (PrincipalComponentAnalysis)(info.GetValue("pca", typeof(PrincipalComponentAnalysis))); } catch (System.Runtime.Serialization.SerializationException ex) { pca = null; } }
// double[,] gR_Magnitude_Mat; private void button3_Click(object sender, EventArgs e) { int scanFilterNum=0; int W = Train_I.Width; int H = Train_I.Height; // Real part Image<Gray, Double> gR_R = new Image<Gray, Double>(W, H); gR_R2 = new double[m, n, 1]; gF_R_One_back = new float[m * n]; gF_R_back = new float[m, n]; gR_R3 = new double[H, W]; gR_R3_One = new double[H * W]; // Ouput gR_R_Mat = new double[H * W, u * v]; // Ouput gR_R_Picked = new Matrix<double>(H, W); gR_R_Picked_Map = new Matrix<double>(H, W); gR_R_One_Picked = new double[H * W]; gR_R_Picked_CS = new double[H, W]; // Imag part Image<Gray, Double> gR_I = new Image<Gray, Double>(W, H); double[, ,] gR_I2 = new double[m, n, 1]; float[] gF_I_One_back = new float[m * n]; float[,] gF_I_back = new float[m, n]; double[,] gR_I3 = new double[H, W]; double[] gR_I3_One = new double[H*W]; // Ouput double[,] gR_I_Mat = new double[H*W, u*v]; // Ouput Matrix<double> gR_I_Picked = new Matrix<double>(H, W); Matrix<double> gR_I_Picked_Map = new Matrix<double>(H, W); double[] gR_I_One_Picked = new double[H * W]; double[,] gR_I_Picked_CS = new double[H, W]; Matrix<double> t = new Matrix<double>(H, W); /////////////// Filtered and save as gR_R_Mat / gR_I_Mat ////////////// for (scanFilterNum = 0; scanFilterNum < u * v; scanFilterNum++) { System.Console.WriteLine(scanFilterNum); // Real part gF_R_One_back = PickUpFilterFloat(gF_R_Mat.Data, scanFilterNum); gF_R_back = OneToTwoFloat(gF_R_One_back, m, n); // OK ConvolutionKernelF matrix_R = new ConvolutionKernelF(gF_R_back); CvInvoke.cvFilter2D(Train_I, gR_R, matrix_R, new Point(0, 0)); gR_R2 = gR_R.Data; gR_R3 = ArrayDownDim(gR_R2); gR_R3_One = TwoToOneDouble(gR_R3); // Imag part gF_I_One_back = PickUpFilterFloat(gF_I_Mat.Data, pickFilterNum); gF_I_back = OneToTwoFloat(gF_I_One_back, m, n); ConvolutionKernelF matrix_I = new ConvolutionKernelF(gF_I_back); CvInvoke.cvFilter2D(Train_I, gR_I, matrix_I, new Point(0, 0)); gR_I2 = gR_I.Data; gR_I3 = ArrayDownDim(gR_I2); gR_I3_One = TwoToOneDouble(gR_I3); // Put into Mat for (int q = 0; q < H * W; q++) { gR_R_Mat[q, scanFilterNum] = gR_R3_One[q]; gR_I_Mat[q, scanFilterNum] = gR_I3_One[q]; // gR_Magnitude_Mat[q, scanFilterNum] = Math.Sqrt((Math.Pow(gR_R3_One[q], 2) + Math.Pow(gR_I3_One[q], 2))); } } /////////////// END Filtered and save as gR_R_Mat / gR_I_Mat ////////////// //////////////////////////////////////////////////////////////////// Test START///////////////////////////////////////////////////////////////// double Imin; double Imax; Point IminLoc; Point ImaxLoc; t.Data = gR_R3; t.MinMax(out Imin, out Imax, out IminLoc, out ImaxLoc); double kkk = ((Imax - Imin) / 255); int W_gR_R3 = t.Width; int H_gR_R3 = t.Height; for (int i = 0; i < H_gR_R3; i++) { for (int j = 0; j < W_gR_R3; j++) { t.Data[i, j] = (float)(((t.Data[i, j] - (float)Imax) / kkk) + 255); // Mapping } } t.Save(@"D:\Code\gF_R_back.bmp"); pictureBox7.Image = Image.FromFile(@"D:\Code\gF_R_back.bmp"); //////////////////////////////////////////////////////////////////// Test END ///////////////////////////////////////////////////////////////// /////////////////////////////// Show Real Part //////////////////////////////// pickResultNum = 0; gR_R_One_Picked = PickUpResultDouble(gR_R_Mat, pickResultNum); // Choose the p-th Gabor filtered Result gR_R_Picked_CS = OneToTwoDouble(gR_R_One_Picked,H,W); gR_R_Picked.Data = gR_R_Picked_CS; // Show the choose filtered Result, mapping pixel value to [0,255] double R_Rmin; double R_Rmax; Point R_RminLoc; Point R_RmaxLoc; gR_R_Picked.MinMax(out R_Rmin, out R_Rmax, out R_RminLoc, out R_RmaxLoc); double k = ((R_Rmax - R_Rmin) / 255); int H_gR_R_Picked = gR_R_Picked.Rows; int W_gR_R_Picked = gR_R_Picked.Cols; for (int i = 0; i < H_gR_R_Picked; i++) { for (int j = 0; j < W_gR_R_Picked; j++) { gR_R_Picked_Map.Data[i, j] = (( (gR_R_Picked.Data[i, j] - R_Rmin) / k) ); // Mapping } } gR_R_Picked_Map.Save(@"D:\Code\gR_R_Picked_Map.bmp"); pictureBox3.Image = Image.FromFile(@"D:\Code\gR_R_Picked_Map.bmp"); /////////////////////////////// Show Imagl Part //////////////////////////////// gR_I_One_Picked = PickUpResultDouble(gR_I_Mat, pickResultNum); // Choose the p-th Gabor filtered Result gR_I_Picked_CS = OneToTwoDouble(gR_I_One_Picked, H, W); gR_I_Picked.Data = gR_I_Picked_CS; // Show the choose filtered Result, mapping pixel value to [0,255] double I_Rmin; double I_Rmax; Point I_RminLoc; Point I_RmaxLoc; gR_I_Picked.MinMax(out I_Rmin, out I_Rmax, out I_RminLoc, out I_RmaxLoc); double kk = ((I_Rmax - I_Rmin) / 255); int H_gR_I_Picked = gR_I_Picked.Rows; int W_gR_I_Picked = gR_I_Picked.Cols; for (int i = 0; i < H_gR_I_Picked; i++) { for (int j = 0; j < W_gR_I_Picked; j++) { gR_I_Picked_Map.Data[i, j] = (((gR_I_Picked.Data[i, j] - I_Rmin) / kk)); // Mapping } } gR_I_Picked_Map.Save(@"D:\Code\gR_I_Picked_Map.bmp"); pictureBox6.Image = Image.FromFile(@"D:\Code\gR_I_Picked_Map.bmp"); label14.Text = "pickResultNum = " + pickResultNum; System.Console.WriteLine(" END OF button3_Click: Gabor Result"); }
public Tensor(double[, ,] entries) { this.entries = (double[, ,])entries.Clone(); }