public JEVisAttributeWS(JEVisDataSourceWS ds, JsonAttribute json)
        {
            this.ds   = ds;
            this.json = json;

            Optimization.getInstance().addAttribute(this);
        }
        private void ChangeVoxelMaterial(DetectedPlaneVisualizer newPlane, HashEntry hashEntry, Material material)
        {
            switch (Optimization.DoRayCastFromHashEntryToPlane(newPlane, hashEntry))
            {
            case Optimization.VoxelPlaneCollision.DOWN:
                //hashEntry.voxel.gameObject.GetComponent<MeshRenderer>().material = m_CustomMaterialRed;
                m_Reconstructor.GetSpatialHashing().setRemoved(hashEntry.hash);
                break;

            case Optimization.VoxelPlaneCollision.UP:
                //hashEntry.voxel.gameObject.GetComponent<MeshRenderer>().material = m_CustomMaterialGreen;
                m_Reconstructor.GetSpatialHashing().setRemoved(hashEntry.hash);
                break;

            case Optimization.VoxelPlaneCollision.INSIDE:
                //hashEntry.voxel.gameObject.GetComponent<MeshRenderer>().material = material;
                m_Reconstructor.GetSpatialHashing().RemoveCollider(hashEntry);
                m_Reconstructor.GetSpatialHashing().setRemoved(hashEntry.hash);
                //m_Reconstructor.GetSpatialHashing().RemoveFromTable(hashEntry.hash);
                break;

            default:
                break;
            }
        }
示例#3
0
        public Rmsd(DCDFile dcd, string alignFile, bool flag, PDBMODE allAtoms, string refJuryProfile = null)
            : base(dcd, alignFile, flag, refJuryProfile)
        {
            DCDReader readDCD = new DCDReader(dcd);
                dirSettings.Load();
            
            pdbs = new PDBFiles();
            readDCD.DCDPrepareReading(dcd.dcdFile, dcd.pdbFile);
            int counter = 0;
            bool cont = true;
            do
            {
                MemoryStream mStream = new MemoryStream();
                StreamWriter wStream = new StreamWriter(mStream);
                cont=readDCD.ReadAndSavePDB(wStream);
                string name = "Model" + counter++;
                mStream.Position = 0;
                pdbs.AddPDB(mStream, allAtoms, name);
            }
            while(cont);

            readDCD.FinishDCDReading();

            pdbs.FindReferenceSeq();
            pdbs.MakeAlignment(alignFile);
            if(pdbs is ErrorBase)
                AddErrors(pdbs.errors);
            opt = new Optimization();

            structNames = CheckAvailableStructures();
            order = true;
        }
示例#4
0
 public NetImguiTarget()
 {
     DevEnv       = DevEnv.vs2019;
     Platform     = Platform.win64;
     Optimization = Optimization.Debug | Optimization.Release;
     Compiler     = Compiler.VS | Compiler.Clang;
 }
示例#5
0
        private static Task <AssemblyContentDescription> CreateContentDescriptionAsync(
            IMethod method,
            IEnumerable <ITypeMember> memberRoots,
            IEnumerable <IType> typeRoots,
            ClrAssembly assembly)
        {
            // TODO: deduplicate this logic (it also appears in IL2LLVM and ILOpt)

            var typeSystem = assembly.Resolver.TypeEnvironment;
            var pipeline   = new Optimization[]
            {
                new ConstantPropagation(),
                MemoryAccessElimination.Instance,
                DeadValueElimination.Instance,
                new JumpThreading(true),
                SwitchSimplification.Instance,
                DuplicateReturns.Instance,
                TailRecursionElimination.Instance,
                BlockFusion.Instance
            };

            var optimizer = new OnDemandOptimizer(
                pipeline,
                m => GetInitialMethodBody(m, typeSystem));

            return(AssemblyContentDescription.CreateTransitiveAsync(
                       new SimpleName("kernel").Qualify(),
                       assembly.Attributes,
                       null,
                       new ITypeMember[] { method }.Concat(memberRoots),
                       typeRoots,
                       optimizer));
        }
示例#6
0
        private void ThreadLibrary(object o)
        {
            int[] inx = (int [])o;



            if (fragBagLibrary[0].GetLength(0) + inx[2] > res.Count)
            {
                resetEvents[inx[3]].Set();
                return;
            }

            for (int n = 0; n < fragBagLibrary[0].GetLength(0); n++)
            {
                chunk[inx[3]][n, 0] = res[inx[2] + n].Atoms[0].Position.X;
                chunk[inx[3]][n, 1] = res[inx[2] + n].Atoms[0].Position.Y;
                chunk[inx[3]][n, 2] = res[inx[2] + n].Atoms[0].Position.Z;
            }
            Optimization.CenterMol(chunk[inx[3]], center[inx[3]]);

            for (int j = inx[0]; j < inx[1]; j++)
            {
                distData[j] = Optimization.Rmsd(fragBagLibrary[j], chunk[inx[3]], false);
            }

            resetEvents[inx[3]].Set();
        }
示例#7
0
        public virtual bool MigrateFieldsToVersion4(ScrollRect scrollRect, out string error, out string additionalInfoOnSuccess)
        {
            additionalInfoOnSuccess = null;
            if (!scrollRect)
            {
                error = "ScrollRect component not found. It's needed during the migration. If this is unexpected, maybe this adapter already migrated?";
                return(false);
            }
            if (!scrollRect.content)
            {
                error = "ScrollRect.content wasn't set";
                return(false);
            }
            Content = scrollRect.content;

            // Commented: already serialized
            //Viewport = scrollRect.viewport;

            if (scrollRect.horizontal == scrollRect.vertical)
            {
                error = "Both horizontal and vertical properties of the ScrollRect are set to " + scrollRect.horizontal + ". Exactly one of them should be active";
                return(false);
            }
            Orientation = scrollRect.horizontal ? OrientationEnum.HORIZONTAL : OrientationEnum.VERTICAL;

            if (scrollRect.horizontalScrollbar && scrollRect.verticalScrollbar)
            {
                additionalInfoOnSuccess = "Both horizontal and vertical scrollbars are assigned. Only the " + (Orientation.ToString().ToLowerInvariant()) + " one was grabbed";
                Scrollbar = Orientation == OrientationEnum.HORIZONTAL ? scrollRect.horizontalScrollbar : scrollRect.verticalScrollbar;
            }

            ScrollSensivity = scrollRect.scrollSensitivity;

            if (effects == null)
            {
                effects = new Effects();
            }
            //effects.contentVisual = contentVisual;
            //effects.ContentVisualParallaxEffect = contentVisualParallaxEffect;
            //effects.elasticMovement = elasticMovement;
            effects.galleryEffectAmount        = _GalleryEffectAmount;
            effects.galleryEffectViewportPivot = _GalleryEffectViewportPivot;
            //effects.inertia = inertia;
            //effects.inertiaDecelerationRate = inertiaDecelerationRate;
            //effects.maxSpeed = maxSpeed;
            effects.loopItems = _LoopItems;
            //effects.pullElasticity = pullElasticity;
            //effects.releaseTime = releaseTime;

            if (optimization == null)
            {
                optimization = new Optimization();
            }
            optimization.recycleBinCapacity = _RecycleBinCapacity;
            //optimization.updateMode = _UpdateMode;

            error = null;
            return(true);
        }
示例#8
0
        public override void CalcDistMatrix(List <string> structures)
        {
            hashIndex = new Dictionary <string, int>(structures.Count);
            for (int i = 0; i < structures.Count; i++)
            {
                if (!pdbs.molDic.ContainsKey(structures[i]))
                {
                    throw new Exception("There is no pdb file or file is incorrect for the structure: " + structures[i]);
                }
                hashIndex.Add(structures[i], i);
            }
            Settings set = new Settings();

            set.Load();
            int threadNumbers = set.numberOfCores;

            this.structures = new List <string>(structures);

            int part = structures.Count * (structures.Count + 1) / (2 * threadNumbers) + 1;

            distanceMatrix = new int[structures.Count * (structures.Count + 1) / 2];
            indexList      = new List <KeyValuePair <int, int> > [threadNumbers];
            optList        = new Optimization[threadNumbers];
            for (int n = 0; n < threadNumbers; n++)
            {
                indexList[n] = new List <KeyValuePair <int, int> >(part);
                optList[n]   = new Optimization();
            }

            int count = 0;

            foreach (var dim1 in structures)
            {
                foreach (var dim2 in structures)
                {
                    if (hashIndex[dim1] <= hashIndex[dim2])
                    {
                        indexList[count].Add(new KeyValuePair <int, int>(hashIndex[dim1], hashIndex[dim2]));
                        if (part <= indexList[count].Count)
                        {
                            count++;
                        }
                    }
                }
            }
            PreparePDBPos();
            resetEvents = new ManualResetEvent[threadNumbers];
            for (int n = 0; n < threadNumbers; n++)
            {
                paramsThread p = new paramsThread();
                p.k = n;
                ThreadPool.QueueUserWorkItem(new WaitCallback(CalcMatrix), (object)p);
                resetEvents[n] = new ManualResetEvent(false);
            }
            for (int j = 0; j < threadNumbers; j++)
            {
                resetEvents[j].WaitOne();
            }
        }
示例#9
0
        public static CustomTarget DefaultTargets()
        {
            Platform     p  = Platform.win64;
            DevEnv       de = DevEnv.vs2019;
            Optimization o  = (Optimization.Debug | Optimization.Release | Optimization.Retail);

            return(new CustomTarget(p, de, o));
        }
示例#10
0
        public JEVisAttributeWS(JEVisDataSourceWS ds, JsonAttribute json, Long obj)
        {
            this.ds   = ds;
            this.json = json;
            this.json.setObjectID(obj);

            Optimization.getInstance().addAttribute(this);
        }
示例#11
0
        public override int[] GetDistance(string refStructure, List <string> structures)
        {
            int[] dist = new int[structures.Count];
            int   i    = 0;

            distanceMatrix = new int[structures.Count];
            Settings set = new Settings();

            set.Load();
            int threadNumbers = set.numberOfCores;

            this.structures = new List <string>(structures);
            int part = this.structNames.Count / threadNumbers;

            indexList = new List <KeyValuePair <int, int> > [threadNumbers];
            optList   = new Optimization[threadNumbers];
            for (int j = 0; j < indexList.Length; j++)
            {
                indexList[j] = new List <KeyValuePair <int, int> >();
                optList[j]   = new Optimization();
            }
            int count = 0;

            for (int j = 0; j < this.structNames.Count; j++)
            {
                if (indexList[count].Count < part)
                {
                    KeyValuePair <int, int> aux = new KeyValuePair <int, int>(j, 0);
                    indexList[count].Add(aux);
                }
                else
                {
                    count++;
                }
            }
            this.structures.Add(refStructure);
            resetEvents = new ManualResetEvent[threadNumbers];
            for (int n = 0; n < threadNumbers; n++)
            {
                int k = n;
                ThreadPool.QueueUserWorkItem(new WaitCallback(CalcMatrixList), (object)k);
                resetEvents[n] = new ManualResetEvent(false);
            }
            for (int j = 0; j < threadNumbers; j++)
            {
                resetEvents[j].WaitOne();
            }

            for (int j = 0; j < this.structures.Count - 1; j++)
            {
                dist[j] = distanceMatrix[j];
            }

            return(dist);
        }
示例#12
0
    // Use this to initialize any variables or game state before the game starts.
    void Awake()
    {
        //check attached gameObjects
        GlobalGO = GameObject.Find("MasterGameController");     //check that this script is attached to a game object named "Global"

        menu          = GetComponent <Menu>();                  //initialize menu
        game          = GetComponent <Game>();                  //initialize game
        input         = GetComponent <Inputs>();                //initialize input
        screensize    = GetComponent <Screensize>();            //initialize screen
        optimizations = GetComponent <Optimization>();          //initialize optimization
    }
示例#13
0
        public async Task StrassenParallelTest_AssertMustBeEqual()
        {
            // Arrange
            Matrix <int> matrixA  = BuildMatrix.RandomInt(1024, 1024, 1, 2);
            Matrix <int> matrixB  = BuildMatrix.RandomInt(1024, 1024, 1, 2);
            Matrix <int> expected = matrixA * matrixB;

            // Act
            var actual = await Optimization.MultiplyStrassenAsync(matrixA, matrixB);

            // Assert
            Assert.Equal(expected, actual);
        }
示例#14
0
        public void StrassenTest_AssertMustBeEqual()
        {
            // Arrange
            Matrix <int> matrixA  = BuildMatrix.RandomInt(1024, 1024, 1, 2);
            Matrix <int> matrixB  = BuildMatrix.RandomInt(1024, 1024, 1, 2);
            Matrix <int> expected = matrixA * matrixB;

            // Act
            var actual = Optimization.MultiplyStrassen(matrixA, matrixB);

            // Assert
            Assert.Equal(expected, actual);
        }
示例#15
0
        /// <summary>
        /// Calls the API with the source file as post data.
        /// </summary>
        /// <param name="source">The content of the source file.</param>
        /// <returns>The Xml response from the Google API.</returns>
        private static XmlDocument CallApi(string source, Optimization optimization = Optimization.SIMPLE_OPTIMIZATIONS)
        {
            using (WebClient client = new WebClient())
            {
                client.Headers.Add("content-type", "application/x-www-form-urlencoded");
                string data   = string.Format(PostData, HttpUtility.UrlEncode(source), optimization.ToString());
                string result = client.UploadString(ApiEndpoint, data);

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(result);
                return(doc);
            }
        }
示例#16
0
        public Rmsd(List <string> fileNames, string alignFile, bool flag, PDBMODE allAtoms, string refJuryProfile = null)
            : base(fileNames, alignFile, flag, refJuryProfile)
        {
            dirSettings.Load();
            pdbs = new PDBFiles();

            pdbs.AddPDB(fileNames, allAtoms);
            pdbs.FindReferenceSeq();
            pdbs.MakeAlignment(null);
            opt         = new Optimization();
            structNames = CheckAvailableStructures();
            order       = true;
        }
示例#17
0
        private ParticleState BestNeighborState()
        {
            ParticleState best = Neighborhood[0].PersonalBest;

            foreach (var particle in Neighborhood)
            {
                if (Optimization.IsBetter(particle.PersonalBest.FitnessValue, best.FitnessValue) < 0)
                {
                    best = particle.PersonalBest;
                }
            }

            return(best);
        }
示例#18
0
        /// <summary>
        /// Compresses the specified file using Google's Closure Compiler algorithm.
        /// <remarks>
        /// The file to compress must be smaller than 200 kilobytes.
        /// </remarks>
        /// </summary>
        /// <param name="file">The absolute file path to the javascript file to compress.</param>
        /// <returns>A compressed version of the specified JavaScript file.</returns>
        public string Compress(string file, Optimization optimization = Optimization.SIMPLE_OPTIMIZATIONS)
        {
            string source = File.ReadAllText(file);

            _xml = CallApi(source);
            try
            {
                return(_xml.SelectSingleNode("//compiledCode").InnerText);
            }
            catch (Exception ex)
            {
                return("");
            }
        }
示例#19
0
 public Target(
     Platform platform,
     DevEnv devEnv,
     Optimization optimization,
     Blob blob,
     BuildSystem buildSystem
     )
 {
     Platform     = platform;
     DevEnv       = devEnv;
     Optimization = optimization;
     Blob         = blob;
     BuildSystem  = buildSystem;
 }
示例#20
0
 public CommonTarget(
     Platform platform,
     DevEnv devEnv,
     Optimization optimization,
     DotNetFramework dotNetFramework,
     DotNetOS dotNetOS
     )
 {
     Platform        = platform;
     DevEnv          = devEnv;
     Optimization    = optimization;
     DotNetFramework = dotNetFramework;
     DotNetOS        = dotNetOS;
 }
示例#21
0
        /// <summary>
        /// Sets the objective function for this linear problem.
        /// Variables are referenced by indexes from the given list of coefficients.
        /// </summary>
        /// <param name="optimization">Minimize or maximize the eqaution?</param>
        /// <param name="coefficients">The variables and coefficients of the equation.</param>
        public void SetObjective(Optimization optimization, IDictionary <object, double> coefficients)
        {
            objOptimization = optimization;

            foreach (var variable in coefficients.Keys)
            {
                if (!variablesDict.Contains(variable))
                {
                    variablesDict.Add(variable);
                }

                var index = variablesDict.IndexOf(variable);
                objCoefficients[index] = coefficients[variable];
            }
        }
 public CommonTarget(
     Platform platform,
     DevEnv devEnv,
     Optimization optimization,
     Blob blob,
     BuildSystem buildSystem,
     Android.AndroidBuildType androidBuildType
     )
 {
     Platform         = platform;
     DevEnv           = devEnv;
     Optimization     = optimization;
     Blob             = blob;
     BuildSystem      = buildSystem;
     AndroidBuildType = androidBuildType;
 }
示例#23
0
 public CommonTarget(
     Platform platform,
     Compiler compiler,
     DevEnv devEnv,
     Optimization optimization,
     Blob blob,
     BuildSystem buildSystem
     )
 {
     Platform     = platform;
     Compiler     = compiler;
     DevEnv       = devEnv;
     Optimization = optimization;
     Blob         = blob;
     BuildSystem  = buildSystem;
 }
示例#24
0
 public Target(
     Platform platform,
     DevEnv devEnv,
     Optimization optimization,
     OutputType outputType     = OutputType.Lib,
     Blob blob                 = Blob.NoBlob,
     BuildSystem buildSystem   = BuildSystem.MSBuild,
     DotNetFramework framework = DotNetFramework.v3_5
     )
 {
     Platform     = platform;
     DevEnv       = devEnv;
     Optimization = optimization;
     OutputType   = outputType;
     Framework    = framework;
     BuildSystem  = buildSystem;
     Blob         = blob;
 }
示例#25
0
文件: Form1.cs 项目: canter96/diplom
        private void button3_Click(object sender, EventArgs e)
        {
            parallel   = true;
            consistent = false;
            OutputGraphics outputGraphics = new OutputGraphics();

            outputGraphics.Text = "Паралельна оптимізація КД";

            Optimization optimization = new Optimization(classX1, classX2, classX3, classX4, classX5);

            optimization.main("parallel");

            outputGraphics.chart2.Series.Clear();
            outputGraphics.chart3.Series.Clear();
            outputGraphics.chart4.Series.Clear();
            outputGraphics.main(outputGraphics.chart1, optimization.E, "Паралельна оптимізація КД", 4, optimization.k1, optimization.k2);
            outputGraphics.Show();
        }
示例#26
0
        private float [,] GetStructAfterRotation(string refStructure, string modelStructure)
        {
            float[,] transMatrix = null;

            if (!pdbs.molDic.ContainsKey(refStructure) || !pdbs.molDic.ContainsKey(modelStructure))
            {
                return(null);
            }
            posMOL locPosMol = opt.PrepareData(pdbs.molDic[refStructure], pdbs.molDic[modelStructure]);

            transMatrix = opt.TransMatrix(locPosMol.posmol2, locPosMol.posmol1);
            if (transMatrix == null)
            {
                return(null);
            }
            return(Optimization.MultMatrixTrans(locPosMol.posmol2, transMatrix));
            //return opt.TransMatrix(opt.posMol1, opt.posMol2);
        }
        private void DrawCustomInspector()
        {
            importHeightMap    = EditorGUILayout.Toggle("Import Height Map", importHeightMap);
            optimizationMethod = (Optimization)EditorGUILayout.EnumPopup("Optimization Algorithm", optimizationMethod);

            if (importHeightMap)
            {
                ExternalHeightMapReceiver.Draw();
                SetOptimizationAlgorithmUI();
            }
            else
            {
                generationAlgorithm =
                    (GenerationAlgorithm)EditorGUILayout.EnumPopup("Generation Algorithm", generationAlgorithm);
                mapSize = Mathf.RoundToInt(EditorGUILayout.Slider("Map size", mapSize, 1, 255));
                SetGenerationAlgorithmUI();
                SetOptimizationAlgorithmUI();
            }
        }
 protected static IEnumerable <string> TestTACOptimization(
     string sourceCode,
     Optimization basicBlockOptimization = null,
     Optimization allCodeOptimization    = null,
     bool unreachableCodeElimination     = false) =>
 ThreeAddressCodeOptimizer.Optimize(
     GenTAC(sourceCode),
     basicBlockOptimization == null ? null :
     new List <Optimization>()
 {
     basicBlockOptimization
 },
     allCodeOptimization == null ? null :
     new List <Optimization>()
 {
     allCodeOptimization
 },
     unreachableCodeElimination)
 .Select(instruction => instruction.ToString());
示例#29
0
        static void Main(string[] args)
        {
            Func <int, int, int> someDelegate = (int x, int y) => SomeFunc(x) > SomeFunc(y) ? SomeFunc(x) : SomeFunc(y);

            someDelegate(1000, 1500);
            Console.WriteLine("--------");

            someDelegate = Optimization.Run <Func <int, int, int> >(
                (int x, int y) => SomeFunc(x) > SomeFunc(y) ? SomeFunc(x) : SomeFunc(y)
                );

            someDelegate(1000, 1500);


            Action someDelegate1 = Optimization.Run <Action>(
                () => SomeFunc1()
                );

            Console.ReadLine();
        }
示例#30
0
文件: Form1.cs 项目: canter96/diplom
        async void consistentAsync()
        {
            consistent = true;
            parallel   = false;
            OutputGraphics outputGraphics = new OutputGraphics();

            outputGraphics.Text = "Послідовна оптимізація КД";

            Optimization optimization = new Optimization(classX1, classX2, classX3, classX4, classX5);
            await Task.Run(() => {
                optimization.main("consistent");
            });

            outputGraphics.chart2.Series.Clear();
            outputGraphics.chart3.Series.Clear();
            outputGraphics.chart4.Series.Clear();

            outputGraphics.GetGraph(outputGraphics.chart1, optimization.E_consistent_all, "Послідовна оптимізація КД", 4);
            outputGraphics.Show();
        }
        public static ScheduleOptimization GetOptimization(Optimization optimization)
        {
            ScheduleOptimization strategy = null;

            switch (optimization)
            {
            case Optimization.MostGaps:
                strategy = new MostGapsOptimization();
                break;

            case Optimization.LeastGaps:
                strategy = new LeastGapsOptimization();
                break;

            case Optimization.MostDays:
                strategy = new MostDaysOptimization();
                break;

            case Optimization.LeastDays:
                strategy = new LeastDaysOptimization();
                break;

            case Optimization.HighestGPA:
                strategy = new HighestGPAOptimization();
                break;

            case Optimization.HighestRMP:
                strategy = new HighestRateMyProfessorOptimization();
                break;

            case Optimization.EarlyEnd:
                strategy = new EarliestEndOptimization();
                break;

            case Optimization.LateStart:
                strategy = new LatestStartOptimization();
                break;
            }
            return(strategy);
        }
示例#32
0
        public Rmsd(List <string> fileNames, string alignFile, bool flag, PDBMODE allAtoms,string refJuryProfile=null)
            : base(fileNames, alignFile, flag,refJuryProfile)
        {

            dirSettings.Load();
            pdbs = new PDBFiles();

            pdbs.AddPDB(fileNames, allAtoms);
            pdbs.FindReferenceSeq();
            pdbs.MakeAlignment(null);
            opt = new Optimization();
            structNames = CheckAvailableStructures();
            order = true;
        }
示例#33
0
        public Rmsd(string dirName,string alignFile,bool flag,PDBMODE allAtoms,string refJuryProfile=null):base(dirName,alignFile,flag,refJuryProfile)
        {

            dirSettings.Load();
            pdbs = new PDBFiles();
            string[] files;
            if(dirSettings.extension==null)
                files = Directory.GetFiles(dirName);
            else
                files = Directory.GetFiles(dirName, dirSettings.extension);

            if (files.Length == 0)
                throw new Exception("In selected directory " + dirName + " there are no files with extesion " + dirSettings.extension);

            string refSeqFile = dirName + ".ref";
            pdbs.ReadRefSeq(refSeqFile);


            pdbs.AddPDB(files, allAtoms);

            if (pdbs.molDic.Keys.Count == 0)
                throw new Exception("Non pdb files correctly read");
            pdbs.FindReferenceSeq();
            pdbs.MakeAlignment(alignFile);
			opt=new Optimization();
            structNames = CheckAvailableStructures();
            order = true;
         }
示例#34
0
        public override void CalcDistMatrix(List <string> structures)
        {
            hashIndex = new Dictionary<string, int>(structures.Count);
            for(int i=0;i<structures.Count;i++)
            {
                if (!pdbs.molDic.ContainsKey(structures[i]))
                    throw new Exception("There is no pdb file or file is incorrect for the structure: " + structures[i]);
                hashIndex.Add(structures[i], i);
            }
            Settings set = new Settings();
            set.Load();
            int threadNumbers =  set.numberOfCores;
            this.structures = new List<string>(structures);

            int part = structures.Count * (structures.Count+1) / (2 * threadNumbers)+1;
            distanceMatrix = new int[structures.Count * (structures.Count + 1) / 2];
            indexList = new List<KeyValuePair<int, int>>[threadNumbers];
            optList = new Optimization[threadNumbers];
            for (int n= 0; n < threadNumbers;n++)
            {
                indexList[n] = new List<KeyValuePair<int, int>>(part);
                optList[n] = new Optimization();
            }
            
            int count = 0;
                foreach (var dim1 in structures)
                {
                    foreach (var dim2 in structures)
                    {
                        if (hashIndex[dim1] <= hashIndex[dim2])
                        {
                            indexList[count].Add(new KeyValuePair<int, int>(hashIndex[dim1], hashIndex[dim2]));
                            if (part <= indexList[count].Count)
                                count++;
                        }
                    }
                }
                PreparePDBPos();
            resetEvents = new ManualResetEvent[threadNumbers];
            for(int n=0;n<threadNumbers;n++)
            {
                paramsThread p=new paramsThread();
                p.k=n;
                ThreadPool.QueueUserWorkItem(new WaitCallback(CalcMatrix),(object) p);
                resetEvents[n] = new ManualResetEvent(false);

            }
            for (int j = 0; j < threadNumbers; j++)
                resetEvents[j].WaitOne();

        }
示例#35
0
        public override int[] GetDistance(string refStructure, List<string> structures)
        {
            int[] dist = new int[structures.Count];
            int i = 0;
            distanceMatrix = new int[structures.Count];
            Settings set = new Settings();
            set.Load();
            int threadNumbers = set.numberOfCores;
            this.structures = new List<string>(structures);
            int part = this.structNames.Count / threadNumbers;
            indexList = new List<KeyValuePair<int, int>>[threadNumbers];
            optList = new Optimization[threadNumbers];
            for (int j = 0; j < indexList.Length; j++)
            {
                indexList[j] = new List<KeyValuePair<int, int>>();
                optList[j] = new Optimization();
            }
            int count = 0;
            for (int j = 0; j < this.structNames.Count; j++)
            {
                if (indexList[count].Count < part)
                {
                    KeyValuePair<int, int> aux = new KeyValuePair<int, int>(j, 0);
                    indexList[count].Add(aux);
                }
                else
                    count++;
            }
            this.structures.Add(refStructure);
            resetEvents = new ManualResetEvent[threadNumbers];
            for (int n = 0; n < threadNumbers; n++)
            {
                int k = n;
                ThreadPool.QueueUserWorkItem(new WaitCallback(CalcMatrixList), (object)k);
                resetEvents[n] = new ManualResetEvent(false);

            }
            for (int j = 0; j < threadNumbers; j++)
                resetEvents[j].WaitOne();

            for (int j = 0; j < this.structures.Count - 1; j++)
                dist[j] = distanceMatrix[j];

            return dist;

        }