public Solvent TransformToSolvent() { Solvent result = new Solvent(); result.MoleculeCAS = MoleculeCAS; result.v = VValue; return(result); }
// SolventMix is a mix of Weed-leaves and chemical(s). public SolventMix(IChronic chronic, IChemical chemical) : base(chronic.Name + " " + chemical.Name, chronic.Description + " " + chemical.Description, chronic.Weight + chemical.Weight, chronic.Value) { Type = ItemType.SolventMix; _extractedOils = new Random().NextDouble() * (0.85 - 0.75) + 0.75; Chronic = chronic; Chemical = chemical; Solvent = new Solvent(Chronic, Chemical); }
public void EmptySolventTest() { Solvent item = new Solvent(); List <OutputMessage> errors = new List <OutputMessage>(); errors = item.Validate(); Assert.AreNotEqual(0, errors.Count); }
private Solvent LoadSolvent(IDataReader reader) { Solvent model = new Solvent(); model.SolventId = reader.GetInt32("solvent_id"); model.Name = reader.GetString("name"); model.Description = reader.GetString("description"); model.ImageName = reader.GetString("image_name"); model.DateEntry = reader.GetDateTime("date_entry"); model.DateUpdated = reader.GetDateTime("date_updated"); return(model); }
public void SelectedSolventTest() { molecules.Add(new SelectedMolecule() { Name = "MoleculeA", CAS = "AAAAA-AA-A", Location = "Q2", VAvailable = 25.2 }); Solvent item = new Solvent(molecules[0]); List <OutputMessage> errors = new List <OutputMessage>(); errors = item.Validate(); Assert.AreNotEqual(0, errors.Count); }
public void SelectedAndNumberVInputSolventTest() { molecules.Add(new SelectedMolecule() { Name = "MoleculeA", CAS = "AAAAA-AA-A", Location = "Q2", VAvailable = 674 }); Solvent item = new Solvent(molecules[0]); item.VValueString = "21"; List <OutputMessage> errors = new List <OutputMessage>(); errors = item.Validate(); Assert.AreEqual(0, errors.Count); }
public async Task <IActionResult> Create([Bind("Id,Name,Description")] SustainableChemistryWeb.Models.Solvent solvent) { try { Solvent appSolvent = new Solvent() { Name = solvent.Name, Description = solvent.Description }; if (ModelState.IsValid) { _context.Add(appSolvent); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public static Algorithm ParseJson(String jsonString, List <MinMaxValue> minMaxValues) { dynamic jsonModel = JsonConvert.DeserializeObject(jsonString); Algorithm algorithm = new Algorithm() { AlgorithmName = jsonModel.algorithm, Models = new List <Model>() }; Model model = new Model() { Clusters = new List <Cluster>(), DataSet = jsonModel.dataSet, Date = DateTime.Now, NumberOfSolvents = 0, NumberOfFeatures = 0, ModelPath = jsonModel.modelPath, AlgorithmName = jsonModel.algorithm }; foreach (var cluster in jsonModel.clusters) { Cluster clusterTemp = new Cluster() { DistanceToClusters = new List <ClusterDistanceCenter>(), Number = cluster.clusterNumber, Solvents = new List <Solvent>(), VectorData = new List <VectorData>(), }; foreach (var vector in cluster.vectorData) { VectorData vectorData = new VectorData() { Value = vector.value, FeatureName = vector.name }; clusterTemp.VectorData.Add(vectorData); } foreach (var distance in cluster.distanceToCluster) { ClusterDistanceCenter clusterDistanceCenter = new ClusterDistanceCenter() { ToClusterId = distance.clusterId, Distance = distance.distance }; clusterTemp.DistanceToClusters.Add(clusterDistanceCenter); } foreach (var solvent in cluster.solvents) { Solvent solventTemp = new Solvent() { CasNumber = solvent.casNumber, Name = solvent.name, DistanceToClusterCenter = solvent.distanceToCluster, Features = new List <Feature>(), MetaData = new SolventMetaData() { Label = solvent.predictLabel, IdCasNr = solvent.iD_CAS_Nr_1, IdEgNr = solvent.iD_EG_Nr, IdEgAnnexNr = solvent.iD_EG_Annex_Nr, Input = solvent.input, IdName1 = solvent.iD_Name_1 } }; solventTemp.CasNumber = solventTemp.CasNumber.Replace("\"", ""); solventTemp.Name = solventTemp.Name.Replace("\"", ""); foreach (var feature in solvent.features) { FeatureName featureName; Enum.TryParse <FeatureName>(feature.name.ToString(), out featureName); var value = minMaxValues.FirstOrDefault(a => a.FeatureName == featureName); Feature featureTemp = new Feature() { FeatureName = feature.name, Value = feature.value }; featureTemp.MinMaxValue = value; solventTemp.Features.Add(featureTemp); } clusterTemp.Solvents.Add(solventTemp); model.NumberOfFeatures = solventTemp.Features.Count; } model.NumberOfSolvents += clusterTemp.Solvents.Count; model.Clusters.Add(clusterTemp); } algorithm.Models.Add(model); return(algorithm); }