mirror of
https://github.com/Lendaia/oe-alga-feladatok.git
synced 2026-04-23 12:26:07 +01:00
finalfinal
This commit is contained in:
@@ -1,193 +1,4 @@
|
||||
// using System;
|
||||
|
||||
// namespace OE.ALGA.Optimalizalas
|
||||
// {
|
||||
// public class VisszalepesesOptimalizacio<T>
|
||||
// {
|
||||
// public int n;
|
||||
// public int[] M;
|
||||
// public T[,] R;
|
||||
// public Func<int, T, bool> ft;
|
||||
// public Func<int, T, T[], bool> fk;
|
||||
// public Func<T[], float> josag;
|
||||
|
||||
// public int Lepesszam { get; set;} = 0;
|
||||
|
||||
// public VisszalepesesOptimalizacio(int n, int[] M, T[,] R, Func<int, T, bool> ft, Func<int, T, T[], bool> fk, Func<T[], float> josag)
|
||||
// {
|
||||
// this.n = n;
|
||||
// this.M = M;
|
||||
// this.R = R;
|
||||
// this.ft = ft;
|
||||
// this.fk = fk;
|
||||
// this.josag = josag;
|
||||
// }
|
||||
|
||||
// public T[] OptimalisMegoldas()
|
||||
// {
|
||||
// int szint = 0;
|
||||
// T[] E = new T[n];
|
||||
// bool van = false;
|
||||
// T[] O = new T[n];
|
||||
// Backtrack(szint, ref E, ref van, ref O);
|
||||
// if (van)
|
||||
// {
|
||||
// return O;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// throw new Exception("Nincs megoldas");
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// virtual public void Backtrack(int szint, ref T[] E, ref bool van, ref T[] O)
|
||||
// {
|
||||
// int i = 0;
|
||||
// while(i < M[szint])
|
||||
// {
|
||||
// Lepesszam++;
|
||||
// i++;
|
||||
// if (ft(szint, R[szint, i]))
|
||||
// {
|
||||
// if(fk(szint, R[szint, i], E))
|
||||
// {
|
||||
// E[szint] = R[szint, i];
|
||||
|
||||
// if (szint == n)
|
||||
// {
|
||||
// if ((!van) || josag(E) > josag(O))
|
||||
// {
|
||||
// O = E;
|
||||
// }
|
||||
// van = true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Backtrack(szint+1, ref E, ref van, ref O);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// public class VisszalepesesHatizsakPakolas
|
||||
// {
|
||||
// HatizsakProblema problema;
|
||||
// public int LepesSzam {get; set;}
|
||||
|
||||
// public VisszalepesesHatizsakPakolas(HatizsakProblema problema)
|
||||
// {
|
||||
// this.problema = problema;
|
||||
// }
|
||||
// virtual public bool[] OptimalisMegoldas()
|
||||
// {
|
||||
// int[] M = new int[problema.N];
|
||||
|
||||
// bool[,] R = new bool[problema.N, 2];
|
||||
// for (int i = 0; i < problema.N; i++)
|
||||
// {
|
||||
// M[i] = 2;
|
||||
// R[i, 0] = true;
|
||||
// R[i, 1] = false;
|
||||
// }
|
||||
// VisszalepesesOptimalizacio<bool> visszalepesesoptimalizacio = new VisszalepesesOptimalizacio<bool>(problema.N, M, R, Ft, Fk, Josag);
|
||||
// bool[] eredmeny = visszalepesesoptimalizacio.OptimalisMegoldas();
|
||||
// LepesSzam = visszalepesesoptimalizacio.Lepesszam;
|
||||
// return eredmeny;
|
||||
// }
|
||||
// public float OptimalisErtek()
|
||||
// {
|
||||
// return problema.OsszErtek(OptimalisMegoldas());
|
||||
// }
|
||||
// private float Josag(bool[] pakolas)
|
||||
// {
|
||||
// float ertek = 0;
|
||||
// if (!problema.Ervenyes(pakolas))
|
||||
// {
|
||||
// ertek = -1;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ertek = problema.OsszErtek(pakolas);
|
||||
// }
|
||||
// return ertek;
|
||||
// }
|
||||
// private bool Ft(int egesz, bool logikai)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// private bool Fk(int egesz, bool logikai, bool[] tomb)
|
||||
// {
|
||||
// int weight = 0;
|
||||
// for (int i = 0; i < problema.N; i++)
|
||||
// {
|
||||
// if(tomb[i])
|
||||
// {
|
||||
// weight += problema.W[i];
|
||||
// }
|
||||
// }
|
||||
// return (weight <= problema.Wmax);
|
||||
// }
|
||||
|
||||
// }
|
||||
// public class SzetvalasztasEsKorlatozasOptimalizacio<T> : VisszalepesesOptimalizacio<T>
|
||||
// {
|
||||
// public Func<int, T[], int> fb;
|
||||
// public SzetvalasztasEsKorlatozasOptimalizacio(Func<int, T[], int> fb, int n, int[] M, T[,] R, Func<int, T, bool> ft, Func<int, T, T[], bool> fk, Func<T[], float> josag) : base(n, M, R, ft, fk, josag)
|
||||
// {
|
||||
// this.fb = fb;
|
||||
// }
|
||||
|
||||
// public override void Backtrack(int szint, ref T[] E, ref bool van, ref T[] O)
|
||||
// {
|
||||
// int i = 0;
|
||||
// while(i < M[szint])
|
||||
// {
|
||||
// Lepesszam++;
|
||||
// i++;
|
||||
// if (ft(szint, R[szint, i]))
|
||||
// {
|
||||
// if(fk(szint, R[szint, i], E) && fb(szint, O) > 6)
|
||||
// {
|
||||
// E[szint] = R[szint, i];
|
||||
|
||||
// if (szint == n)
|
||||
// {
|
||||
// if ((!van) || josag(E) > josag(O))
|
||||
// {
|
||||
// O = E;
|
||||
// }
|
||||
// van = true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Backtrack(szint+1, ref E, ref van, ref O);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// public class SzetvalasztasEsKorlatozasHatizsakPakolas : VisszalepesesHatizsakPakolas
|
||||
// {
|
||||
// public SzetvalasztasEsKorlatozasHatizsakPakolas(HatizsakProblema problema) : base(problema)
|
||||
// {
|
||||
// }
|
||||
// public override bool[] OptimalisMegoldas()
|
||||
// {
|
||||
// bool[] asd = new bool[2] {true, true};
|
||||
// return asd;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace OE.ALGA.Optimalizalas
|
||||
{
|
||||
@@ -244,16 +55,6 @@ namespace OE.ALGA.Optimalizalas
|
||||
|
||||
public T[] OptimalisMegoldas()
|
||||
{
|
||||
// T[] E = new T[n];
|
||||
// T[] O = new T[n];
|
||||
// bool van = false;
|
||||
|
||||
// Backtrack(0, ref E, ref van, ref O);
|
||||
|
||||
// if (van)
|
||||
// return O;
|
||||
// else
|
||||
// throw new NincsElKivetel();
|
||||
|
||||
int szint = 0;
|
||||
T[] E = new T[n];
|
||||
|
||||
Reference in New Issue
Block a user