internal OrConstraintRepeater(Solver theSolver, OrToolsCache theCache, ModelModel theModel, OrValueMapper theValueMapper) { this.solver = theSolver; this.cache = theCache; this.model = theModel; this.valueMapper = theValueMapper; }
private CatalogViewModel GetCatalogTree() { CatalogViewModel catalog = new CatalogViewModel(); var brands = brandService.GetAllBrands(); for (int i = 0; i < brands.Count(); i++) { BrandModel brand = new BrandModel { Id = brands[i].Id, Name = brands[i].Name, Photo = brands[i].Photo }; var models = modelService.GetAllModels(brands[i].Id); for (int j = 0; j < models.Count(); j++) { ModelModel model = new ModelModel { Id = models[j].Id, Name = models[j].Name, Photo = models[j].PhotoUrl }; brand.Models.Add(model); } catalog.Brands.Add(brand); } return(catalog); }
/// <summary> /// Convert all buckets into a representation understood by the solver. /// </summary> /// <param name="model">The model.</param> internal void ConvertBuckets(ModelModel model) { foreach (var aBucket in model.Buckets) { ConvertBucket(aBucket); } }
private void CreateVariables(ModelModel model) { foreach (var variable in model.Variables) { switch (variable) { case SingletonVariableModel singletonVariable: var singletonSolverVariable = _modelSolverMap.GetSolverSingletonVariableByName(singletonVariable.Name); _constraintNetwork.AddVariable(singletonSolverVariable); break; case AggregateVariableModel aggregateVariable: var aggregateSolverVariable = _modelSolverMap.GetSolverAggregateVariableByName(aggregateVariable.Name); _constraintNetwork.AddVariable(aggregateSolverVariable); break; default: throw new NotImplementedException(); } } foreach (var bucketVariable in model.Buckets) { var bucketVariableMap = _modelSolverMap.GetBucketVariableMapByName(bucketVariable.Name); _constraintNetwork.AddVariable(bucketVariableMap); } }
public PartialViewResult EditModel(int id) { unitOfWork = new EFUnitOfWork(db); ModelEditViewModel mevm = new ModelEditViewModel(); var model = unitOfWork.GetRepository <Model>().GetById(id); ModelModel mm = Mapper.Map <Model, ModelModel>(model); var brands = unitOfWork.GetRepository <Brand>().GetAll().Select(t => new SelectListItem() { Value = t.Id.ToString(), Text = t.Name }).ToList(); mevm.brandId = model.BrandId; mevm.ModelModel = mm; mevm.Brands = new SelectList(brands, "Value", "Text", mevm.brandId); unitOfWork.Dispose(); return(PartialView("_ModelEditPartialView", mevm)); }
/// <summary> /// Initialize the expression constraint converter with a solver and or-tools cache. /// </summary> /// <param name="theSolver">Google or-tools solver instance.</param> /// <param name="theCache">Cache mapping between the model and Google or-tools solver.</param> /// <param name="theModel">Model</param> internal OrExpressionConstraintConverter(Google.OrTools.ConstraintSolver.Solver theSolver, OrToolsCache theCache, ModelModel theModel, OrValueMapper theValueMapper) { this.solver = theSolver; this.cache = theCache; this.model = theModel; this.valueMapper = theValueMapper; }
public IEnumerable <ModelModel> ModelDropdown() { List <ModelModel> models = new List <ModelModel>(); using (var cn = new SqlConnection(Settings.GetConnectionString())) { SqlCommand cmd = new SqlCommand("ModelDropdown", cn); cmd.CommandType = CommandType.StoredProcedure; cn.Open(); using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { ModelModel model = new ModelModel(); model.ModelId = (int)dr["ModelId"]; model.MakeId = (int)dr["MakeId"]; model.Model = dr["Model"].ToString(); models.Add(model); } } } return(models); }
/// <summary> /// Initialize an all different constraint editor view model with the model. /// </summary> public AllDifferentConstraintEditorViewModel(ModelModel theModel) { _model = theModel; Validator = new AllDifferentConstraintEditorViewModelValidator(); ConstraintName = string.Empty; SelectedVariable = string.Empty; Variables = new ObservableCollection <string>(); }
/// <summary> /// Convert all buckets into a representation understood by the solver. /// </summary> /// <param name="model">The model.</param> internal void ConvertBuckets(ModelModel model) { foreach (var bucket in model.Buckets) { var bucketMap = ConvertBucket(bucket); _modelSolverMap.AddBucket(bucket.Name, bucketMap); } }
internal OrangeConstraintRepeater(ConstraintNetwork constraintNetwork, OrangeModelSolverMap modelSolverMap, ModelModel theModel, OrangeValueMapper theValueMapper) { _constraintNetwork = constraintNetwork; _modelSolverMap = modelSolverMap; _model = theModel; _valueMapper = theValueMapper; _arcBuilder = new ArcBuilder(_modelSolverMap, _valueMapper); }
/// <summary> /// Convert the model into a representation used by the Google or-tools solver. /// </summary> /// <param name="theModel">The model model.</param> internal void ConvertFrom(ModelModel theModel) { Debug.Assert(this.constraintConverter != null); Debug.Assert(this.variableConverter != null); this.variableConverter.ConvertVariables(theModel); this.bucketConverter.ConvertBuckets(theModel); this.constraintConverter.ProcessConstraints(theModel); }
private Model MapModelModel(ModelModel modelModel) { return(new Model { BrandId = modelModel.BrandId, Id = modelModel.Id, Name = modelModel.Name }); }
private CatalogViewModel Catalog() { CatalogViewModel catalog = new CatalogViewModel(); var brands = brandService.GetAllBrands(); for (int i = 0; i < brands.Count(); i++) { BrandModel brand = new BrandModel { Id = brands[i].Id, Name = brands[i].Name, Photo = brands[i].Photo }; var models = modelService.GetAllModels(brands[i].Id); for (int j = 0; j < models.Count(); j++) { ModelModel model = new ModelModel { Id = models[j].Id, Name = models[j].Name, Photo = models[j].PhotoUrl }; var cars = carService.GetAllCars(models[j].Id); for (int k = 0; k < cars.Count(); k++) { CarModel car = new CarModel { Id = cars[k].Id, Color = cars[k].Color, VolumeEngine = cars[k].VolumeEngine, Description = cars[k].Description }; var prices = cars[k].Prices; for (int l = 0; l < prices.Count(); l++) { CostModel cost = new CostModel { Id = prices[l].Id, Date = prices[l].Date, Price = prices[l].Price }; car.Prices.Add(cost); } model.Cars.Add(car); } brand.Models.Add(model); } catalog.Brands.Add(brand); } return(catalog); }
private long EvaluateFunction(FunctionInvocationNode functionCall, ModelModel theModel) { Debug.Assert(functionCall.FunctionName == "size", "Only the size function is supporteed at the moment."); var variableName = functionCall.ArgumentList.Arguments.First().Value.Value; var theVariable = theModel.GetVariableByName(variableName); return(theVariable.GetSize()); }
public void Should_FailCreate_Model() { var model = new ModelModel { Name = "KA Sedan 1.6", BrandID = 1 }; Assert.ThrowsAsync <FileNotFoundException>(() => this.modelService.Create(model)); }
private void ConvertSingletonVariables(ModelModel theModel) { foreach (var variable in theModel.Singletons) { var variableBand = VariableBandEvaluator.GetVariableBand(variable); this.valueMapper.AddVariableDomainValue(variable, variableBand); var orVariable = ProcessVariable(variable); this.cache.AddSingleton(variable.Name.Text, new Tuple <SingletonVariableModel, IntVar>(variable, orVariable)); } }
/// <summary> /// Convert all buckets into a representation understood by the solver. /// </summary> /// <param name="model">The model.</param> internal void ConvertBuckets(ModelModel model) { foreach (var bucket in model.Buckets) { bucket.PopulateInstances(null); var bucketMap = new OrBucketVariableMap(bucket, null); var bucketTracker = new OrBucketTracker(bucket, bucketMap); ConvertBucket(bucketTracker); } }
public IActionResult UpdateModel([FromBody] ModelModel modelModel, int id) { var isUpdated = _modelRepository.Update(id, MapModelModel(modelModel)); if (!isUpdated) { return(BadRequest()); } return(Ok()); }
/// <summary> /// Initialize a repeater context from the constraint. /// </summary> /// <param name="theConstraint">Expression constraint.</param> /// <param name="theModel">Model</param> public OrConstraintRepeaterContext(ExpressionConstraintModel theConstraint, ModelModel theModel) { Constraint = theConstraint; Model = theModel; this.counters = new List <CounterContext>(); if (!theConstraint.Expression.Node.HasExpander) { return; } CreateCounterContextsFrom(theConstraint.Expression.Node.Expander); }
public TrainViewModel() { AssignCommands(); Model = new ModelModel { Lteration = 201000, Rate = 85 }; DispatcherHelper.Initialize(); }
/// <summary> /// Build a constraint network from the model. /// </summary> /// <param name="model">Constraint model.</param> /// <returns>Constraint network.</returns> internal ConstraintNetwork Build(ModelModel model) { MapVariables(model); MapValues(model); ConvertBuckets(model); _constraintNetwork = new ConstraintNetwork(); PopulateConstraintNetwork(model); CreateVariables(model); return(_constraintNetwork); }
async public void Should_Update_Model() { var newModel = new ModelModel { Name = "Onix LTE", BrandID = 1 }; var create = await this.modelService.Update(newModel); Assert.Equal(1, create.Id); Assert.Equal("Generic Model", create.Name); }
internal override Task <object> GetInfo() { var item = Item; ModelModel model = new ModelModel { ID = item.ID, Name = item.Name }; return(Task.FromResult((object)model)); }
public async Task <ModelModel> Update(ModelModel model) { var validator = new ModelModelValidator(); if (!validator.Validate(model).IsValid) { throw new TaskSchedulerException(); } var query = await this.modelRepository.UpdateIntoDatabase(this.mapper.Map <ModelModel, Model>(model)); return(this.mapper.Map <Model, ModelModel>(query)); }
public string GetTem(ModelModel model) { string path = ""; switch (model) { case ModelModel.CS: path = "/Tem/TemModel/CSModel.TXT"; break; case ModelModel.Nh: path = "/Tem/TemModel/HModel.TXT"; break; default: throw new Exception(); } return(System.Web.HttpContext.Current.Server.MapPath(path)); }
protected override async Task SaveAsync() { try { var name = View.NameModel; if (_markID == null) { throw new ArgumentNullException(null, "Вы не выбрали модель"); } if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException(null, "Вы не ввели имя модели"); } using (var context = new DbSSContext()) { if (Identifier != null) { await context.Model.Where(m => m.ID == Identifier).UpdateAsync(m => new ModelModel { ID_mark = (Guid)_markID, Name = name }); } else { ModelModel insertModelInfo = new ModelModel { ID = ConsistentGuid.CreateGuid(), ID_mark = (Guid)_markID, Name = name }; context.Model.Add(insertModelInfo); await context.SaveChangesAsync(); Identifier = insertModelInfo.ID; } } View.Close(); } catch (Exception ex) { ShowError(ex.Message); } }
/// <summary> /// 模型管理界面 /// 添加一个已经存在的模型 /// </summary> /// <param name="addModel"></param> /// <returns></returns> public int TransferModel(ModelModel addModel) { using (IDbConnection conn = SqlHelper.GetConnection()) { conn.Open(); var sql = @"INSERT INTO TB_MODEL(MODELNAME,CREATETIME,LOCATION,UPDATETIME) VALUES(@ModelName,@CreateTime,@Location,@UpdateTime)"; return(conn.Execute(sql, new { addModel.ModelName, addModel.CreateTime, addModel.Location, addModel.UpdateTime })); } }
private long EvaluateBand(BandExpressionNode theExpression, ModelModel theModel) { switch (theExpression.Inner) { case NumberLiteralNode numberLiteral: return(numberLiteral.Value); case FunctionInvocationNode functionCall: return(EvaluateFunction(functionCall, theModel)); case CharacterLiteralNode characterLiteral: return(characterLiteral.Value - 'a' + 1); default: throw new NotImplementedException("Unknown band expression node."); } }
//get device info from database before edit internal DeviceModel GetDeviceInfoWithLocation(int deviceID) { SqlConnection con = new SqlConnection(connectionString); con.Open(); SqlCommand cmd = new SqlCommand("GetDeviceWithLocation", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.Add("@deviceID", System.Data.SqlDbType.Int).Value = deviceID; //execute query // cmd.ExecuteNonQuery(); #region //model for data transfer SqlDataReader reader = cmd.ExecuteReader(); DeviceModel device = new DeviceModel(); ModelModel model = new ModelModel(); CategoryModel category = new CategoryModel(); BuildingModel building = new BuildingModel(); StorageLocationModel location = new StorageLocationModel(); model.Category = category; location.Location = building; #endregion while (reader.Read()) { device.DeviceID = (int)reader["deviceID"]; device.SerialNumber = (string)reader["serialNumber"]; device.Status = (byte)reader["status"]; model.Category.Category = (string)reader["categoryName"]; model.ModelName = (string)reader["modelName"]; model.ModelDescription = (string)reader["modelDescription"]; location.Location.RoomNumber = (byte)reader["roomNr"]; location.Location.Building = (string)reader["buildingName"]; location.ShelfName = (string)reader["shelfName"];; location.ShelfLevel = (byte)reader["shelfLevel"]; location.ShelfSpot = (byte)reader["shelfSpot"]; } device.Model = model; device.Location = location; con.Close(); return(device); }
public ActionResult Index(/*int type,*/ HttpPostedFileBase model) { ModelModel m = new ModelModel(); if (model != null) { var length = model.InputStream.Length; byte[] fileData = null; using (var binaryReader = new BinaryReader(model.InputStream)) { fileData = binaryReader.ReadBytes(model.ContentLength); } m.TopBar = fileData; } return(View(m)); }