public ContractContent(int Tier, string Title, string Description, Objective[] Objectives) { this.Tier = Tier; this.Title = Title; this.Description = Description; this.Objectives = Objectives; }
public void Initialize(Objective objective) { this.objective = objective; if (textName != null) { textName.text = objective.description; } if (statusImage != null) { switch (objective.state) { case Objective.ObjectiveState.inactive: gameObject.SetActive(false); break; case Objective.ObjectiveState.active: statusImage.sprite = inProgressSprite; Color currentColor = new Color(); ColorUtility.TryParseHtmlString("#7E0092FF", out currentColor); statusImage.color = currentColor; break; case Objective.ObjectiveState.complete: statusImage.sprite = completedSprite; break; } if(objective.state == Objective.ObjectiveState.complete) { statusImage.sprite = completedSprite; } else if (objective.state == Objective.ObjectiveState.active) { statusImage.sprite = inProgressSprite; } } }
public static void Test() { ProfessionCondition professionCondition1 = new ProfessionCondition(Person.ProfessionType.Educator, 3, ComparisonCondition.GREATER | ComparisonCondition.EQUAL); ProfessionCondition professionCondition2 = new ProfessionCondition(Person.ProfessionType.Worker, 0, ComparisonCondition.EQUAL); ProfessionCondition professionCondition3 = new ProfessionCondition(Person.ProfessionType.Educator, 3, ComparisonCondition.LESS); PotentialProfessionCondition professionCondition4 = new PotentialProfessionCondition(Person.ProfessionType.Educator, 3, ComparisonCondition.LESS); TurnCondition turnCondition = new TurnCondition(5, ComparisonCondition.LESS | ComparisonCondition.EQUAL); TurnCondition turnCondition2 = new TurnCondition(5, ComparisonCondition.GREATER); Objective objective1 = new Objective("Have at least 3 educators."); objective1.SuccessConditions.Add(professionCondition1); objective1.FailureConditions.Add(professionCondition4); Objective objective2 = new Objective("Give every worker a profession."); objective2.SuccessConditions.Add(professionCondition2); Objective objective3 = new Objective("No more than five days may elapse"); objective3.FailureConditions.Add(turnCondition2); Mission currentMission = new Mission(); currentMission.PrimaryObjectives.Add(objective1); currentMission.PrimaryObjectives.Add(objective2); currentMission.PrimaryObjectives.Add(objective3); currentMission.AddTrigger(new Trigger( new ProfessionCondition(Person.ProfessionType.Environmentalist, 0, ComparisonCondition.GREATER), new MoneyAdjustmentEvent(10))); XmlSerializer serializer = new XmlSerializer(typeof(Mission)); TextWriter writer = new StreamWriter("test.xml"); serializer.Serialize(writer, currentMission); writer.Close(); }
public IntelCommand(FireTeam executor, Vector3 nextPos, Objective intel) : base(executor) { this.targetPos = nextPos; this.intel = intel; this.executor = executor; executor.teammates[0].GetComponent<Soldier>().AddIPersonListener(this); }
public ContractContent(int Tier, string Title, string Description, string TargetShipImagePath, Objective[] Objectives) { this.Tier = Tier; this.Title = Title; this.Description = Description; this.TargetShipImagePath = TargetShipImagePath; this.Objectives = Objectives; }
/// <summary> /// draws default components /// </summary> /// <param name="objective">the objective of this view</param> public BaseView(Objective objective) { //draw components InitializeComponent(); //copy obejctive myObjective = objective; }
public Mission(Fish Agent, Objective Obj, Func<BitArray> Targets, bool OverrideDropMission = false, bool AttackAlongTheWay = true) { m_agent = Agent; m_obj = Obj; m_targets = Targets; m_attackAlongTheWay = AttackAlongTheWay; m_overrideDropMission = OverrideDropMission; }
Objective LoadObjective(Vector2 pos, string destScene, bool active, Objective next, string name) { Objective clone; clone = Instantiate(objPrefab, pos, Quaternion.identity) as Objective; clone.Init(destScene, active, next, name); objectives.Add(clone); return clone; }
private void Objective_OnCompleted(Objective sender) { UpdateListItem updateLine = Instantiate(updateListItemPrefab) as UpdateListItem; updateLine.transform.SetParent(transform); updateLine.animateTime = animationTime; updateLine.Text = "Completed: " + sender.description; sender.OnCompleted -= Objective_OnCompleted; itemsToBeAddedQueue.Enqueue(updateLine); }
public void SetLevelAndLoad(Objective obj) { Application.LoadLevel(obj.Destination); CurObjective = obj; foreach(GameObject go in GameObject.FindGameObjectsWithTag("objective")) { go.SetActive(false); } }
public override void Init() { newObstacle = myPet.GetCurrentPOI().GetComponent<Objective>(); if(newObstacle != currentObstacle) { currentObstacle = newObstacle; currentObstacle.Init(this as IPetCombat); } }
void AddToUI(Objective o) { GameObject go = Instantiate(UIObjectPrefab); Vector3 mod = new Vector3 (0, -counter * 40, 0); go.name = o.gameObject.name; go.transform.FindChild("Text").GetComponent<Text>().text = o.description; go.transform.SetParent(ObjectivePanel.transform, false); go.transform.localPosition = go.transform.localPosition + mod; counter++; }
public void ActivateObjective(Objective obj) { foreach (Objective o in objectives) { if (o.Equals(obj)) { o.Active = true; break; } } }
public static Unit[] GetAllUnitsWithObjective(Commander commander, Objective objective) { Unit[] allUnits = commander.GetAllUnits(); List<Unit> unitsWithObjective = new List<Unit>(); foreach(Unit u in allUnits) { if(u.currentObjective == objective) unitsWithObjective.Add(u); } return unitsWithObjective.ToArray(); }
public void RegisterListener(Objective o, Transform target) { this.observer = o; this.target = target; if (this.collider == null) gameObject.AddComponent<MeshCollider>(); if (target.collider == null) target.gameObject.AddComponent<MeshCollider>(); }
//On trigger void OnTriggerEnter2D(Collider2D c) { //If not issued, make a new mission, add the parts, issue it and update the UI. if (!issued) { Objective newObj = new Objective (missionName); foreach (string s in missionParts) { newObj.addPart (s); } ObjectiveHandler.inst.objectives.Add (newObj); ObjectiveHandler.inst.UpdateUI (); issued = true; } }
public Contract(string p_Name, string p_Description, string p_Title, string p_ImagePath, string p_ShipImagePath, Objective[] p_Objectives) { contractObjectives = p_Objectives.ToList(); completed = false; targetImage = Resources.Load<Sprite>(p_ImagePath); targetShipImage = Resources.Load<Sprite>(p_ShipImagePath); name = p_Name; title = p_Title; description = p_Description; reward = ""; objectivePrefab = Resources.Load("Objective") as GameObject; }
public void AddObjective(Objective objective) { if (ordered && objectives.Count == 0) { objective.orderNumber = 1; } if (ordered && objectives.Count > 0 && objective.orderNumber == 0) { objective.orderNumber = objectives.Count + 1; } objectives.Add(objective); }
public void Init(string dest, bool act, Objective next, string name) { destinationLevel = dest; active = act; if (active) GetComponent<SpriteRenderer>().sprite = sprites[0]; else GetComponent<SpriteRenderer>().sprite = sprites[1]; this.Next = next; gameObject.name = name; }
public void InitializeObjectives() { // Primary Objective time for now primary_objective.SetObjective (ObjectiveType.TIME, ObjectiveReward.NONE, baseTimePerLevel*level, 0); // Set secondary Objectives secondary_objectives = new Objective[num_objectives]; for(int i=0; i<num_objectives; i++){ secondary_objectives[i] = new Objective(); } secondary_objectives[0].SetObjective(ObjectiveType.DAMAGE, ObjectiveReward.GAINZ, Random.Range(2,5),Random.Range(20, 40)); secondary_objectives[1].SetObjective(ObjectiveType.KILL, ObjectiveReward.GAINZ, Random.Range (level * 2, level * 5),Random.Range(15, 30)); secondary_objectives [2].SetObjective (ObjectiveType.FIRE, ObjectiveReward.BRAINZ, Random.Range (level * 2, level * 5), Random.Range (15, 30)); secondary_objectives [3].SetObjective (ObjectiveType.SCAVENGER, ObjectiveReward.BRAINZ, Random.Range (5,10), Random.Range (20, 40)); }
public Contract(int p_Tier, string p_Name, string p_Description, string p_Title, string p_ImagePath, string p_ShipImagePath, Objective[] p_Objectives) { contractObjectives = p_Objectives.ToList(); completed = false; tier = p_Tier; targetImage = Resources.Load<Sprite>(p_ImagePath); targetShipImage = Resources.Load<Sprite>(p_ShipImagePath); name = p_Name; title = p_Title; description = p_Description; reward = DetermineReward(); objectivePrefab = Resources.Load("Objective") as GameObject; contractPlanet = WarpScript.instance.currentPlanet; }
static void GolombExecute( Solver solver, Objective objective, IntSearch search, string instance ) { DateTime start = DateTime.Now; solver.Solve( new GoalAnd( new IntGenerate( solver, solver.IntVarList.ToArray(), IntVarSelector.FirstNotBound, search ), new SolutionGoal( solver, solver.IntObjective, objective, instance ) ) ); SearchAll( solver, instance ); TimeSpan span = DateTime.Now - start; Console.Out.WriteLine(); Console.Out.WriteLine( instance + "\t" + span.ToString() ); }
void Start () { mQueue = GUIClass.messageQueue; allSpaceCrafts = SpaceCraft.spaceCraftList; planetList = Planet.planetList; ObjectiveFunction [0] = Obj1Check; ObjectiveFunction [1] = Obj2Check; ObjectiveFunction [2] = Obj3Check; ObjectiveFunction [3] = Obj4Check; ObjectiveFunction [4] = Obj5Check; ObjectiveFunction [5] = Obj6Check; ObjectiveFunction [6] = Obj7Check; for (int i = 0; i < numberOfObjectives; i++) { objsList [i] = new Objective (); objsList [i].ObjectiveGoal = objectiveGoal [i]; objsList [i].Check = ObjectiveFunction [i]; } }
public static void Golomb( int n ) { Golomb golomb = new Golomb( n ); Solver solver = golomb.Solver; solver.IntObjective.Var = golomb.MarkList[ golomb.MarkList.Count - 1 ]; solver.IntObjective.Step = 1; Objective objective = new Objective(); objective.Value = int.MaxValue; objective.Register( solver.IntObjective ); solver.Solve( new GoalAnd( new IntGenerate( solver, golomb.MarkList.ToArray(), IntVarSelector.FirstNotBound, new IntSearchInstantiateBest() ), new SolutionGoal( solver, solver.IntObjective, objective, "0" ) ) ); SearchAll( solver ); Console.Out.WriteLine(); Console.Out.WriteLine( solver.Time.ToString() ); }
void LoadNewObjectives() { int random1 = UnityEngine.Random.Range(0, objectiveList.Count); objective1 = objectiveList[random1]; objectiveGO1.GetComponent<GUITexture>().texture = objective1.texture; int random2 = UnityEngine.Random.Range(0, objectiveList.Count); objective2 = objectiveList[random2]; objectiveGO2.GetComponent<GUITexture>().texture = objective2.texture; int random3 = UnityEngine.Random.Range(0, objectiveList.Count); objective3 = objectiveList[random3]; objectiveGO3.GetComponent<GUITexture>().texture = objective3.texture; objective1.completed = false; objective2.completed = false; objective3.completed = false; objectiveGOCross1.guiTexture.enabled = false; objectiveGOCross2.guiTexture.enabled = false; objectiveGOCross3.guiTexture.enabled = false; }
/// <summary> /// Constructor /// </summary> /// <param name="objective">whats the objective?</param> /// <param name="messageText">text to display</param> public ClassesView(Objective objective, string messageText) : base(objective) { InitializeComponent(); //change message text lblMessage.Text = messageText; //copy objective myObjective = objective; //clear global variable GlobalData.currentCourse = null; //clear list lvwCourses.Items.Clear(); List<CourseData> myCourses; //get all logged in users classes myCourses = CourseController.GetCourses(GlobalData.currentUser); //add each class to the list foreach (CourseData course in myCourses) { ListViewItem item = lvwCourses.Items.Add(course.Name, 0); item.Tag = course; } //change visibility based on view type if (myObjective == Objective.ManageCourses) { mnsMain.Visible = true; } else { mnsMain.Visible = false; } }
/** * Call this when the objective needs to change */ public void ChangeObjective(Objective newObjective) { objective = newObjective; if (PhotonNetwork.player.GetTeam() == PunTeams.Team.red) { // Alien Debug.Log("Setting text of alien objectives"); transform.Find("Title").GetComponent<Text>().text = "Human Objective: " + objective.Title; transform.Find("Description").GetComponent<Text>().text = objective.Description; } else { // Human Debug.Log("Setting text of human objectives"); Debug.Log("Human objective title: " + objective.Title); Debug.Log("Human objective desc.: " + objective.Description); transform.Find("Title").GetComponent<Text>().text = objective.Title; transform.Find("Description").GetComponent<Text>().text = objective.Description; } Debug.Log("Objective title: " + transform.Find("Title").GetComponent<Text>().text); Debug.Log("Objective desc: " + transform.Find("Description").GetComponent<Text>().text); if (objective.Location == null) DeactivateLocationButton(); else ActivateLocationButton(); if (objective.Location2 != null) { PrimaryLocationButton.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(70f, -85f, 0f); SecondaryLocationButton.SetActive(true); } if (PhotonNetwork.player.GetTeam() == PunTeams.Team.red) { // Alien. Indicate primary human objective HumanObjectivePanel.SetActive(true); HumanObjectivePanel.transform.Find("Title").GetComponent<Text>().text = "Destroy The Ship"; HumanObjectivePanel.transform.Find("Description").GetComponent<Text>().text = "No one must escape. Your " + "sacrifice will not be in vain"; } }
void Start() { Slider = GetComponent <Slider>(); date = gameManager.Date; Slider.maxValue = date.Expectation; }
public RequiredSupplementaryDocumentBuilder WithObjective(Objective objective) { _objective = objective; return(this); }
public void addObjectives() { _objective = new Objective("Collect 5 Energy Crystals", true, 5); _objectiveMenu.ObjectivesList.Add(_objective); _objectiveMenu.UpdateObjectiveList(); }
/// <summary> /// Read the JSON file for the associated level name and set up the level object in the game code /// </summary> /// <param name="name"></param> private void loadLevel(string name) { // Open the file to read using (StreamReader r = new StreamReader("Levels/" + name + ".json")) { string json = r.ReadToEnd(); JObject levelJson = (JObject)JsonConvert.DeserializeObject(json); level = new Level(); level.name = levelJson.GetValue("levelName").ToString(); JArray photos = (JArray)levelJson.GetValue("photos"); level.photos = new List <Photo>(); // Iterate over the photos using (var photoEnum = photos.GetEnumerator()) { while (photoEnum.MoveNext()) { Photo photo = new Photo(); JObject photoJson = (JObject)photoEnum.Current; photo.name = (string)photoJson.GetValue("photo"); JArray objectives = (JArray)photoJson.GetValue("objectives"); photo.objectives = new List <Objective>(); // Iterate over the objectives using (var objectiveEnum = objectives.GetEnumerator()) { while (objectiveEnum.MoveNext()) { Objective objective = new Objective(); JObject objectiveJson = (JObject)objectiveEnum.Current; objective.x = (int)objectiveJson.GetValue("x"); objective.y = (int)objectiveJson.GetValue("y"); JArray words = (JArray)objectiveJson.GetValue("words"); objective.words = new List <string>(); // Iterate over the words using (var wordsEnum = words.GetEnumerator()) { while (wordsEnum.MoveNext()) { objective.words.Add((string)wordsEnum.Current); } } photo.objectives.Add(objective); } } level.photos.Add(photo); } } } currentPhotoIndex = 0; currentObjectiveIndex = 0; newLevelLoaded = true; correctAnswers = new List <string>(); }
/// <summary> /// Add a new objective into autopilot's action queue /// </summary> /// <param name="aObjective">Objective to be added/queued</param> public void EnqueueObjective(Objective aObjective) { ObjectiveQueue.Enqueue(aObjective); }
public static int Main(string[] args) { string modelDirectory = ((args != null) && (args.Length > 0)) ? args[0] : "../../models"; string solver = ((args != null) && (args.Length > 1)) ? args[1] : null; /* * // If the AMPL installation directory is not in the system search path: * ampl.Environment env = new ampl.Environment( * "full path to the AMPL installation directory"); * // Create an AMPL instance * using (AMPL a = new AMPL(env)) {} */ // Create an AMPL instance using (AMPL a = new AMPL()) { if (solver != null) { a.SetOption("solver", solver); } // Interpret the two files a.Read(System.IO.Path.Combine(modelDirectory, "diet/diet.mod")); a.ReadData(System.IO.Path.Combine(modelDirectory, "diet/diet.dat")); // Solve a.Solve(); // Get objective entity by AMPL name Objective totalcost = a.GetObjective("Total_Cost"); // Print it Console.WriteLine("ObjectiveInstance is: {0}", totalcost.Value); // Reassign data - specific instances Parameter cost = a.GetParameter("cost"); cost.SetValues(ampl.Tuple.FromArray("BEEF", "HAM"), new double[] { 5.01, 4.55 }); Console.WriteLine("Increased costs of beef and ham."); // ReSolve and display objective a.Solve(); Console.WriteLine("Objective value: {0}", totalcost.Value); // Reassign data - all instances cost.SetValues(new double[] { 3, 5, 5, 6, 1, 2, 5.01, 4.55 }); Console.WriteLine("Updated all costs"); // ReSolve and display objective a.Solve(); Console.WriteLine("New objective value: {0}", totalcost.Value); // Get the values of the variable Buy in a dataframe object Variable Buy = a.GetVariable("Buy"); // Access a specific instance (method 1) Console.WriteLine(Buy.Get("FISH").ToString()); // Access a specific instance (method 2) Console.WriteLine(Buy[new ampl.Tuple("FISH")].ToString()); DataFrame df = Buy.GetValues(); // Print them Console.WriteLine(df); // Get the values of an expression into a DataFrame object DataFrame df2 = a.GetData("{j in FOOD} 100*Buy[j]/Buy[j].ub"); // Print them Console.WriteLine(df2); } return(0); }
void NarrativeSwitchOff() { objectiveSwitchChecker = gameObjectiveEngine.currentObjective; switchNarrative = false; }
public Execute Store(Storage @in, string name, Objective objective) { return(this + $"store {@in} score {name} {objective}"); }
public void CreateObjective([FromBody] Objective newObjective) { facade.CreateObjective(newObjective); }
private static void RunLinearProgrammingExample(String solverType) { Solver solver = Solver.CreateSolver("IntegerProgramming", solverType); if (solver == null) { Console.WriteLine("Could not create solver " + solverType); return; } // x1, x2 and x3 are continuous non-negative variables. Variable x1 = solver.MakeNumVar(0.0, double.PositiveInfinity, "x1"); Variable x2 = solver.MakeNumVar(0.0, double.PositiveInfinity, "x2"); Variable x3 = solver.MakeNumVar(0.0, double.PositiveInfinity, "x3"); // Maximize 10 * x1 + 6 * x2 + 4 * x3. Objective objective = solver.Objective(); objective.SetCoefficient(x1, 10); objective.SetCoefficient(x2, 6); objective.SetCoefficient(x3, 4); objective.SetMaximization(); // x1 + x2 + x3 <= 100. Constraint c0 = solver.MakeConstraint(double.NegativeInfinity, 100.0); c0.SetCoefficient(x1, 1); c0.SetCoefficient(x2, 1); c0.SetCoefficient(x3, 1); // 10 * x1 + 4 * x2 + 5 * x3 <= 600. Constraint c1 = solver.MakeConstraint(double.NegativeInfinity, 600.0); c1.SetCoefficient(x1, 10); c1.SetCoefficient(x2, 4); c1.SetCoefficient(x3, 5); // 2 * x1 + 2 * x2 + 6 * x3 <= 300. Constraint c2 = solver.MakeConstraint(double.NegativeInfinity, 300.0); c2.SetCoefficient(x1, 2); c2.SetCoefficient(x2, 2); c2.SetCoefficient(x3, 6); Console.WriteLine("Number of variables = " + solver.NumVariables()); Console.WriteLine("Number of constraints = " + solver.NumConstraints()); int resultStatus = solver.Solve(); // Check that the problem has an optimal solution. if (resultStatus != Solver.OPTIMAL) { Console.WriteLine("The problem does not have an optimal solution!"); return; } Console.WriteLine("Problem solved in " + solver.WallTime() + " milliseconds"); // The objective value of the solution. Console.WriteLine("Optimal objective value = " + solver.Objective().Value()); // The value of each variable in the solution. Console.WriteLine("x1 = " + x1.SolutionValue()); Console.WriteLine("x2 = " + x2.SolutionValue()); Console.WriteLine("x3 = " + x3.SolutionValue()); Console.WriteLine("Advanced usage:"); Console.WriteLine("Problem solved in " + solver.Iterations() + " iterations"); Console.WriteLine("x1: reduced cost = " + x1.ReducedCost()); Console.WriteLine("x2: reduced cost = " + x2.ReducedCost()); Console.WriteLine("x3: reduced cost = " + x3.ReducedCost()); Console.WriteLine("c0: dual value = " + c0.DualValue()); Console.WriteLine(" activity = " + c0.Activity()); Console.WriteLine("c1: dual value = " + c1.DualValue()); Console.WriteLine(" activity = " + c1.Activity()); Console.WriteLine("c2: dual value = " + c2.DualValue()); Console.WriteLine(" activity = " + c2.Activity()); }
public static string FormattedCurrentValue(this Objective objective) { return(FormatValue(objective.CurrentValue, objective.DataType)); }
public static string FormattedBaselineValue(this Objective objective) { return(FormatValue(objective.BaselineValue, objective.DataType)); }
private List<Clue> PlaceCluesAndUpdateDependencyGraph(IEnumerable<int> clueVertices, Door doorLockedByClues, Objective objectiveLockedByClues) { //Add clues var clues = new List<Clue>(); foreach (var clueVertex in clueVertices) clues.Add(BuildAndAddClueToMap(clueVertex, doorLockedByClues, objectiveLockedByClues)); int thisDoorIndex; if (doorLockedByClues != null) thisDoorIndex = doorLockedByClues.LockIndex; else thisDoorIndex = objectiveLockedByClues.LockIndex; foreach (var clueVertex in clueVertices) { UpdateDependencyGraphWhenClueIsPlaced(clueVertex, new List<int> { thisDoorIndex }); } return clues; }
private Model Model(EczaneNobetTekGrupDataModel data) { var model = new Model() { Name = "Eczane Nöbet Tekli Model" }; #region Veriler var gunDegerler = data.TarihAraligi.Select(s => s.NobetGunKuralId).Distinct().ToList(); var diniBayramGunDegerleri = data.TarihAraligi.Where(w => w.NobetGunKuralId == 8).Select(s => s.NobetGunKuralId).Distinct().ToList(); var milliBayramGunDegerleri = data.TarihAraligi.Where(w => w.NobetGunKuralId == 9).Select(s => s.NobetGunKuralId).Distinct().ToList(); var bayramGunDegerleri = data.TarihAraligi.Where(w => w.NobetGunKuralId > 7).Select(s => s.NobetGunKuralId).Distinct().ToList(); #endregion #region Karar Değişkenleri _x = new VariableCollection <EczaneNobetTarihAralik>( model, data.EczaneNobetTarihAralik, "_x", null, h => data.LowerBound, h => data.UpperBound, a => VariableType.Binary); #endregion #region Amaç Fonksiyonu var amac = new Objective(Expression.Sum((data.EczaneNobetTarihAralik .Select(i => _x[i]))), "Sum of all item-values: ", ObjectiveSense.Minimize); model.AddObjective(amac); #endregion #region Kısıtlar #region Talep Kısıtları foreach (var nobetGrupGorevTip in data.NobetGrupGorevTipler) { foreach (var d in data.TarihAraligi) { //nöbet gruplarının günlük nöbetçi sayısı int talep = data.GerekliNobetSayisi; var talepFarkli = data.NobetGrupTalepler .Where(s => s.NobetGrupGorevTipId == nobetGrupGorevTip.Id && s.TakvimId == d.TakvimId) .Select(s => s.NobetciSayisi).SingleOrDefault(); if (talepFarkli > 0) { talep = talepFarkli; } model.AddConstraint( Expression.Sum(data.EczaneNobetTarihAralik .Where(k => k.TakvimId == d.TakvimId) .Select(m => _x[m])) == talep, $"her güne bir eczane atanmalı, {1}"); } } #endregion #region Arz Kısıtları #region Peşpeşe Görev Yazılmasın foreach (var f in data.EczaneKumulatifHedefler) { foreach (var g in data.TarihAraligi.Take(data.TarihAraligi.Count() - data.PespeseNobet)) { model.AddConstraint( Expression.Sum(data.EczaneNobetTarihAralik .Where(e => e.EczaneNobetGrupId == f.EczaneNobetGrupId && e.NobetGorevTipId == f.NobetGorevTipId && (e.Gun >= g.Gun && e.Gun <= g.Gun + data.PespeseNobet) ) .Select(m => _x[m])) <= 1, $"eczanelere peşpeşe nöbet yazılmasın, {f}"); } } #endregion #region Her eczaneye yazılması gereken nöbetler Nöbet arzlarını(kapasitelerini-hedeflerini) ayarla foreach (var hedef in data.EczaneKumulatifHedefler) { #region Toplam model.AddConstraint( Expression.Sum(data.EczaneNobetTarihAralik .Where(e => e.EczaneNobetGrupId == hedef.EczaneNobetGrupId && e.NobetGorevTipId == hedef.NobetGorevTipId) .Select(m => _x[m])) <= hedef.Toplam, $"her eczaneye bir ayda nöbet grubunun hedefi kadar nöbet yazılmalı, {hedef}"); model.AddConstraint( Expression.Sum(data.EczaneNobetTarihAralik .Where(e => e.EczaneNobetGrupId == hedef.EczaneNobetGrupId && e.NobetGorevTipId == hedef.NobetGorevTipId) .Select(m => _x[m])) >= hedef.Toplam - 1, $"her eczaneye bir ayda nöbet grubunun hedefi kadar nöbet yazılmalı, {hedef}"); #endregion #region Bayram Toplamları if (bayramGunDegerleri.Count() > 0) { var temp = hedef.ToplamBayram - 1; if (temp < 0) { temp = 0; } model.AddConstraint( Expression.Sum(data.EczaneNobetTarihAralik .Where(e => e.EczaneNobetGrupId == hedef.EczaneNobetGrupId && e.GunDegerId > 7) .Select(m => _x[m])) <= hedef.ToplamBayram, $"her eczaneye bir ayda nöbet grubunun hedefi kadar toplam bayram nöbeti yazılmalı, {hedef}"); model.AddConstraint( Expression.Sum(data.EczaneNobetTarihAralik .Where(e => e.EczaneNobetGrupId == hedef.EczaneNobetGrupId && e.GunDegerId > 7) .Select(m => _x[m])) >= temp, $"her eczaneye bir ayda nöbet grubunun hedefi kadar toplam bayram nöbeti yazılmalı, {hedef}"); } #endregion #region Diğer günler //gunDegerler: nöbet yazılacak tarih aralığındaki hafta ve bayram günleri foreach (var gunDeger in data.NobetGrupGunKurallar.Where(s => s.NobetGrupId == data.NobetGrup.Id).Select(s => s.NobetGunKuralId)) { //GetEczaneGunHedef2(out maxArz, out minArz, gunDeger, f.EczaneId); GetEczaneGunHedef(hedef, out double maxArz, out double minArz, gunDeger); model.AddConstraint( Expression.Sum(data.EczaneNobetTarihAralik .Where(e => e.EczaneNobetGrupId == hedef.EczaneNobetGrupId && e.GunDegerId == gunDeger) .Select(m => _x[m])) <= maxArz, $"her eczaneye bir ayda nöbet grubunun {gunDeger} hedefi kadar nöbet yazılmalı, {hedef}"); model.AddConstraint( Expression.Sum(data.EczaneNobetTarihAralik .Where(e => e.EczaneNobetGrupId == hedef.EczaneNobetGrupId && e.GunDegerId == gunDeger) .Select(m => _x[m])) >= minArz, $"her eczaneye bir ayda nöbet grubunun {gunDeger} hedefi kadar nöbet yazılmalı, {hedef}"); } #endregion } #endregion #region İstek Karşılansın //foreach (var f in data.EczaneNobetIstekler) //{ // model.AddConstraint( // Expression.Sum(data.EczaneNobetTarihAralik // .Where(e => e.EczaneId == f.EczaneId // && e.NobetGrupId == f.NobetGrupId // && e.TakvimId == f.TakvimId // && e.NobetGrupId == data.NobetGrup.Id // ) // .Select(m => _x[m])) == 1, // $"istege nobet yaz, {f}"); //} #endregion #region Mazerete Görev Yazılmasın foreach (var f in data.EczaneNobetMazeretListe) { model.AddConstraint( Expression.Sum(data.EczaneNobetTarihAralik .Where(e => e.EczaneId == f.EczaneId && e.NobetGrupId == f.NobetGrupId && e.TakvimId == f.TakvimId && e.NobetGrupId == data.NobetGrup.Id ) .Select(m => _x[m])) == 0, $"mazerete nobet yazma, {f}"); } #endregion #region Bayram günlerinde en fazla 1 görev yazılsın. //eğer bayram günleri ardışık günlerden fazlaysa if (data.TarihAraligi.Where(w => w.NobetGunKuralId > 7).Count() > data.PespeseNobet) { foreach (var f in data.EczaneKumulatifHedefler) { foreach (var g in data.TarihAraligi.Where(w => w.NobetGunKuralId > 7)) { model.AddConstraint( Expression.Sum(data.EczaneNobetTarihAralik .Where(e => e.EczaneNobetGrupId == f.EczaneNobetGrupId && e.Gun == g.Gun ) .Select(m => _x[m])) <= 1, $"bayram nöbeti sınırlama, {f}"); } } } #endregion #endregion #endregion return(model); }
public override void CheckDialog() { //玩家身上有任务,检测对话NPC是否为交任务NPC或者接任务NPC。 if (TaskMgr.Instance.OnGoingTask != null) { Task t = ResMgr.Instance.Load <Task>(TaskMgr.Instance.OnGoingTask.TaskID); if (t.CmpltOnOriginalNpc && t.originTaskGiver == tg._ID) { if (TaskMgr.Instance.CompleteTask(t)) { DialogMgr.Instance.EnqueueDialog(tg.currentTask.OnCmpltDialog, tg); tg.currentTask = tg.GetCurrentTask(); } else { DialogMgr.Instance.EnqueueDialog(tg.currentTask.OnGoingDialog, tg); } } else if (!t.CmpltOnOriginalNpc && t.CmpltNpcID == tg._ID) { if (TaskMgr.Instance.CompleteTask(t)) { DialogMgr.Instance.EnqueueDialog(t.OnCmpltDialog, tg); tg.currentTask = tg.GetCurrentTask(); } else { Objective currentOb = null; for (int i = 0; i < t.Objectives.Count; ++i) { if (!t.Objectives[i].IsFinish) { currentOb = t.Objectives[i]; break; } } if (currentOb is TalkObjective) { if ((currentOb as TalkObjective).TalkerID == tg._ID) { if (dialogSp && !DialogMgr.Instance.inDialog) { if (spIndex < specialDB.Count - 1) { spIndex++; } DialogMgr.Instance.EnqueueDialog(specialDB[spIndex], tg); if (spIndex == specialDB.Count - 1) { dialogSp = false; } } } } else { base.CheckDialog(); } } } else if (!t.CmpltOnOriginalNpc && t.originTaskGiver == tg._ID) { DialogMgr.Instance.EnqueueDialog(t.OnGoingDialog, tg); } else { if (dialogSp && !DialogMgr.Instance.inDialog) { if (spIndex < specialDB.Count - 1) { spIndex++; } DialogMgr.Instance.EnqueueDialog(specialDB[spIndex], tg); if (spIndex == specialDB.Count - 1) { dialogSp = false; } } else { base.CheckDialog(); } } } else { //玩家身上没任务,NPC身上有待接且未完成任务,就接 if (tg.GetCurrentTask() != null) { tg.currentTask = tg.GetCurrentTask(); if (!TaskMgr.Instance.HasCmpltTaskWithID(tg.currentTask.TaskID)) { DialogMgr.Instance.EnqueueDialog(tg.currentTask.OnGetDialog, tg); TaskMgr.Instance.AcceptTask(tg.currentTask); } } //没有待接任务就正常输出 else { if (dialogSp && !DialogMgr.Instance.inDialog) { if (spIndex < specialDB.Count - 1) { spIndex++; } DialogMgr.Instance.EnqueueDialog(specialDB[spIndex], tg); if (spIndex == specialDB.Count - 1) { dialogSp = false; } } else { base.CheckDialog(); } } } }
/// <summary> /// Clears current objective qeueue and adds the provided one into the empty queue /// </summary> /// <param name="aObjective">Objective to replace the others with</param> public void SetObjective(Objective aObjective) { ClearObjectives(); ObjectiveQueue.Enqueue(aObjective); }
static void Main() { // Data. // [START data_model] int[,] costs = { { 90, 80, 75, 70 }, { 35, 85, 55, 65 }, { 125, 95, 90, 95 }, { 45, 110, 95, 115 }, { 50, 100, 90, 100 }, }; int numWorkers = costs.GetLength(0); int numTasks = costs.GetLength(1); // [END data_model] // Model. // [START model] Solver solver = Solver.CreateSolver("SCIP"); // [END model] // Variables. // [START variables] // x[i, j] is an array of 0-1 variables, which will be 1 // if worker i is assigned to task j. Variable[,] x = new Variable[numWorkers, numTasks]; for (int i = 0; i < numWorkers; ++i) { for (int j = 0; j < numTasks; ++j) { x[i, j] = solver.MakeIntVar(0, 1, $"worker_{i}_task_{j}"); } } // [END variables] // Constraints // [START constraints] // Each worker is assigned to at most one task. for (int i = 0; i < numWorkers; ++i) { Constraint constraint = solver.MakeConstraint(0, 1, ""); for (int j = 0; j < numTasks; ++j) { constraint.SetCoefficient(x[i, j], 1); } } // Each task is assigned to exactly one worker. for (int j = 0; j < numTasks; ++j) { Constraint constraint = solver.MakeConstraint(1, 1, ""); for (int i = 0; i < numWorkers; ++i) { constraint.SetCoefficient(x[i, j], 1); } } // [END constraints] // Objective // [START objective] Objective objective = solver.Objective(); for (int i = 0; i < numWorkers; ++i) { for (int j = 0; j < numTasks; ++j) { objective.SetCoefficient(x[i, j], 1); } } objective.SetMinimization(); // [END objective] // Solve // [START solve] Solver.ResultStatus resultStatus = solver.Solve(); // [END solve] // Print solution. // [START print_solution] // Check that the problem has a feasible solution. if (resultStatus == Solver.ResultStatus.OPTIMAL || resultStatus == Solver.ResultStatus.FEASIBLE) { Console.WriteLine($"Total cost: {solver.Objective().Value()}\n"); for (int i = 0; i < numWorkers; ++i) { for (int j = 0; j < numTasks; ++j) { // Test if x[i, j] is 0 or 1 (with tolerance for floating point // arithmetic). if (x[i, j].SolutionValue() > 0.5) { Console.WriteLine($"Worker {i} assigned to task {j}. Cost: {costs[i, j]}"); } } } } else { Console.WriteLine("No solution found."); } // [END print_solution] }
public RequiredSupplementaryDocument(Objective objective, List <string> documentTypes, List <string> countryCodes) { Objective = objective; DocumentTypes = documentTypes; CountryCodes = countryCodes; }
private void Start() { objectiveScript = FindObjectOfType <Objective>(); }
private async Task DeleteObjective_Click(Objective objective) { await scoreboard.DeleteAsync(objective.Id); _scoreboard.Remove(objective); }
public bool ObjectiveWeightsEqual100(ObjectiveKeyResult objectiveKeyResult, Objective newObjective) { var currentSum = objectiveKeyResult.Objectives.Sum(o => o.Weight); return(currentSum + newObjective.Weight != 100); }
void PrepareObjectives() { for (int i = 0; i < objectives.Count; i++) { if (i < savedObjectiveId) { if (objectives [i].objectsToDisable != null) { objectives [i].objectsToDisable.SetActive(false); } if (objectives [i].objectsToEnable != null) { objectives [i].objectsToEnable.SetActive(true); } //skip animations we have passed if (objectives [i].animation != null) { objectives [i].animation.SetTrigger("Skip"); } //these enemies are dead so don't bring them back if (objectives [i].type == Objective.Type.Kills) { objectives [i].objectiveObj.SetActive(false); } //reactivates escort EscortController escort = objectives [i].objectiveObj.GetComponent <EscortController> (); if (escort != null) { escort.Enable(); } } else { if (objectives [i].objectsToEnable != null) { objectives [i].objectsToEnable.SetActive(false); } } if (objectives [i].type == Objective.Type.Camera) { if (objectives [i].objectiveObj.GetComponent <Camera> () != null) { objectives [i].objectiveObj.SetActive(false); } } if (objectives [i].hasCameraEvent) { Objective newCameraObjective = new Objective(); newCameraObjective.type = Objective.Type.Camera; newCameraObjective.objectiveObj = objectives [i].objectiveObj; newCameraObjective.showsWorldIndicator = objectives [i].showsWorldIndicator; newCameraObjective.time = objectives[i].time; objectives [i].time = 0; objectives.Insert(i, newCameraObjective); i++; } } }
// Token: 0x0600343D RID: 13373 RVA: 0x00029817 File Offset: 0x00027A17 public int GetObjectiveIndex(Objective objective) { return(this.Objectives.IndexOf(objective)); }
private void Awake() { m_Goal = FindObjectOfType <Objective>(); }
public Objective GetItem(string id) { Objective item = ItemRepository.Get(id); return(item); }
/// <summary> /// The protocols for how link fields are named vary. Try the most likely two possibilities, /// and log failures. /// </summary> /// <param name="relationship">The relationship to set.</param> /// <returns>True if the relationship was created, else false.</returns> public static bool TrySetRelationship(SetRelationshipParams relationship, Objective objective) { return(TrySetRelationship(relationship, $"{relationship.module2}") || TrySetRelationship(relationship, $"{relationship.module2}_{relationship.module1}") || TrySetRelationship(relationship, GetActivitiesLinks(relationship.module1, objective))); }
protected override Heuristic CreateHeuristic(OrganonConfiguration organonConfiguration, Objective objective, HeuristicParameters parameters) { ThresholdAccepting acceptor = new ThresholdAccepting(this.Stand !, organonConfiguration, objective, parameters); if (this.IterationsPerThreshold != null) { acceptor.IterationsPerThreshold.Clear(); acceptor.IterationsPerThreshold.AddRange(this.IterationsPerThreshold); } if (this.Thresholds != null) { acceptor.Thresholds.Clear(); acceptor.Thresholds.AddRange(this.Thresholds); } return(acceptor); }
private Objective BuildAndAddObjectiveToMap(ObjectiveRequirements thisObj) { //Find the possible rooms that this objective could be placed in the real map var possibleRooms = mapNoCycles.roomMappingNoCycleToFullMap[thisObj.Vertex]; int thisLockIndex = nextLockIndex; nextLockIndex++; var newObj = new Objective(thisObj.Vertex, thisObj.Id, thisLockIndex, GetLockIndicesByIds(thisObj.OpenLockId), thisObj.NumberOfCluesRequired, possibleRooms); //add to lock map objectiveMap.Add(thisLockIndex, newObj); lockDependencyGraph.AddVertex(thisLockIndex); //add to room map List<Objective> objListAtVertex; objectiveRoomMap.TryGetValue(thisObj.Vertex, out objListAtVertex); if (objListAtVertex == null) { objectiveRoomMap[thisObj.Vertex] = new List<Objective>(); } objectiveRoomMap[thisObj.Vertex].Add(newObj); return newObj; }
bool AllowedToComplete(Objective obj) { return(Condition.AllowedToComplete()); }
public Execute Unless(string target, Objective targetObj, ScoreOperator @operator, string src, Objective srcObj) { return(this + $"unless score {target} {targetObj} {@operator} {src} {srcObj}"); }
static void Main(string[] args) { SBMLNamespaces sbmlns = new SBMLNamespaces(3, 1, "fbc", 1); SBMLDocument document = new SBMLDocument(sbmlns); // create the Model Model model = document.createModel(); // create the Compartment Compartment compartment = model.createCompartment(); compartment.setId("compartment"); compartment.setConstant(true); compartment.setSize(1); // create the Species Species species = model.createSpecies(); species.setId("Node1"); species.setCompartment("compartment"); species.setConstant(false); species.setHasOnlySubstanceUnits(false); species.setBoundaryCondition(false); species = model.createSpecies(); species.setId("Node2"); species.setCompartment("compartment"); species.setConstant(false); species.setHasOnlySubstanceUnits(false); species.setConstant(false); species.setHasOnlySubstanceUnits(false); species.setBoundaryCondition(false); species = model.createSpecies(); species.setId("Node3"); species.setCompartment("compartment"); species.setConstant(false); species.setHasOnlySubstanceUnits(false); species.setBoundaryCondition(false); species = model.createSpecies(); species.setId("Node4"); species.setCompartment("compartment"); species.setConstant(false); species.setHasOnlySubstanceUnits(false); species.setBoundaryCondition(false); species = model.createSpecies(); species.setId("Node5"); species.setCompartment("compartment"); species.setConstant(false); species.setHasOnlySubstanceUnits(false); species.setBoundaryCondition(false); species = model.createSpecies(); species.setId("Node6"); species.setCompartment("compartment"); species.setConstant(false); species.setHasOnlySubstanceUnits(false); species.setBoundaryCondition(false); species = model.createSpecies(); species.setId("Node7"); species.setCompartment("compartment"); species.setConstant(false); species.setHasOnlySubstanceUnits(false); species.setBoundaryCondition(false); species = model.createSpecies(); species.setId("Node8"); species.setCompartment("compartment"); species.setConstant(false); species.setHasOnlySubstanceUnits(false); species.setBoundaryCondition(false); species = model.createSpecies(); species.setId("Node0"); species.setCompartment("compartment"); species.setConstant(false); species.setHasOnlySubstanceUnits(false); species.setBoundaryCondition(true); species = model.createSpecies(); species.setId("Node9"); species.setCompartment("compartment"); species.setConstant(false); species.setHasOnlySubstanceUnits(false); species.setBoundaryCondition(true); Reaction reaction = model.createReaction(); reaction.setId("J0"); reaction.setReversible(false); reaction.setFast(false); SpeciesReference reactant = reaction.createReactant(); reactant.setSpecies("Node0"); reactant.setStoichiometry(1); reactant.setConstant(true); SpeciesReference product = reaction.createProduct(); product.setSpecies("Node1"); product.setStoichiometry(1); product.setConstant(true); reaction = model.createReaction(); reaction.setId("J1"); reaction.setReversible(false); reaction.setFast(false); reactant = reaction.createReactant(); reactant.setSpecies("Node1"); reactant.setStoichiometry(1); reactant.setConstant(true); product = reaction.createProduct(); product.setSpecies("Node2"); product.setStoichiometry(1); product.setConstant(true); reaction = model.createReaction(); reaction.setId("J2"); reaction.setReversible(false); reaction.setFast(false); reactant = reaction.createReactant(); reactant.setSpecies("Node2"); reactant.setStoichiometry(1); reactant.setConstant(true); product = reaction.createProduct(); product.setSpecies("Node3"); product.setStoichiometry(1); product.setConstant(true); reaction = model.createReaction(); reaction.setId("J3"); reaction.setReversible(false); reaction.setFast(false); reactant = reaction.createReactant(); reactant.setSpecies("Node1"); reactant.setStoichiometry(1); reactant.setConstant(true); product = reaction.createProduct(); product.setSpecies("Node4"); product.setStoichiometry(1); product.setConstant(true); reaction = model.createReaction(); reaction.setId("J4"); reaction.setReversible(false); reaction.setFast(false); reactant = reaction.createReactant(); reactant.setSpecies("Node4"); reactant.setStoichiometry(1); reactant.setConstant(true); product = reaction.createProduct(); product.setSpecies("Node3"); product.setStoichiometry(1); product.setConstant(true); reaction = model.createReaction(); reaction.setId("J5"); reaction.setReversible(false); reaction.setFast(false); reactant = reaction.createReactant(); reactant.setSpecies("Node3"); reactant.setStoichiometry(1); reactant.setConstant(true); product = reaction.createProduct(); product.setSpecies("Node5"); product.setStoichiometry(1); product.setConstant(true); reaction = model.createReaction(); reaction.setId("J6"); reaction.setReversible(false); reaction.setFast(false); reactant = reaction.createReactant(); reactant.setSpecies("Node5"); reactant.setStoichiometry(1); reactant.setConstant(true); product = reaction.createProduct(); product.setSpecies("Node6"); product.setStoichiometry(1); product.setConstant(true); reaction = model.createReaction(); reaction.setId("J7"); reaction.setReversible(false); reaction.setFast(false); reactant = reaction.createReactant(); reactant.setSpecies("Node6"); reactant.setStoichiometry(1); reactant.setConstant(true); product = reaction.createProduct(); product.setSpecies("Node7"); product.setStoichiometry(1); product.setConstant(true); reaction = model.createReaction(); reaction.setId("J8"); reaction.setReversible(false); reaction.setFast(false); reactant = reaction.createReactant(); reactant.setSpecies("Node5"); reactant.setStoichiometry(1); reactant.setConstant(true); product = reaction.createProduct(); product.setSpecies("Node8"); product.setStoichiometry(1); product.setConstant(true); reaction = model.createReaction(); reaction.setId("J9"); reaction.setReversible(false); reaction.setFast(false); reactant = reaction.createReactant(); reactant.setSpecies("Node8"); reactant.setStoichiometry(1); reactant.setConstant(true); product = reaction.createProduct(); product.setSpecies("Node7"); product.setStoichiometry(1); product.setConstant(true); reaction = model.createReaction(); reaction.setId("J10"); reaction.setReversible(false); reaction.setFast(false); reactant = reaction.createReactant(); reactant.setSpecies("Node7"); reactant.setStoichiometry(1); reactant.setConstant(true); product = reaction.createProduct(); product.setSpecies("Node9"); product.setStoichiometry(1); product.setConstant(true); // // Get a FbcModelPlugin object plugged in the model object. // // The type of the returned value of SBase::getPlugin() function is SBasePlugin, and // thus the value needs to be casted for the corresponding derived class. // FbcModelPlugin mplugin = (FbcModelPlugin)(model.getPlugin("fbc")); FluxBound bound = mplugin.createFluxBound(); bound.setId("bound1"); bound.setReaction("J0"); bound.setOperation("equal"); bound.setValue(10); Objective objective = mplugin.createObjective(); objective.setId("obj1"); objective.setType("maximize"); // mark obj1 as active objective mplugin.setActiveObjectiveId("obj1"); FluxObjective fluxObjective = objective.createFluxObjective(); fluxObjective.setReaction("J8"); fluxObjective.setCoefficient(1); libsbml.writeSBMLToFile(document, "fbc_example1.xml"); }
public void SetObjectives(Objective[] objectives) { this.objectives = objectives; }
public Execute Unless(string target, Objective targetObj, IntRange matches) { return(this + $"unless score {target} {targetObj} matches {matches}"); }