internal override async void Drawing() { if (OwnerChart == null || OwnerChart.ItemsSource == null || OwnerChart.XAxis == null || OwnerChart.YAxis == null) { return; } IEnumerable <IList> items = OwnerChart.ItemsSource; IAxis xaxis = OwnerChart.XAxis; IAxis yaxis = OwnerChart.YAxis; if (OwnerChart.X < 0) { OwnerChart.X = 0; } int x = OwnerChart.X; if (OwnerChart.Y < 0) { OwnerChart.Y = 1; } int y = OwnerChart.Y; var geometries = await CreateGeometrys(items, xaxis, yaxis, x, y); using (var dc = DV.RenderOpen()) { base.ClearTransform(); for (int i = 0; i < geometries.Count; i++) { dc.DrawGeometry(new SolidColorBrush(GetGradientColor(i, geometries.Count)), new Pen(this.Stroke, 0), geometries[i]); } dc.Close(); } }
private void metroButton1_Click(object sender, EventArgs e) { if (!SesionManager.iniciarSesion(usernameTB.Text, passwordTB.Text)) { MetroFramework.MetroMessageBox.Show(this, Sesion.obtenerSesion().idioma.textos["login_failed"], Sesion.obtenerSesion().idioma.textos["notification"]); return; } var sesion = Sesion.obtenerSesion(); MetroFramework.MetroMessageBox.Show(this, sesion.idioma.textos["login_success"], sesion.idioma.textos["notification"]); if (!DV.verificarDV()) { if (PermisosManager.verificarPatente(sesion.usuario, "DigitoVerificador")) { ErrorDV error = new ErrorDV(); error.Show(); return; } MetroFramework.MetroMessageBox.Show(this, sesion.idioma.textos["error_contact_admin"], sesion.idioma.textos["notification"]); return; } this.Hide(); Home h1 = new Home(); h1.ShowDialog(); this.Close(); }
protected void DV_Click(object sender, EventArgs e) { int DV; DV = UtilContratosArrto.Digitoverificador(Convert.ToInt32(this.TextBoxIdEdo.Text), Convert.ToInt32(TextBoxUltConsecutivo.Text)); this.LabelDV.Text = "Digito verificador: " + DV.ToString(); }
static void Main_Testing(string[] args) { //Functions Func <DV, D> F1 = delegate(DV x) { D x1 = x[0]; return(AD.Pow(x1 - 7, 2)); }; Func <DV, D> F2 = delegate(DV x) { D x1 = x[0]; D x2 = x[1]; return(AD.Pow(x1, 2) + AD.Pow(x2, 3)); }; //Test poing //DV thePoint = new DV(new double[] { 10, 10 }); DV thePoint = new DV(new double[] { 10 }); Console.WriteLine(" f(10) = {0}", F1(thePoint)); var v = AD.Grad(F1, thePoint); Console.WriteLine("Version 1"); Console.WriteLine(" dx1 = {0}", v[0]); //Console.WriteLine(" dx2 = {0}", v[1]); var h = AD.Hessian(F1, thePoint); Console.WriteLine("\nVersion 2"); Console.WriteLine(" d2x1 = {0}", h[0, 0]); //Console.WriteLine(" d2x2 = {0}", h[1, 1]); Console.ReadKey(); }
public IHttpActionResult PutDV(string id, DV dV) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != dV.MA_DICH_VU) { return(BadRequest()); } db.Entry(dV).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DVExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public static void archivar(Objetivo obj) { dao.archivar(obj.id); DV.actualizarDV(); BitacoraManager.agregarMensajeControl("Objetivo actualizado: Archivado", obj); }
public static void borrar(Reconocimiento rec) { dao.borrar(rec.id); DV.actualizarDV(); BitacoraManager.agregarMensajeControl("Reconocimiento borrado: ", rec); }
public bool checkIn_HoaDon() { DV dV = dt.DVs.Where(s => s.MaDV == txtMaDVu.Text).FirstOrDefault(); if (dV != null) { DanhSachDichVu danhSachDichVu = dt.DanhSachDichVus.Where(s => s.MaDanhSach == cmbMaDanhSach.Text).FirstOrDefault(); if (danhSachDichVu != null) { CT_PhieuThue cT_PhieuThue = dt.CT_PhieuThues.Where(s => s.SoPhieuThue == Convert.ToInt32(danhSachDichVu.SoPhieuThue)). FirstOrDefault(); if (cT_PhieuThue != null) { PhieuThuePhong phieuThuePhong = dt.PhieuThuePhongs.Where(s => s.MaPhieuThue == cT_PhieuThue.MaPhieuThue).FirstOrDefault(); if (phieuThuePhong != null) { string a = phieuThuePhong.MaPhieuThue.ToString(); HoaDon hoaDon = dt.HoaDons.Where(s => s.MaPhieuThue == phieuThuePhong.MaPhieuThue).FirstOrDefault(); if (hoaDon != null) { return(false); } } } //MessageBox.Show("Dịch Vụ Này đã được thanh toán trong hóa đơn! không xóa được"); } } return(true); }
private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e) { if (checkIn_HoaDon() == true) { if (txtMaSuDung.Text == "") { MessageBox.Show("Bạn Chưa Chọn Hóa ĐƠn Xóa!"); } else { DV dV = dt.DVs.Where(s => s.MaDanhSach == txtMaSuDung.Text).FirstOrDefault(); if (dV != null) { MessageBox.Show("Không Thể Xóa"); } else { DialogResult xoa = MessageBox.Show("bạn có muốn xóa không?", "", MessageBoxButtons.YesNo); if (xoa == DialogResult.Yes) { dt.deleteDanhSach(txtMaSuDung.Text); MessageBox.Show("Xóa Thành Công !"); } } } } else { MessageBox.Show("Dịch Vụ Này Đã Thanh Toán Không Thể Xóa"); } DanhSachSuDungDichVu_Load(sender, e); }
public void ShowDistanceView(string distance, string time) { DV.TextToShow(string.Format("{0}, {1}", distance, time)); DV.View.Alpha = 0; DistanceViewIsShowing = true; mapView.AddSubview(DV.View); mapView.BringSubviewToFront(DV.View); UIView.BeginAnimations("foo"); UIView.SetAnimationDuration(0.25f); DV.View.Alpha = 0.75f; var frame = DV.View.Frame; //frame.Y -= DV.View.Frame.Height; frame.Y += DV.View.Frame.Height; DV.View.Frame = frame; UIView.CommitAnimations(); }
// TODO //public static Emblema obtenerEmblema(Reconocimiento reconocimiento) { // if (reconocimiento.emblema == null) { // reconocimiento.emblema = dao.obtenerEmblema(reconocimiento); // } // return reconocimiento.emblema; //} public static int crear(Reconocimiento rec) { int valoracionReconocedor = PuestoManager.obtener(rec.reconocedor).valoracion; int valoracionReconocido = PuestoManager.obtener(rec.reconocido).valoracion; rec.valoracion = valoracionReconocedor / valoracionReconocido; //if (TrabajadorManager.obtenerSectorJefes(rec.reconocedor).Count > 0) { // rec.valoracion++; //} rec.fecha = DateTime.Now; int result = dao.crear(rec); BitacoraManager.agregarMensajeControl("Reconocimiento creado: ", rec); NotificacionManager.enviar(new Notificacion { texto = "Te han reconocido", usuario = rec.reconocido }); DV.actualizarDV(); return(result); }
public static void actualizar(Usuario us) { UsuarioManager.actualizar(us); dao.agregarPuesto(us); DV.actualizarDV(); }
public IHttpActionResult PostDV(DV dV) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.DVs.Add(dV); try { db.SaveChanges(); } catch (DbUpdateException) { if (DVExists(dV.MA_DICH_VU)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = dV.MA_DICH_VU }, dV)); }
public static DV FirstOrder_DivisionMethod(Func <DV, D> f, DV startPoint, double accuracy, out int calcsF, out int calcsGradient) { DV[] x; double[] fx; return(FirstOrder_DivisionMethod(f, startPoint, accuracy, out calcsF, out calcsGradient, out x, out fx)); }
public static int crear(Objetivo obj) { obj.id = dao.crear(obj); DV.actualizarDV(); BitacoraManager.agregarMensajeControl("Nuevo objetivo", obj); return(obj.id); }
public static DV FirstOrder_DivisionMethod(Func <DV, D> f, DV startPoint, double accuracy, out int calcsF, out int calcsGradient, out DV[] x, out double[] fx) { //Counters calcsF = 0; //Count how many times the objective function was used. calcsGradient = 0; //Count how many times the gradient was calculated. //Define our X vector int maxIterations = 10000; x = new DV[maxIterations]; fx = new double[maxIterations]; //Pick an initial guess for x int i = 0; x[0] = startPoint; fx[0] = f(x[0]); calcsF++; //Loop through gradient steps until min points are found, recompute gradient and repeat. double alpha = 1; while (true) { //Compute next step, using previous step i++; //Step 1 - Determine the gradient DV gradient = AD.Grad(f, x[i - 1]); calcsGradient++; //Step 2 - Division method, to compute the new x[i] and fx[i] DV xPrev = x[i - 1]; Func <D, D> objFAlpha = delegate(D a) { DV xNext = xPrev - (a * gradient); return(f(xNext)); }; alpha = alpha * 0.8; double beta = UnimodalMinimization.DivisionSearch(objFAlpha, fx[i - 1], alpha, out fx[i], ref calcsF); x[i] = x[i - 1] - (beta * gradient); //Step 3 - Check if accuracy has been met. If so, then end. double magGradient = Math.Sqrt(AD.Pow(gradient[0], 2) + AD.Pow(gradient[1], 2)); if (magGradient < accuracy) { break; } //DV dx = AD.Abs(x[i] - x[i - 1]); //if (((err[0] < accuracy) && (err[1] < accuracy))) // break; } //Return the minimization point. x = x.Take(i + 1).ToArray(); fx = fx.Take(i + 1).ToArray(); return(x[i]); }
public IHttpActionResult GetDV(string id) { DV dV = db.DVs.Find(id); if (dV == null) { return(NotFound()); } return(Ok(dV)); }
public static int agregarNoCumplido(ObjetivoNoCumplido obj) { int id = dao.agregarNoCumplido(obj); DV.actualizarDV(); NotificacionManager.enviar( new Notificacion(Sesion.obtenerSesion().idioma.textos["failed_objective"] + ": " + obj.descripcion, obj.empleado) ); return(id); }
// TODO public static int crear(Usuario us) { if (UsuarioManager.crear(us) == 0) { return(0); } dao.agregarPuesto(us); DV.actualizarDV(); return(us.id); }
private void ErrorDV_Load(object sender, EventArgs e) { this.allControls = Program.GetAllControls(this); string[] erorrs = DV.obtenerErrores().Split('\n'); foreach (string error in erorrs) { listErrors.Items.Add(error); } IdiomaManager.cambiar(Sesion.obtenerSesion().idioma, Sesion.obtenerSesion().idioma.id, this); }
public IHttpActionResult DeleteDV(string id) { DV dV = db.DVs.Find(id); if (dV == null) { return(NotFound()); } db.DVs.Remove(dV); db.SaveChanges(); return(Ok(dV)); }
private void dataGridViewX1_CellClick(object sender, DataGridViewCellEventArgs e) { int i = dataGridViewX1.CurrentRow.Index; if (i >= 0 && i < dataGridViewX1.RowCount - 1) { mahd = dataGridViewX1.Rows[i].Cells[0].Value.ToString(); txtMaHoaDon.Text = dataGridViewX1.Rows[i].Cells[0].Value.ToString(); cmbNhanVien.Text = dataGridViewX1.Rows[i].Cells[1].Value.ToString(); cmbMaKH.Text = dataGridViewX1.Rows[i].Cells[2].Value.ToString(); cmbMaPhieuThue.Text = dataGridViewX1.Rows[i].Cells[3].Value.ToString(); string maphieu = dataGridViewX1.Rows[i].Cells[3].Value.ToString(); // dateTimePicker1.Value =Convert.ToDateTime( dataGridViewX1.Rows[i].Cells[0].Value.ToString()); txtTienPhong.Text = dataGridViewX1.Rows[i].Cells[4].Value.ToString(); txtSoNgay.Text = dataGridViewX1.Rows[i].Cells[5].Value.ToString(); txtTienDV.Text = dataGridViewX1.Rows[i].Cells[6].Value.ToString(); txtTongTien.Text = dataGridViewX1.Rows[i].Cells[7].Value.ToString(); dateTimePicker1.Value = Convert.ToDateTime(dataGridViewX1.Rows[i].Cells[8].Value.ToString()); dtNgayTraPhong.Value = Convert.ToDateTime(dateTimePicker1.Value.ToString()); CT_PhieuThue phieu = dt.CT_PhieuThues.FirstOrDefault(p => p.MaPhieuThue == maphieu); if (phieu != null) { DanhSachDichVu danhSachDichVu = dt.DanhSachDichVus.Where(s => s.SoPhieuThue == phieu.SoPhieuThue).FirstOrDefault(); if (danhSachDichVu != null) { txtDichVu.Text = danhSachDichVu.MaDanhSach.ToString(); try { DV dV = dt.DVs.Where(s => s.MaDanhSach == danhSachDichVu.MaDanhSach).FirstOrDefault(); LoaiDV loaiDV = dt.LoaiDVs.Where(s => s.MaLoaiDV == dV.MaLoaiDV).FirstOrDefault(); if (loaiDV != null) { TienDVResult tienDVResult = dt.TienDV(txtDichVu.Text).FirstOrDefault(); txtTienDV.Text = tienDVResult.Column1.ToString(); // MessageBox.Show(tienDVResult.Column1.ToString()); } } catch { } } } dateNgayThuePhong.Value = Convert.ToDateTime(phieu.NgayNhanPhong.Value.ToString()); } // MessageBox.Show(i.ToString()); // cmbNhanVien.SelectedValue = dataGridViewX1.Rows[i].Cells[0].Value.ToString(); }
public static void Main(string[] args) { // You can compute the value of the derivative of F at a point D da = AD.Diff(F, 2.3); // Or, you can generate a derivative function which you may use for many evaluations // dF is the derivative function of F var dF = AD.Diff(F); // Evaluate the derivative function at different points D db = dF(2.3); D dc = dF(1.4); // Construction and casting of D (scalar) values // Construct new D D a = new D(4.1); // Cast double to D D b = (D)4.1; // Cast D to double double c = (double)b; // Construction and casting of DV (vector) values // Construct new DV DV va = new DV(new double[] { 1, 2, 3 }); // Cast double[] to DV double[] vaa = new double[] { 1, 2, 3 }; DV vb = (DV)vaa; // Cast DV to double[] double[] vc = (double[])vb; // Construction and casting of DM (matrix) values // Construct new DM DM ma = new DM(new double[, ] { { 1, 2 }, { 3, 4 } }); // Cast double[,] to DM double[,] maa = new double[, ] { { 1, 2 }, { 3, 4 } }; DM mb = (DM)maa; // Cast DM to double[,] double[,] mc = (double[, ])mb; }
private Boolean modulo11CNPJ(String dado) { if (dado.Length < 14) { return(false); } int soma = 0, digito = 0, contar = 0, multiplica = 6; String DV; String digitos = dado; foreach (var item in dado) { digito = Convert.ToInt16(Convert.ToString(item)); soma += (multiplica * digito); contar++; multiplica = (multiplica == 9) ? 2 : multiplica + 1; if (contar > dado.Length - 3) { break; } } DV = ((soma % 11) >= 10) ? "0" : Convert.ToString(soma % 11); soma = 0; contar = 0; multiplica = 5; foreach (var item in dado) { digito = Convert.ToInt16(Convert.ToString(item)); soma += (multiplica * digito); contar++; multiplica = (multiplica == 9) ? 2 : multiplica + 1; if (contar > dado.Length - 2) { break; } } DV += ((soma % 11) >= 10) ? "0" : Convert.ToString(soma % 11); String DVOriginal = Convert.ToString(digitos[(digitos.Length - 2)]) + Convert.ToString(digitos[(digitos.Length - 1)]); return(DV.Equals(DVOriginal)); }
private void btnXoa_Click(object sender, EventArgs e) { DV dV = dt.DVs.Where(s => s.MaLoaiDV == txtMaLoaiDV.Text).FirstOrDefault(); if (dV != null) { MessageBox.Show("Không xóa được !", "", MessageBoxButtons.OK); } else { DialogResult xoa = MessageBox.Show("bạn có chắc muốn xóa không?", "", MessageBoxButtons.YesNo); if (xoa == DialogResult.Yes) { dt.xoaDV(txtMaLoaiDV.Text); MessageBox.Show("xóa thành công?", "", MessageBoxButtons.OK); } } }
public static void MakeDataFile(string file, Func <DV, D> f, DV start, DV end, D accuracy) { //Open file for editing StreamWriter theFile = new StreamWriter(file); //Generate data and add to file for (D x1 = start[0]; x1 <= end[0]; x1 += accuracy) { for (D x2 = start[1]; x2 <= end[1]; x2 += accuracy) { //Create point and results DV thePoint = new DV(new D[] { x1, x2 }); D fx = f(thePoint); //Add to file theFile.WriteLine("{0}\t{1}\t{2}", (double)x1, (double)x2, (double)fx); } } //Save file theFile.Close(); }
private Boolean modulo11CPF(String dado) { int soma = 0, digito = 0, contar = 1; String DV; String digitos = dado.Replace("/", ""); foreach (var item in digitos) { digito = Convert.ToInt16(Convert.ToString(item)); soma += (contar * digito); contar++; if (contar > dado.Length - 2) { break; } } DV = ((soma % 11) >= 10) ? "0" : Convert.ToString(soma % 11); soma = 0; contar = 0; foreach (var item in digitos) { digito = Convert.ToInt16(Convert.ToString(item)); soma += (contar * digito); contar++; if (contar > dado.Length - 2) { break; } } DV += ((soma % 11) >= 10) ? "0" : Convert.ToString(soma % 11); String DVOriginal = Convert.ToString(digitos[(digitos.Length - 2)]) + Convert.ToString(digitos[(digitos.Length - 1)]); return(DV.Equals(DVOriginal)); }
internal override async void Drawing() { if (OwnerChart == null || OwnerChart.ItemsSource == null || OwnerChart.XAxis == null || OwnerChart.YAxis == null) { return; } IEnumerable <IList> items = OwnerChart.ItemsSource; IAxis xaxis = OwnerChart.XAxis; IAxis yaxis = OwnerChart.YAxis; if (OwnerChart.X < 0) { OwnerChart.X = 0; } int x = OwnerChart.X; if (OwnerChart.Y < 0) { OwnerChart.Y = 1; } int y = OwnerChart.Y; using (var getdatatask = xaxis.GetHistogramViewData(items, x, Count)) { var datas = await getdatatask; if (datas.Count() <= 0) { var tempdc = DV.RenderOpen(); tempdc.DrawLine(new Pen(this.Stroke, 0), new Point(0, 0), new Point(0, 0)); tempdc.Close(); return; } var maxy = datas.Max(p => p.Value); yaxis.Max = maxy * 1.2; yaxis.Min = 0; yaxis.Drawing(); var height = this.ActualHeight; Func <double, ValueLocationConvertParam, double> YGetLocation = yaxis.GetValueLocation; var yconvert = yaxis.GetConvertParam(); var task = Task.Run(() => { var streamGeometry = new StreamGeometry() { FillRule = FillRule.EvenOdd }; using (StreamGeometryContext sgc = streamGeometry.Open()) { List <Point> points = new List <Point>(); foreach (var data in datas) { var yvalue = YGetLocation(data.Value, yconvert); if (double.IsNaN(data.Key[0]) || double.IsInfinity(data.Key[0]) || double.IsNaN(data.Key[1]) || double.IsInfinity(data.Key[1]) || double.IsNaN(yvalue) || double.IsInfinity(yvalue)) { continue; } points.Add(new Point(data.Key[0], yvalue)); points.Add(new Point(data.Key[1], yvalue)); } if (points.Count > 0) { points.Add(new Point(points[points.Count - 1].X, height)); points.Add(new Point(points[0].X, height)); sgc.BeginFigure(new Point(points[0].X, height), true, true); sgc.PolyLineTo(points, false, false); } else { sgc.BeginFigure(new Point(0, 0), true, true); sgc.LineTo(new Point(0, 0), false, false); } sgc.Close(); } streamGeometry.Freeze(); return(streamGeometry); }); var geometryTemp = await task; task.Dispose(); var dc = DV.RenderOpen(); base.ClearTransform(); dc.DrawGeometry(this.Fill, new Pen(this.Stroke, 1), geometryTemp); dc.Close(); } }
public static DV FirstOrder_OneDimensionalMethod(Func <DV, D> f, DV startPoint, double accuracy, out int calcsF, out int calcsGradient, out DV[] x, out double[] fx) { //Counters calcsF = 0; //Count how many times the objective function was used. calcsGradient = 0; //Count how many times the gradient was calculated. //Define our X vector int maxIterations = 1000; x = new DV[maxIterations]; fx = new double[maxIterations]; //Pick an initial guess for x int i = 0; x[i] = startPoint; fx[i] = f(x[i]); calcsF++; //Loop through gradient steps until min points are found, recompute gradient and repeat. while (true) { //Compute next step, using previous step i++; //Return failed results if (double.IsNaN(x[i - 1][0]) || double.IsNaN(x[i - 1][1]) || (i == maxIterations)) { x = x.Take(i).ToArray(); fx = fx.Take(i).ToArray(); return(null); } //Step 1 - Determine the gradient DV gradient = 0 - AD.Grad(f, x[i - 1]); calcsGradient++; DV direction = gradient / Math.Sqrt(AD.Pow(gradient[0], 2) + AD.Pow(gradient[1], 2)); //Normalize Gradient //Step 2 - Build an objective function using the gradient. // This objective function moves downward in the direction of the gradient. // It uses golden ratio optimization to find the minimum point in this direction DV xPrev = x[i - 1]; Func <D, D> objFStep = delegate(D alpha) { DV xNew = xPrev + (alpha * direction); return(f(xNew)); }; var stepSearchResults = UnimodalMinimization.goldenRatioSearch(objFStep, 0, 1, accuracy); //alpha can only be between 0 and 1 double step = (stepSearchResults.a + stepSearchResults.b) / 2; //The step required to get to the bottom calcsF += stepSearchResults.CalculationsUntilAnswer; //The number of calculations of f that were required. //Step 3 - Move to the discovered minimum point x[i] = x[i - 1] + (step * direction); fx[i] = f(x[i]); calcsF++; //Step 4 - Check if accuracy has been met. If so, then end. double magGradient = Math.Sqrt(AD.Pow(gradient[0], 2) + AD.Pow(gradient[1], 2)); if (magGradient < accuracy) { break; } DV dx = AD.Abs(x[i] - x[i - 1]); if (((dx[0] < accuracy) && (dx[1] < accuracy))) { break; } } //Return the minimization point. x = x.Take(i + 1).ToArray(); fx = fx.Take(i + 1).ToArray(); return(x[i]); }
public static DV SecondOrder_DivisionMethod(Func <DV, D> f, DV startPoint, double accuracy, out int calcsF, out int calcsGradient, out int calcsHessian, out DV[] x, out double[] fx) { //Counters calcsF = 0; //Count how many times the objective function was used. calcsGradient = 0; //Count how many times the gradient was calculated. calcsHessian = 0; //Count how many times the second gradient was calculated. //Define our X vector int maxIterations = 10000; x = new DV[maxIterations]; fx = new double[maxIterations]; //Pick an initial guess for x int i = 0; x[i] = startPoint; fx[i] = f(x[i]); calcsF++; //Loop through gradient steps until zeros are found double alpha = 1; while (true) { //Compute next step, using previous step i++; //Step 1 - Determine the gradients DV gradient = AD.Grad(f, x[i - 1]); calcsGradient++; var hess = AD.Hessian(f, x[i - 1]); calcsHessian++; //Step 2 - Compute full step (alpha = 1). Loop through every entry in the DV and compute the step for each one. List <D> listSteps = new List <D>(); while (true) { try { int c = listSteps.Count; listSteps.Add(-gradient[c] / hess[c, c]); // first-gradient divided by second-gradient } catch { break; } } DV fullStep = new DV(listSteps.ToArray()); //Step 3 - Division method, to compute the new x[i] and fx[i] DV xPrev = x[i - 1]; Func <D, D> objFAlpha = delegate(D a) { DV xNext = xPrev + (a * fullStep); return(f(xNext)); }; alpha = alpha * 0.8; double beta = UnimodalMinimization.DivisionSearch(objFAlpha, fx[i - 1], alpha, out fx[i], ref calcsF); x[i] = x[i - 1] + (beta * fullStep); //Check if accuracy has been met double magGradient = Math.Sqrt(AD.Pow(gradient[0], 2) + AD.Pow(gradient[1], 2)); if (magGradient < accuracy) { break; } DV dx = AD.Abs(x[i] - x[i - 1]); if ((dx[0] < accuracy * 0.1) && (dx[1] < accuracy * 0.1)) { break; } } //Return the minimization point x = x.Take(i + 1).ToArray(); fx = fx.Take(i + 1).ToArray(); return(x[i]); }