public async Task <ActionResult <ProblemType> > PostProblemType(ProblemType problemType) { _context.ProblemType.Add(problemType); await _context.SaveChangesAsync(); return(CreatedAtAction("GetProblemType", new { id = problemType.Id }, problemType)); }
public IMOOProblem GetProblem() { ProblemType problem_type = (ProblemType)cboProblem.SelectedItem; if (problem_type == ProblemType.NDND) { return(new NDNDProblem()); } else if (problem_type == ProblemType.NGPD) { return(new NGPDProblem()); } else if (problem_type == ProblemType.TNK) { return(new TNKProblem()); } else if (problem_type == ProblemType.OKA2) { return(new OKA2Problem()); } else if (problem_type == ProblemType.SYMPART) { return(new SYMPARTProblem()); } return(null); }
public async Task <IActionResult> PutProblemType(Guid id, ProblemType problemType) { if (id != problemType.Id) { return(BadRequest()); } _context.Entry(problemType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProblemTypeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Edit(Guid id, [Bind("Type,Name,Id")] ProblemType problemType) { if (id != problemType.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _dbContext.Update(problemType); await _dbContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProblemTypeExists(problemType.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(problemType)); }
private static string GetAnswerPlotCommand(ProblemType problem, string answerPath, string plotPath) { if (problem == ProblemType.Regression) return GetRegressionAnswerCommand(answerPath, plotPath); else return GetClassificationAnswerCommand(answerPath); }
public CodeJamProblem(char problem, ProblemType problemType, int attempt = 0) : this( Path.Combine(filesDirectory, char.ToUpper(problem).ToString() + "-" + GetProblemTypeName(problemType) + (problemType == ProblemType.Small ? "-attempt" + attempt.ToString() : string.Empty) + ".in") ) { }
public Problem(ProblemType problemType, int first, int second, int result) { ProblemType = problemType; First = first; Second = second; Result = result; }
public void OnOtherProblemToggleValueChanged(bool value) { if (value) { CommitProblemType = ProblemType.Other; } }
private void btnDelType_Click(object sender, EventArgs e) { if (this.IsAdd) { MessageBox.Show("尚未添加完成"); return; } else if (this.IsEdit) { MessageBox.Show("尚未编辑完成"); return; } if (this.lvType.SelectedItems.Count <= 0) { MessageBox.Show("需要先选中教材才能删除。"); return; } List <string> typeIDS = new List <string>(); foreach (ListViewItem lvItem in this.lvType.SelectedItems) { ProblemType type = (ProblemType)lvItem.Tag; typeIDS.Add(type.Id); } this.iProblemTypeFormReq.DelTypeByIds(typeIDS); this.initData(); }
// blocking public ItemOfInterest GetItem(ProblemType problemType) { bool lockTaken = false; Monitor.Enter(_blackboard, ref lockTaken); ItemOfInterest item = null; try { item = _blackboard.Items.FirstOrDefault(it => it.ProblemType == problemType && it.State != ItemState.Processing); if (item != null) { item.State = ItemState.Processing; } } finally { if (lockTaken) { Monitor.Exit(_blackboard); } } return(item); }
public CasesData(ProblemType problemType, List <DenseVector> input, List <DenseVector> output = null, int outputLength = 1, int historyLength = 0) { if (input == null || input.Count == 0) { throw new ArgumentException("Input cannot be null or empty."); } HasOutput = output != null; if (HasOutput && input.Count != output.Count) { throw new ArgumentException("Input rows count should equal output rows count."); } ProblemType = problemType; if (ProblemType == ProblemType.Classification && HasOutput && output.First().Count != 1) { throw new ArgumentException("Classification problem should have only one defined output."); } if (outputLength <= 0) { throw new ArgumentException("regressionOutputLenght has to be positive."); } MinValue = double.MaxValue; MaxValue = double.MinValue; BaseInputSize = input[0].Count; ClassIndexes = new List <int>(); cases = new List <Tuple <DenseVector, DenseVector, DenseVector> >(); for (int i = 0; i < input.Count; i++) { CheckIfIsExtremum(input[i]); if (HasOutput) { if (problemType == ProblemType.Regression) { CheckIfIsExtremum(output[i]); } else if (problemType == ProblemType.Classification) { UpdateClassCount((int)output[i][0]); } } } for (int i = historyLength; i < input.Count; i++) { cases.Add(Tuple.Create(CreateInput(input, i, historyLength), ProblemType == ProblemType.Classification ? CreateClasyficationOutput(output, i, outputLength) : CreateRegressionOutput(output, i, outputLength), new DenseVector(outputLength))); } }
public static (List <Board>, int?) Solve(ProblemType problemType, AlgorithmType algorithmType, List <Polymino> polyminos, int solutionsLimit) { if (problemType == ProblemType.Square) { if (algorithmType == AlgorithmType.Precise) { return(PreciseSquareSolver.Solve(polyminos, solutionsLimit)); } else { return(HeuristicSquareSolver.Solve(polyminos)); } } else { if (algorithmType == AlgorithmType.Precise) { return(PreciseRectangleSolver.Solve(polyminos, solutionsLimit)); } else { return(HeuristicRectangleSolver.Solve(polyminos)); } } }
internal uint ReportProblem(ProblemType problem, Exception e, string detail = null) { string circumstance = detail ?? Report.ExMessage(e, false); if (!string.IsNullOrEmpty(e.HelpLink)) { circumstance += " (see " + e.HelpLink + ")"; } /* e may be null */ if (problem == ProblemType.ExceptionThrown) { if (m_exceptionsThrown.ContainsKey(circumstance)) { m_exceptionsThrown[circumstance]++; } else { m_exceptionsThrown[circumstance] = 1; } } else if (problem == ProblemType.ExceptionTriggered) { if (m_exceptionsTriggered.ContainsKey(circumstance)) { m_exceptionsTriggered[circumstance]++; } else { m_exceptionsTriggered[circumstance] = 1; } } return(ReportProblem(problem, circumstance)); }
public void loadInputFile() { Reader reader = new Reader(); List <string> rawData = reader.getRawDataFromInputFile(Globals.INPUT_NAME); //Regex regex = new Regex(@"\-[^+-]+"); //var matches = regex.Matches(rawData.ElementAt(0)); //string[] objectiveFunction = matches.Cast<Match>().Select(x => x.Value).ToArray(); string lineOne = rawData.ElementAt(0); string problemString = lineOne.Substring(0, 3).ToLower(); if (problemString != "min" || problemString != "max") { ErrorHandler.getInstance().messageAndExit("Min or Max problem parameter not found in line 1"); } else { Problem = (problemString == "min" ? ProblemType.Minimization : ProblemType.Maximization); } lineOne = lineOne.Remove(0, 4); string[] objectiveFunctionList = lineOne.Split(' '); if (objectiveFunctionList.Length == 0) { ErrorHandler.getInstance().messageAndExit("No objective function specified in line 1"); } if (objectiveFunctionList.Length == 1) { ErrorHandler.getInstance().message("Only one decision variable in line 1 - Please handle me"); } }
public static string ViewString(this ProblemType type) { string result = ""; switch (type) { case ProblemType.Pending: result = "Грешка"; break; case ProblemType.Delay: result = "Закъснение при полет"; break; case ProblemType.Cancel: result = "Отменен полет"; break; default: result = "Отказан достъп до борда"; break; } return(result); }
private void btnSubmit_Click(object sender, EventArgs e) { ProblemType type = new ProblemType(); type.Modify = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); type.Name = this.tbTypeName.Text.Trim(); type.Other = this.rtbTypeOther.Text; if (IsAdd) { type.Id = Guid.NewGuid().ToString("N"); type.Create = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); this.iProblemTypeFormReq.InsertOneType(type); this.IsAdd = false; } if (IsEdit) { type.Id = this.CurrentSelType.Id; this.iProblemTypeFormReq.UpdateOneType(type); this.IsEdit = false; } this.btnSubmit.Visible = false; this.btnCancelSubmit.Visible = false; this.initData(); this.initView(); }
public List<ProblemWord> Words { get; set; } //Segmentation public MathProblem(int index, string originProblem, ProblemType pt) { Index = index; OriginalProblem = originProblem; Type = pt; Words = new List<ProblemWord>(); }
private void lvType_SelectedIndexChanged(object sender, EventArgs e) { if (this.lvType.SelectedItems.Count == 0) { return; } if (this.IsAdd) { MessageBox.Show("尚未添加完成"); return; } else if (this.IsEdit) { MessageBox.Show("尚未编辑完成"); return; } if (this.lvType.SelectedItems.Count > 1) { //选中多项目,就是一项都没有选中,先把右边的按钮设置为不可点击状态。 //MessageBox.Show("选中了多堂课程"); this.CurrentSelType = null; this.tbTypeName.Text = ""; this.rtbTypeOther.Text = ""; return; } //以下就是选中项为1项的情况了 //获取选中课程的数据 this.CurrentSelType = (ProblemType)lvType.SelectedItems[0].Tag; this.tbTypeName.Text = this.CurrentSelType.Name; this.rtbTypeOther.Text = this.CurrentSelType.Other; }
private void btnSubmit_Click(object sender, EventArgs e) { Problem problem = new Problem(); problem.Modify = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); problem.Content = this.rtxContent.Text; problem.Other = this.rtxOther.Text; ProblemType type = (ProblemType)this.cbProblemType.SelectedItem; if (type != null) { problem.TypeId = type.Id; } //this.iProblemEditFormReq.InsertOneProblem(problem, this.checkIDs); if (this.addProblem != null) { problem.Id = Guid.NewGuid().ToString("N"); problem.Create = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); this.addProblem(problem, this.checkIDs); } if (this.editProblem != null) { problem.Id = this.CurSelProblemWithTN.Id; this.editProblem(problem, this.oldKnowl, this.checkIDs); } this.Close(); }
public void OnGameProblemToggleValueChanged(bool value) { if (value) { CommitProblemType = ProblemType.Game; } }
public void testToCCRProblem() { CCRHelper helper = new CCRHelper(); ProblemType problem = helper.buildProblemObject("Congestive Heart Failure", "939", "3110103", "", "3110719", "3110719", "VEHU,TEN", "ICD9", "428.0", "", "A", "ACTIVE"); Assert.IsNotNull(problem); Assert.IsTrue(String.Equals(problem.Description.Text, "Congestive Heart Failure")); Assert.AreEqual(problem.IDs.Count, 1); Assert.IsTrue(String.Equals(problem.IDs.First().ID, "939")); Assert.AreEqual(problem.DateTime.Count, 4); Assert.IsTrue(String.Equals(problem.DateTime[0].ExactDateTime, "3110103")); Assert.IsTrue(String.Equals(problem.DateTime[0].Type.Text, "Start date")); Assert.IsTrue(String.Equals(problem.DateTime[1].ExactDateTime, "")); Assert.IsTrue(String.Equals(problem.DateTime[1].Type.Text, "Stop date")); Assert.IsTrue(String.Equals(problem.DateTime[2].ExactDateTime, "3110719")); Assert.IsTrue(String.Equals(problem.DateTime[2].Type.Text, "Entered date")); Assert.IsTrue(String.Equals(problem.DateTime[3].ExactDateTime, "3110719")); Assert.IsTrue(String.Equals(problem.DateTime[3].Type.Text, "Updated date")); Assert.AreEqual(problem.Source.Count, 1); Assert.AreEqual(problem.Source.First().Actor.Count, 1); Assert.IsTrue(String.Equals(problem.Source.First().Actor.First().ActorID, "VEHU,TEN")); Assert.IsTrue(String.Equals(problem.Source.First().Actor.First().ActorRole.First().Text, "Treating clinician")); Assert.AreEqual(problem.Description.Code.Count, 1); Assert.IsTrue(String.Equals(problem.Description.Code.First().Value, "428.0")); Assert.IsTrue(String.Equals(problem.Description.Code.First().CodingSystem, "ICD9")); Assert.IsTrue(String.Equals(problem.Description.Code.First().Version, "")); Assert.IsTrue(String.Equals(problem.Status.Text, "ACTIVE")); Assert.IsTrue(String.Equals(problem.Status.Code.First().Value, "A")); }
public void OnPayProblemToggleValueChanged(bool value) { if (value) { CommitProblemType = ProblemType.Pay; } }
} //Segmentation public MathProblem(int index, string originProblem, ProblemType pt) { Index = index; OriginalProblem = originProblem; Type = pt; Words = new List <ProblemWord>(); }
internal uint ReportProblem(ProblemType problem, string detail = null) { switch (problem) { case ProblemType.ExceptionTriggered: m_numProblemsCaused++; break; default: m_numProblems++; break; } m_problemCount[(int)problem]++; switch (problem) { case ProblemType.GenericProblem: if (m_genericProblems.ContainsKey(detail)) { m_genericProblems[detail]++; } else { m_genericProblems[detail] = 1; } break; } return(m_numProblems); }
/// <summary> /// 构造一个出卷规则 /// </summary> /// <param name="unit">章节</param> /// <param name="pt">题目类型</param> /// <param name="pl">难度系数</param> /// <param name="score">题目分数</param> /// <param name="count">题目数量</param> public PaperRule(int unit,ProblemType pt,int pl,int score,int count) { Chapter=unit; PType = pt; PLevel = pl; Score = score; Count = count; }
public void SetProblem(ProblemType problem, string value = null) { switch (problem) { case ProblemType.Locate: inputLbl1.Text = string.Format("Locate {0}", value ?? "the country."); inputLbl1.Visible = true; inputTxt1.Visible = false; inputTxt1.Enabled = false; nxtBtn.Visible = false; playVoiceBtn.Visible = true; break; case ProblemType.SpellCapital: inputLbl1.Text = string.Format("Spell the capital of this country."); inputLbl1.Visible = true; inputTxt1.Visible = true; inputTxt1.Enabled = true; nxtBtn.Visible = false; playVoiceBtn.Visible = false; break; case ProblemType.SpellCapitalVoice: inputLbl1.Text = string.Format("Spell the capital of this country."); inputLbl1.Visible = true; inputTxt1.Visible = true; inputTxt1.Enabled = true; nxtBtn.Visible = false; playVoiceBtn.Visible = true; break; case ProblemType.SpellCountry: inputLbl1.Text = string.Format("Spell the name of this country."); inputLbl1.Visible = true; inputTxt1.Visible = true; inputTxt1.Enabled = true; nxtBtn.Visible = false; playVoiceBtn.Visible = false; break; case ProblemType.SpellCountryVoice: inputLbl1.Text = string.Format("Spell the name of this country."); inputLbl1.Visible = true; inputTxt1.Visible = true; inputTxt1.Enabled = true; nxtBtn.Visible = false; playVoiceBtn.Visible = true; break; case ProblemType.None: inputLbl1.Visible = false; inputTxt1.Visible = false; inputTxt1.Enabled = false; nxtBtn.Visible = false; playVoiceBtn.Visible = false; break; } }
public static string ProblemNameForType(ProblemType t) { switch (t) { case ProblemType.DVRP: return("DVRP"); default: return(null); } }
public AddSubProblem(int id, int level, int operator1, int operator2, int result, ProblemType probType) { this.AddSubProblemID = id; this.Level = level; this.Operator1 = operator1; this.Operator2 = operator2; this.Result = result; this.ProblemType = probType; }
public static int GetStatusCode(ProblemType problemType) { return(problemType switch { ProblemType.ERROR_NONE => StatusCodes.Status200OK, ProblemType.ERROR_MULTIPLE => StatusCodes.Status400BadRequest, ProblemType.ERROR_DATA_ALREADY_EXISTS => StatusCodes.Status409Conflict, _ => StatusCodes.Status400BadRequest });
/// <summary> /// Creates new instance of TravelingSalesmanProblem class /// </summary> /// <param name="name">problem name</param> /// <param name="comment">comment on problem from the author</param> /// <param name="type">TSP or ATSP</param> /// <param name="nodeProvider">provider of nodes</param> /// <param name="edgeProvider">provider of edges</param> /// <param name="edgeWeightsProvider">provider of edge weights</param> /// <param name="fixedEdgesProvider">provider of fixed edges</param> public TravelingSalesmanProblem(string name, string comment, ProblemType type, INodeProvider nodeProvider, IEdgeProvider edgeProvider, IEdgeWeightsProvider edgeWeightsProvider, IFixedEdgesProvider fixedEdgesProvider) : base(name, comment, type, nodeProvider, edgeProvider, edgeWeightsProvider, fixedEdgesProvider) { }
public static Problem CreateProblem(string desc, DataStructureType dt, ProblemType t = ProblemType.CreatedByStudent, Assignment a = null) { Problem p = new Problem(desc, dt, t, a); if (a != null) { a.AddProblem(p); } return(p); }
public CodedProblemDetails(ProblemType problemType, string objectName, object objectValue) { Check.NotNull(problemType, nameof(problemType)); Check.NotNullOrEmpty(objectName, nameof(objectName)); Check.NotNull(objectValue, nameof(objectValue)); ProblemType = problemType; ObjectName = objectName; ObjectValue = objectValue; }
//lets say we have 0 to 10 (10 being the positive response) public Problem(string problem, string pos, string avg, string refusal, string helpAcceptedText, string helpDeclinedText, ProblemType problemType = ProblemType.Misc) { problemText = problem; positiveResponse = pos; averageResponse = avg; refusalResponse = refusal; this.helpAcceptedText = helpAcceptedText; this.helpDeclinedText = helpDeclinedText; this.problemType = problemType; }
public HardwareController() { _hardwareService = new HardwareService(); _productService = new ProductService(); _customerService = new CustomerService(); _ptypes = new ProblemType(); _tsh = new TroubleShooting(); }
public void LoadTrainingData(string trainingDataPath, ProblemType problem, ActivationType activation) { TrainingDataPath = trainingDataPath; var csvReader = new ReadCSV(trainingDataPath, true, CSVFormat.DecimalPoint); var values = new List<double[]>(); var answers = new List<double[]>(); while (csvReader.Next()) { if (ProblemType.Classification == problem) { values.Add(new []{csvReader.GetDouble(0), csvReader.GetDouble(1)}); answers.Add(new []{csvReader.GetDouble(2)}); } else { values.Add(new[] { csvReader.GetDouble(0)}); answers.Add(new[] { csvReader.GetDouble(1) }); _originalRegressionValues.Add(values.Last()[0]); _originalRegressionAnswers.Add(answers.Last()[0]); } } csvReader.Close(); if (problem == ProblemType.Classification) { answers = SpreadClassificationAnswers(answers, activation); FirstLayerSize = 2; } else LastLayerSize = FirstLayerSize = 1; AnalizeValues(problem, values); Normalize(values, _valuesMins, _valuesMaxes, activation); if (problem == ProblemType.Regression) { AnalizeAnswers(answers); Normalize(answers, _answersMins, _answersMaxes, activation); } values.StableShuffle(); answers.StableShuffle(); ListExtensions.ResetStableShuffle(); var trainingSetSize = (int)(values.Count * 0.85); TrainingDataSet = new BasicMLDataSet(values.Take(trainingSetSize).ToArray(), answers.Take(trainingSetSize).ToArray()); ValidationDataSet = new BasicMLDataSet(values.Skip(trainingSetSize).ToArray(), answers.Skip(trainingSetSize).ToArray()); }
/// <summary> /// 添加一道题目的得分情况 /// </summary> /// <param name="pt">题目类型</param> /// <param name="score">所得分数</param> public void addDetail(ProblemType pt, int score) { foreach (Sum dt in sum) { if (dt.PType == pt) { dt.score += score; return; } } sum.Add(new Sum(pt, score)); }
public Problem( string userId, string function, string function2, ProblemType taskType, ProblemStatus taskStatus) { this.UserId = userId; this.Function = function; this.Function2 = function2; this.ProblemType = taskType; this.ProblemStatus = taskStatus; }
/// <summary> /// 构造一个程序改错题对象 /// 根据题目类型设置语言 /// </summary> /// <param name="pt">题目类型</param> public PModif(ProblemType pt) { type = pt; switch (pt) { case ProblemType.CProgramModification: language = PLanguage.C; break; case ProblemType.CppProgramModification: language = PLanguage.CPP; break; case ProblemType.VbProgramModification: language = PLanguage.VB; break; } this.Type = ProgramPType.Modify; }
/// <summary> /// 构造一个程序填空题对象 /// 根据题目类型设置语言 /// </summary> /// <param name="pt">题目类型</param> public PCompletion(ProblemType pt) { type = pt; switch (pt) { case ProblemType.CProgramCompletion: language = PLanguage.C; break; case ProblemType.CppProgramCompletion: language = PLanguage.CPP; break; case ProblemType.VbProgramCompletion: language = PLanguage.VB; break; } this.Type = ProgramPType.Completion; }
public static void AddNewProblem(ProblemModel model, int? id, ProblemType type) { using (TopCoderPrototypeEntities entityModel = new TopCoderPrototypeEntities()) { Problem problem = new Problem(); problem.Title = model.Title; problem.ProblemType = (int)type; BinaryFormatter bf = new BinaryFormatter(); MemoryStream ms = new MemoryStream(); bf.Serialize(ms, model); problem.Data = ms.ToArray(); entityModel.AddToProblems(problem); entityModel.SaveChanges(); } }
/// <summary> /// 构造一个程序编程题 /// 设置语言及题干 /// </summary> /// <param name="pt">题目类型</param> /// <param name="p">题干</param> public PFunction(ProblemType pt, string p) { problem = p; type = pt; switch (pt) { case ProblemType.CProgramFun: language = PLanguage.C; break; case ProblemType.CppProgramFun: language = PLanguage.CPP; break; case ProblemType.VbProgramFun: language = PLanguage.VB; break; } this.Type = ProgramPType.Function; }
public MLPNetwork(int layersCount, int neuronsCount, bool bias, ActivationFunctionType aft, ProblemType problemType, string inputFileName) { this.layersCount = layersCount; this.neuronsCount = neuronsCount; this.bias = bias; this.activationFunType = aft; this.problemType = problemType; LoadTrainingData(inputFileName); network = new BasicNetwork(); network.AddLayer(new BasicLayer(null, bias, trainingData.InputSize)); for (int i = 0; i < layersCount; i++) network.AddLayer(new BasicLayer(CreateActivationFunction(), bias, neuronsCount)); network.AddLayer(new BasicLayer(CreateActivationFunction(), false, outputSize)); network.Structure.FinalizeStructure(); network.Reset(); }
public CustomProgramInfo(ProblemType t) { InitializeComponent(); this.Dock = DockStyle.Fill; type = t; switch (type) { case ProblemType.BaseProgramCompletion: this.Rquest.Text = "根据题目描述完成编程填空题。"; totalCount = ClientControl.paper.pCompletion.Count; break ; case ProblemType.BaseProgramModification: this.Rquest.Text = "根据题目描述完成编程改错题。"; totalCount = ClientControl.paper.pModif.Count; break ; case ProblemType.BaseProgramFun: this.Rquest.Text = "根据题目描述完成编程综合题。"; totalCount = ClientControl.paper.pFunction.Count; break ; } this.SetQuestion(proID); }
/// <summary> /// Creates new instance of ProblemBase class /// </summary> /// <param name="name">Problem name</param> /// <param name="comment">Comment on problem</param> /// <param name="type">The problem type (TSP, ATSP, etc)</param> /// <param name="nodeProvider">Provider of graph nodes</param> /// <param name="edgeProvider">Provider of graph edges</param> /// <param name="edgeWeightsProvider">Provider of edge weights</param> /// <param name="fixedEdgesProvider">Provider of solution fixed edges</param> protected ProblemBase(string name, string comment, ProblemType type, INodeProvider nodeProvider, IEdgeProvider edgeProvider, IEdgeWeightsProvider edgeWeightsProvider, IFixedEdgesProvider fixedEdgesProvider) { if (nodeProvider == null) { throw new ArgumentNullException("nodeProvider"); } if (edgeProvider == null) { throw new ArgumentNullException("edgeProvider"); } if (edgeWeightsProvider == null) { throw new ArgumentNullException("edgeWeightsProvider"); } if (fixedEdgesProvider == null) { throw new ArgumentNullException("fixedEdgesProvider"); } Name = name; Comment = comment; Type = type; NodeProvider = nodeProvider; EdgeProvider = edgeProvider; EdgeWeightsProvider = edgeWeightsProvider; FixedEdgesProvider = fixedEdgesProvider; }
/// <summary> /// </summary> /// <param name="name">The name of the file containing the specific problem instance, excluding the file extension</param> /// <param name="type">The specific problem type (TSP, ATSP, etc)</param> /// <returns>The relevant TspLib95Item associated with "name" or a default item if not found</returns> public TspLib95Item GetItemByName(string name, ProblemType type) { return Items.Select(i => i).FirstOrDefault(i => i.Problem.Name == name && i.Problem.Type == type); }
public string Get(ProblemType pt) { string s = ""; XmlNode xn = Find(xd.ChildNodes.Item(1).ChildNodes.Item(0), pt.ToString()); if (xn != null) { foreach (XmlNode xnn in xn.ChildNodes) { if (xnn.Name == "StudentAns") { s += xnn.ChildNodes.Item(0).Value + ","; } if (xnn.Name == "AnsPath") { return xnn.ChildNodes.Item(0).Value; } } s = s.Remove(s.Length - 1); } return s; }
public string FindLogAns(ProblemType pt, int id) { string temp = ""; foreach (XmlNode xn in xd.ChildNodes.Item(1).ChildNodes) { if (xn.Attributes[1].Value == pt.ToString() && xn.ChildNodes[0].LastChild.Value == id.ToString()) { temp = xn.ChildNodes[1].LastChild.Value; } } return temp; }
public void AddStudentAns(ProblemType pt, Pid_Ans pa) { XmlNode xn; switch (pt) { case ProblemType.Choice: case ProblemType.Completion: case ProblemType.Judgment: case ProblemType.Word: case ProblemType.Excel: case ProblemType.PowerPoint: case ProblemType.CProgramCompletion: case ProblemType.CProgramModification: case ProblemType.CProgramFun: case ProblemType.CppProgramCompletion: case ProblemType.CppProgramModification: case ProblemType.CppProgramFun: case ProblemType.VbProgramCompletion: case ProblemType.VbProgramModification: case ProblemType.VbProgramFun: { xn = Find(xd.ChildNodes.Item(1).ChildNodes.Item(0), pt.ToString()); XmlElement xmlelem; xmlelem = xd.CreateElement("ProblemID"); xmlelem.AppendChild(xd.CreateTextNode(pa.id.ToString())); xn.AppendChild(xmlelem); xmlelem = xd.CreateElement("StudentAns"); xmlelem.AppendChild(xd.CreateTextNode(pa.ans)); xn.AppendChild(xmlelem); break; } default: { break; } } xd.Save(fileName); }
private int ProblemDificultyGenerator(ProblemType problemType) { return DificultyCoeff * (int)problemType; }
private string GetNextProblem(ProblemType type) { switch (type) { case ProblemType.Addition: _currentMathProblem = new AdditionProblem(GetDifficultyLevel()); _problems.Add(_currentMathProblem); break; case ProblemType.Subtraction: _currentMathProblem = new SubtractionProblem(GetDifficultyLevel()); _problems.Add(_currentMathProblem); break; case ProblemType.AddSubtract: if (rand.Next(4) >= 2) { _currentMathProblem = new AdditionProblem(GetDifficultyLevel()); _problems.Add(_currentMathProblem); } else { _currentMathProblem = new SubtractionProblem(GetDifficultyLevel()); _problems.Add(_currentMathProblem); } break; case ProblemType.Multiplication: _currentMathProblem = new MultiplicationProblem(GetDifficultyLevel()); _problems.Add(_currentMathProblem); break; case ProblemType.Division: _currentMathProblem = new DivisionProblem(GetDifficultyLevel()); _problems.Add(_currentMathProblem); break; case ProblemType.MultiplyDivide: if (rand.Next(4) >= 2) { _currentMathProblem = new MultiplicationProblem(GetDifficultyLevel()); _problems.Add(_currentMathProblem); } else { _currentMathProblem = new DivisionProblem(GetDifficultyLevel()); _problems.Add(_currentMathProblem); } break; case ProblemType.All: int randInt = rand.Next(8); if (randInt >= 6) { _currentMathProblem = new MultiplicationProblem(GetDifficultyLevel()); _problems.Add(_currentMathProblem); } else if (randInt >= 4) { _currentMathProblem = new DivisionProblem(GetDifficultyLevel()); _problems.Add(_currentMathProblem); } else if (randInt >= 2) { _currentMathProblem = new AdditionProblem(GetDifficultyLevel()); _problems.Add(_currentMathProblem); } else { _currentMathProblem = new SubtractionProblem(GetDifficultyLevel()); _problems.Add(_currentMathProblem); } break; } return "Problem Number " + _problems.Count + ": " + Environment.NewLine + Environment.NewLine + _currentMathProblem; }
public IdScoreType(int id, ProblemType pt, int score) { this.id = id; this.pt = pt; this.score = score; }
public IdAnswerType(int id, ProblemType pt, string answer) { this.id = id; this.pt = pt; this.answer = answer; }
public Problem(string name, ProblemType problemType, int dificulty) { this.name = name; this.problemType = problemType; this.dificulty = dificulty; }
/// <summary>Reports a problem to the host application.</summary> /// <param name="type">The type of problem that is reported.</param> /// <param name="text">The textual message that describes the problem.</param> public virtual void ReportProblem(ProblemType type, string text) { }
/// <summary> /// 获取题目类型对应的中文名称 /// </summary> /// <param name="pt">题目类型</param> /// <returns>中文名称</returns> public static string GetPTypeName(ProblemType pt) { switch (pt) { case ProblemType.Choice: return "选择题"; break; case ProblemType.Completion: return "填空题"; break; case ProblemType.Judgment: return "判断题"; break; case ProblemType.Word: return "Word题"; break; case ProblemType.PowerPoint: return "PowerPoint题"; break; case ProblemType.Excel: return "Excel题"; break; case ProblemType.CProgramCompletion: return "C程序填空题"; break; case ProblemType.CProgramModification: return "C程序改错题"; break; case ProblemType.CProgramFun: return "C程序综合题"; break; case ProblemType.CppProgramCompletion: return "C++程序填空题"; break; case ProblemType.CppProgramModification: return "C++程序改错题"; break; case ProblemType.CppProgramFun: return "C++程序综合题"; break; case ProblemType.VbProgramCompletion: return "VB程序填空题"; break; case ProblemType.VbProgramModification: return "VB程序改错题"; break; case ProblemType.VbProgramFun: return "VB程序综合题"; break; } return ""; }
private void AddProblem(System.Collections.Specialized.NameValueCollection form, ProblemType type, string userId) { var function1 = form["Function.Function1"]; var function2 = form["Function.Function2"]; var newProblem = new Problem(userId, function1, function2 == "" ? null : function2, type, ProblemStatus.Active); this.Data.Problems.Add(newProblem); this.Data.SaveChanges(); Common.Mistake[] mistakes = new Common.Mistake[4]; for (int i = 0; i < 4; i++) { var mistakeIndex = form["Mistakes[" + i + "].IndexOfX"]; var mistakeProduct = form["Mistakes[" + i + "].MistakenProduct"]; var mistakeValue = form["Mistakes[" + i + "].MistakenValue"]; string mistakeDisplay; if (i < 2) { mistakeDisplay = FunctionParser.GetDisplayX(mistakeProduct + mistakeIndex); } else { mistakeDisplay = FunctionParser.GetDisplayProduct(mistakeProduct); } var mistake = new NDKS.Models.Mistake(newProblem.Id, mistakeProduct, Int32.Parse(mistakeValue), mistakeIndex == "" ? null : (int?) Int32.Parse(mistakeIndex), mistakeDisplay); this.Data.Mistakes.Add(mistake); } this.Data.SaveChanges(); }
public void AddLog(ProblemType pt, Pid_Ans pa) { XmlNode xn; XmlElement xmlelem, xmlelem1; xmlelem = xd.CreateElement("Time"); XmlAttribute xa = xd.CreateAttribute("value"); xmlelem.Attributes.Append(xa); xmlelem.SetAttribute("value", DateTime.Now.ToLongTimeString()); xa = xd.CreateAttribute("type"); xmlelem.Attributes.Append(xa); xmlelem.SetAttribute("type", pt.ToString()); switch (pt) { case ProblemType.Choice: case ProblemType.Completion: case ProblemType.Judgment: { xmlelem1 = xd.CreateElement("ProblemID"); xmlelem1.AppendChild(xd.CreateTextNode(pa.id.ToString())); xmlelem.AppendChild(xmlelem1); xmlelem1 = xd.CreateElement("StudentAns"); xmlelem1.AppendChild(xd.CreateTextNode(pa.ans)); xmlelem.AppendChild(xmlelem1); break; } case ProblemType.Word: case ProblemType.Excel: case ProblemType.PowerPoint: case ProblemType.CProgramCompletion: case ProblemType.CProgramModification: case ProblemType.CProgramFun: case ProblemType.CppProgramCompletion: case ProblemType.CppProgramModification: case ProblemType.CppProgramFun: case ProblemType.VbProgramCompletion: case ProblemType.VbProgramModification: case ProblemType.VbProgramFun: { xmlelem1 = xd.CreateElement("ProblemID"); xmlelem1.AppendChild(xd.CreateTextNode(pa.id.ToString())); xmlelem.AppendChild(xmlelem1); xmlelem1 = xd.CreateElement("AnsPath"); xmlelem1.AppendChild(xd.CreateTextNode(pa.ans)); xmlelem.AppendChild(xmlelem1); break; } case ProblemType.Start: case ProblemType.Blank: { xmlelem1 = xd.CreateElement("ProblemID"); xmlelem1.AppendChild(xd.CreateTextNode(pa.id.ToString())); xmlelem.AppendChild(xmlelem1); xmlelem1 = xd.CreateElement("StudentAns"); xmlelem1.AppendChild(xd.CreateTextNode(pa.ans)); xmlelem.AppendChild(xmlelem1); break; } default: { break; } } xd.ChildNodes[1].AppendChild(xmlelem); xd.Save(fileName); }
public Sum(ProblemType pt, int score) { this.PType = pt; this.score = score; }
/// <summary> /// 数据库初始化 /// </summary> private static void Method05() { Menu root = new Menu() { Name = "root", Remark = "根", Parent = null, TreePath = "0", ActionName = "Index", SortCode = 0 }; Menu privage = new Menu() { Name = "privage", Remark = "权限", Parent = root, TreePath = "1", ActionName = "Index", SortCode = 2 }; Menu privage21 = new Menu() { Name = "Users", Remark = "用户管理", Parent = privage, TreePath = "2", ActionName = "Index", SortCode = 1 }; Menu privage22 = new Menu() { Name = "Roles", Remark = "角色管理", Parent = privage, TreePath = "2", ActionName = "Index", SortCode = 2 }; Menu siteManagement = new Menu() { Name = "SiteManagement", Remark = "现场管理", Parent = root, TreePath = "1", ActionName = "Index", SortCode = 3 }; Menu siteManagement31 = new Menu() { Name = "Problem", Remark = "异常管理", Parent = siteManagement, TreePath = "2", ActionName = "Index", SortCode = 1 }; Menu siteManagement32 = new Menu() { Name = "Problem", Remark = "异常报表", Parent = siteManagement, TreePath = "2", ActionName = "report", SortCode = 2 }; Menu siteManagement33 = new Menu() { Name = "Department", Remark = "部门", Parent = siteManagement, TreePath = "2", ActionName = "Index", SortCode = 3 }; Menu siteManagement34 = new Menu() { Name = "Factory", Remark = "工厂", Parent = siteManagement, TreePath = "2", ActionName = "Index", SortCode = 4 }; Menu siteManagement35 = new Menu() { Name = "ProblemSource", Remark = "问题来源", Parent = siteManagement, TreePath = "2", ActionName = "Index", SortCode = 5 }; Menu siteManagement36 = new Menu() { Name = "ProblemType", Remark = "问题类型", Parent = siteManagement, TreePath = "2", ActionName = "Index", SortCode = 6 }; Menu testLog = new Menu() { Name = "TestLog", Remark = "测试数据", Parent = root, TreePath = "1", ActionName = "Index", SortCode = 4 }; Menu testLog1 = new Menu() { Name = "Cpk", Remark = "Cpk测试数据", Parent = testLog, TreePath = "2", ActionName = "Index", SortCode = 1 }; Menu testLog2 = new Menu() { Name = "OperationLog", Remark = "测试数据操作Log", Parent = testLog, TreePath = "2", ActionName = "Index", SortCode = 2 }; Menu hr = new Menu() { Name = "Hr", Remark = "Hr数据", Parent = root, TreePath = "1", ActionName = "Index", SortCode = 5 }; Menu hr1 = new Menu() { Name = "SwipeCard", Remark = "刷卡管理", Parent = hr, TreePath = "2", ActionName = "Index", SortCode = 1 }; Menu hr2 = new Menu() { Name = "TemporaryCard", Remark = "临时卡管理", Parent = hr, TreePath = "2", ActionName = "Index", SortCode = 2 }; Menu hr3 = new Menu() { Name = "IgnoreCard", Remark = "过滤卡管理", Parent = hr, TreePath = "2", ActionName = "Index", SortCode = 3 }; Menu warehouse=new Menu() { Name = "WareHouse", Remark = "WareHouse数据", Parent = root, TreePath = "1", ActionName = "Index", SortCode = 6 }; Menu warehouse1 = new Menu() { Name = "PurchaseAndDelivery", Remark = "收退板查询", Parent = warehouse, TreePath = "2", ActionName = "Index", SortCode = 1 }; Menu warehouse2 = new Menu() { Name = "PurchaseAndDelivery", Remark = "收退板管理", Parent = warehouse, TreePath = "2", ActionName = "InAndOut", SortCode = 2 }; List<Menu> menus = new List<Menu> { root, privage, privage21, privage22, siteManagement, siteManagement31, siteManagement32, siteManagement33, siteManagement34, siteManagement35, siteManagement36, testLog, testLog1, testLog2, hr,hr1,hr2,hr3, warehouse,warehouse1,warehouse2 }; User user1 = new User() { Email = "123", CreatedTime = DateTime.Now, Name = "user1", NickName = "梁贵", Password = "******", }; User user2 = new User() { Email = "123", CreatedTime = DateTime.Now, Name = "user2", NickName = "梁贵2", Password = "******", }; List<User> users = new List<User> { user1, user2 }; Role role1 = new Role() { Name = "role1", Remark = "role1" }; Role role2 = new Role() { Name = "role2", Remark = "role2" }; role1.Menus = menus; role1.Users = users; List<Role> roles = new List<Role> { role1, role2 }; Factory factory1 = new Factory() { Text = "龙旗一厂", Value = "龙旗一厂" }; Factory factory2 = new Factory() { Text = "龙旗二厂", Value = "龙旗二厂" }; Factory factory3 = new Factory() { Text = "深圳振华", Value = "深圳振华" }; List<Factory> factorys = new List<Factory> { factory1, factory2, factory3 }; Department department1 = new Department() { Text = "生产", Value = "生产" }; Department department2 = new Department() { Text = "计划", Value = "计划" }; Department department3 = new Department() { Text = "工程", Value = "工程" }; Department department4 = new Department() { Text = "质量", Value = "质量" }; Department department5 = new Department() { Text = "仓库", Value = "仓库" }; List<Department> departments = new List<Department> { department1, department2, department3, department4, department5 }; ProblemSource problemSource1 = new ProblemSource() { Text = "邮件预警", Value = "邮件预警" }; ProblemSource problemSource2 = new ProblemSource() { Text = "用户反馈", Value = "用户反馈" }; ProblemSource problemSource3 = new ProblemSource() { Text = "客户反馈", Value = "客户反馈" }; List<ProblemSource> problemSources = new List<ProblemSource> { problemSource1, problemSource2, problemSource3 }; ProblemType problemType1 = new ProblemType() { Text = "MES系统", Value = "MES系统" }; ProblemType problemType2 = new ProblemType() { Text = "订单导入", Value = "订单导入" }; ProblemType problemType3 = new ProblemType() { Text = "入库比对", Value = "入库比对" }; ProblemType problemType4 = new ProblemType() { Text = "出库扫描", Value = "出库扫描" }; ProblemType problemType5 = new ProblemType() { Text = "数据回传", Value = "数据回传" }; List<ProblemType> problemTypes = new List<ProblemType> { problemType1, problemType2, problemType3, problemType4, problemType5 }; Problem problem1 = new Problem() { Department = "生产", Factory = "龙旗一厂", QuestionFrom = "邮件预警", Type = "MES系统", Workers = "梁贵", ProblemTime = DateTime.Now, Detail = "detail1", Reason = "reason1", IsComplete = true, IsPeople = true, IsDeleted = false, Remark = "remark1", Solution = "solution1", Suggestion = "suggestion1" }; Problem problem2 = new Problem() { Department = "生产", Factory = "龙旗一厂", QuestionFrom = "邮件预警", Type = "MES系统", Workers = "梁贵", ProblemTime = DateTime.Now.AddDays(1), Detail = "detail1", Reason = "reason1", IsComplete = true, IsPeople = true, IsDeleted = false, Remark = "remark1", Solution = "solution1", Suggestion = "suggestion1" }; List<Problem> problems = new List<Problem> { problem1, problem2 }; _program.MenuRepository.UnitOfWork.TransactionEnabled = true; Console.WriteLine(_program.MenuRepository.Insert(menus.AsEnumerable())); Console.WriteLine(_program.UserRepository.Insert(users.AsEnumerable())); Console.WriteLine(_program.RoleRepository.Insert(roles.AsEnumerable())); Console.WriteLine(_program.FactoryRepository.Insert(factorys.AsEnumerable())); Console.WriteLine(_program.DepartmentRepository.Insert(departments.AsEnumerable())); Console.WriteLine(_program.ProblemSourceRepository.Insert(problemSources.AsEnumerable())); Console.WriteLine(_program.ProblemTypeRepository.Insert(problemTypes.AsEnumerable())); Console.WriteLine(_program.ProblemRepository.Insert(problems.AsEnumerable())); _program.MenuRepository.UnitOfWork.SaveChanges(); }