1. Trang chủ
  2. » Ngoại Ngữ

14531-spreadsheet-based-modeling-and-optimization-of-a-bi-modal-traveling-salesman-problem-model-solution-and-case

40 3 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 40
Dung lượng 2,89 MB

Nội dung

Bond University Volume 12| Issue | 2020 Spreadsheet-Based Modeling and Optimization of a Bi-Modal Traveling Salesman Problem: Model, Solution, and Case Roger Grinde, Decision Sciences University of New Hampshire roger.grinde@unh.edu _ Follow this and additional works at: https://sie.scholasticahq.com This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 4.0 Licence Spreadsheet-Based Modeling and Optimization of a BiModal Traveling Salesman Problem: Model, Solution, and Case Roger Grinde Decision Sciences, University of New Hampshire roger.grinde@unh.edu Abstract This paper presents a bi-modal routing problem and two-phase spreadsheet-based model and solution approach The problem is the Bi-Modal Covering Salesman Problem, and the context for the problem in this paper is a recreational hiking problem Two hikers seek to traverse a set of peaks, where they have defined a number of hikes from which to choose The problem is to a) identify the set of hikes in order to minimize a hiking time objective while ascending all peaks, followed by b) sequencing the chosen hikes in order to minimize a driving distance objective The problem essentially combines two wellknown problems in Operations Research: the Set Covering Problem and the Traveling Salesman Problem A mathematical programming formulation is presented, followed by a detailed explanation of the Excel™ model and solution approach with Solver™, using linear and evolutionary engines The model is enhanced using Visual Basic for Applications In instruction, it can be utilized in many ways, from a classroom discussion example all the way up to a semester long project done in several phases A case, split into two parts, is provided in the appendix The full workbook and a template file is available upon request from the author Keywords: routing, optimization, Operations Research, traveling salesman, spreadsheet, Excel, Solver, VBA, Simplex Method, evolutionary algorithm 1.0 Introduction This paper presents a model and solution of a bi-modal routing problem related to the well-known Traveling Salesman Problem (TSP) It is bi-modal due to vehicular and walking travel and is termed the Bi-Modal Covering Salesman Problem (BCSP) A model formulation, spreadsheet-based solution approach (Excel™ with VBA), and case study are provided It is suited for courses related to Optimization, Operations Research, Management Science, Business Analytics, and programming at various levels and various programs (e.g., business, engineering, applied mathematics) depending on what aspects of the problem-solving process the instructor wishes to emphasize From an educational standpoint, the problem has some key differences compared to the TSP, which present questions of how to model it, and then how to find a solution approach The problem can be used to emphasize the modeling aspect, the spreadsheet implementation, VBA enhancements, or some combination of these It could also be used as a guided semester-long project where these aspects are emphasized during different phases The author has used the problem as a case in an MBA course in Management Science with good results The specific problem arises in hiking, but it is related to some other variations of the TSP and is applicable to some other bi-modal routing situations There are a number of mountain peaks to climb For this paper, the specific problem of the 48 mountain peaks above 4000 feet in altitude, in the State of New Hampshire, USA, are used (Smith & Dickerman, 2012) The hikers seek to a) identify the set of hikes to perform which will ascend each peak in the shortest hiking time; and b) sequence the hikes to minimize the driving distance between and within hikes Appendices C and D contain case studies for classroom use The method is generalizable to other situations Briefly, the peaks are reached by one or more trails, each with trailheads A specific trail may traverse more than one peak and may be a round-trip trail or a one-way trail Trailheads are connected by a network of roads Two hikers utilize two vehicles to reach the trailheads, and then hike one or more hikes from that trailhead In the case of one-way hikes, the hikers must stage a vehicle at each end of the trailhead In this section, related work is discussed Section presents the problem formulation and outlines the solution approach The spreadsheet implementation (in Excel™ and VBA) is explained in Section 3, and Section explores educational value and possible uses Concluding remarks are provided in Section Appendices contain VBA code and the case study presented, in two parts The spreadsheet implementation and a template file is available from the author upon request The TSP and related Vehicle Routing Problem (VRP) have a rich literature due to their many practical applications as well as solution challenges Examples include Gutin (2007), Applegate et al (2007), Golden et al (2008), and Braekers et al (2016) Review of multi-objective problems is done by Jozefowiez et al (2008) The Covering Tour Problem (CTP) has similarity to the BCSP discussed in this paper, in that there are two node sets However, in the CTP there is only one mode of transportation The goal is to find a minimum-cost tour through a subset of the nodes in one set, so that every node in the other set is within some critical distance of a visited nodes (e.g., rural health clinics might be one node set, and towns/villages might be the other node set) Current & Schilling (1989) introduced this problem, and it has been studied by others The problem most directly related to the BCSP presented in this paper is termed the Walking Line of Travel Problem (WLT) It was studied by Levy & Bodin (1988) The example provided was to schedule postal carriers who drive to a parking area, complete a walking tour delivering mail, and return to the vehicle It differs from the BCSP in that one-way trips are not allowed, so the BCSP is a more general version of the WLT problem Grinde (2017) presents a formulation of the BCSP, an heuristic solution approach using traditional optimization software, and computational results 2.0 Problem Formulation and Solution Approach The BCSP uses two networks, one for each mode of transportation In the hiking case problem, one network is a set of parking areas (P1, P2, …, Pm) connected by roads The other network is a set of peaks (“cities” in the traditional TSP language), denoted by (C1, C2, …, Cn) and connected by trails Some trails have connection points to parking areas Each of the peaks must be visited at least once Figure shows an example The overall objective is to minimize total weighted travel time or distance (driving plus hiking) while visiting each peak at least once This involves driving from a home base to one of the parking areas, making one or more hikes (either cyclical or chain hikes, to be discussed shortly), driving to another parking area and hiking from there, and returning to the home base after all peaks have been visited Figure Road and Trail Networks The concept of a single trip visiting one or more peaks (hike in this problem context) is as follows The car is driven to a parking area Pi A hike is performed, which visits one or more peaks Two possibilities exist for the end of the hike A loop or cyclical hike is when the hikers return to Pi, and then drive to another parking location (or perform another hike from Pi) Figure shows a cyclical hike; Figure a chain hike A one-way, or chain, hike ends at a different parking area, say Pj To perform a chain hike, both hikers drive to Pj, the endpoint of the hike, and leave one car Then they drive to Pi, and depart on the hike Finishing the hike at Pj, they drive back to Pi to retrieve the other car Cyclical Trip Illustration Road C2 Trail Parking Area Step 2: Hike C1 Peak C3 P Step 1: Drive Cars Step 3: Drive Cars Figure Cyclical Hike Chain Trip Illustration Road C2 Trail Parking Area Step 3: Hike C1 Peak C3 Step 2: Drive Car to begin of hike P2 (end of hike) P1 (begin of hike) Step 1: Drive Cars from previous hike Step 4: Drive Car to begin of hike Step 5: Drive Cars to next hike Figure Chain Hike Chain hike feasibility depends on the application In the hiking setting, it is common not only to have two hikers, but also that some hikes are more naturally done as one-way hikes This has the potential to reduce hiking time considerably Having two cars increases the total mileage driven, though not necessarily the time Chain hikes (trips) may be useful in other settings as well, with or without multiple vehicles For example if the “parking” areas are airports, and customers are to be visited on one-way trips between airports Another example may occur with bike or car sharing programs, where the pick-up and drop-off locations can be different Other application notes are discussed as part of Case A (Appendix C) The modeling and solution approach here assumes that possible hiking trips are developed in advance This is reasonable, as there are many hiking guides available and there tends to be a finite number of reasonable hikes The problem becomes two-phased: 1) select which hikes to perform, visiting each peak at least once while minimizing the hiking objective; and 2) sequencing the sequencing hikes so the driving objective is optimized The objective can be time-based or distance-based, or a weighted combination In the spreadsheet implementation developed for this paper, the hikingbased objective has precedence over the driving-based objective A mathematical programming formulation of the BCSP is presented here This is the same as in Grinde (2017) That paper then used traditional optimization tools for the solution and presented computational experience This paper uses the formulation as a guide for the development of the spreadsheet-based approach which is the focus here When using this problem in an educational setting, the instructor can choose the depth in which to cover the formulation In a mathematical programming course, the formulation would probably receive much attention In an application-based MBA course, the formulation might be used mainly to illustrate the correspondence between the formulation and the resulting Excel™ and Solver™ model Notation is as follows: i = 1,…,m trip index (hiking trips, each visiting one or more peaks) j = 1,…,n customer (peak) index ci = hiking cost of trip i (e.g., time, distance) dik = driving cost of driving from trip i to trip k (e.g., time, distance) aij = if trip i visits customer (peak) j; otherwise The direction of travel could affect the hike cost (e.g., terrain features), so it is common to define a hike in each direction, especially for chain hikes (cyclical hikes can be done in the fastest way with no impact on driving logistics) The driving distance matrix (elements are dik) is the matrix of hike-hike distances Decision variables for the problem are xi for each trip being selected or not, and yik used to model the sequencing of trips Both sets of variables are binary Specifically, xi = if trip (hike) i is selected; otherwise yik = if trip (hike) k follows trip (hike) i (k≠i); otherwise A mathematical programming formulation follows Because the objective is the combination of hiking and driving objectives, w1 and w2 are used respectively to weight the objectives 𝑤 𝑐𝑥 +𝑤 𝑑 𝑦 subject to 𝑎 𝑥 ≥1 𝑗 = … 𝑛 (1) 𝑦 −𝑥 =0 𝑖 = … 𝑚 (2) 𝑦 −𝑥 =0 𝑘 = … 𝑚 (3) subtour elimination constraints 𝑥 , 𝑦 ∈ {0,1} The objective is the weighted sum of the hiking and driving costs For relatively larger values of w1, the hiking objective is more important, and vice versa Constraints (1) ensure that every peak is visited at least once (these constraints are essentially the type of constraints found in set covering problems, hence the “covering” in the BCSP acronym) Constraints (2) and (3) make sure that the selected hikes are connected to the actual driving network That is, if a hike is not selected, no drives should be selected to or from that hike Similarly, if a hike is selected, there must be one drive to that hike and one drive away from that hike The subtour elimination constraints ensure that the hikes selected form a full cycle (aka, Hamiltonian tour) These latter constraints are essentially the constraints found in a typical Traveling Salesman Problem Weights on the objective allow for differential importance of the hiking and driving objectives That said, the two-objective problem is a very difficult mathematical program to solve However, the objective and constraints are separable by objective Specifically, by addressing the hiking objective first, the best set of hikes can be identified This is essentially Phase I of the solution process Once this is done, the selected hikes can be sequenced to minimize the driving objective This is Phase II of the solution process The spreadsheet implementation developed in this paper is solved using this two-phased approach where the hiking objective taking precedence over the driving objective 3.0 Spreadsheet-Based Solution Approach 3.1 Overview of Workbook Based on the problem formulation of the previous section, and the two-phased solution approach, the problem is modeled and solved using Excel™ and Solver™ Visual Basic for Applications (VBA) is used to automate tasks such as resetting and building the Solver settings, and for solving the Phase II problem using several different random starting sequences However, VBA is not needed for the core functionality of the model and heuristic solution Extensive use of range names is made to allow for better selfdocumentation of formulas, generality, easier scalability, and better generality of the VBA code A Documentation sheet is included that provides the formula logic in tabular form, definitions of the named ranges, and screen shots of Solver settings This section first provides an overview of the structure of the workbook and its sheets, and then provides explanations of the core functional aspects of those sheets Figure shows, in block diagram form, the logical structure of the workbook The two primary sheets are Model_Cover and Model_Sequence Model_Cover is for the Phase I problem It contains the definitions of the hikes and the optimization model to select the hikes that minimize the hiking objective Model_Sequence is for the Phase II problem It extracts the selected hikes from Model_Cover, and contains the optimization model to identify the best sequence in which to perform the hikes according to the driving objective Model_Sequence uses driving distances between hikes computed and stored in the Hike_Hike_Dist sheet In turn, the Hike_Hike_Dist sheet is computed from distance values between parking areas stored in the Drives sheet Two other sheets are used by VBA in the event the user wants to try one or more random starting sequences for the selected hikes These are the Index_Randomizer sheet, which computes a random sequence of hikes for the correct number of selected hikes The VBA_Support_Sheet is used to store the best-found sequence of hikes for the Phase II problem if the user tries one or more random starting sequences VBA is used on the Model_Cover sheet to quickly build the Solver settings for either a distance-based or time-based hiking objective, and to solve the Solver model On the Model_Sequence sheet, VBA is used to reset and rebuild the Solver model (necessary if the number of selected hikes changes), to reset the sequence of hikes to an increasing order of hike number, to compute and show a random sequence of hikes and the resulting driving distance, to solve the Solver model, and to run the Solver model for a user-specified number of random starting solutions Figure Logical Structure of Workbook Table lists the defined ranges in the workbook Some of these will be mentioned when discussing the detailed logic Table Range Names and Associated Cell References Worksheet Model_Cover Model_Cover Model_Cover Model_Cover Model_Cover Model_Cover Model_Cover Model_Cover Model_Cover Model_Cover Model_Cover Range Name Hike_ID Hike_Info HikeChosen HikePeakArray Max_Allowed_Hiking_Tim e Max_Avg_Hiking_Time Max_Chain_Hikes Max_Number_Hikes Min_Chain_Hikes Min_Number_Hikes Number_Chain_Hikes Reference =Model_Cover!$A$9:$A$50 =Model_Cover!$A$8:$G$50 =Model_Cover!$BD$9:$BD$50 =Model_Cover!$H$9:$BC$50 =Model_Cover!$C$73 =Model_Cover!$C$72 =Model_Cover!$C$69 =Model_Cover!$C$71 =Model_Cover!$C$68 =Model_Cover!$C$70 =Model_Cover!$C$62 Worksheet Model_Cover Model_Cover Model_Cover Model_Cover Model_Cover Model_Sequence Model_Sequence Model_Sequence Model_Sequence Model_Sequence Model_Sequence Model_Sequence Model_Sequence Drives Hike_Hike_Dist Index_Randomizer VBA_Support_Shee t Range Name Number_Hikes_Chosen PeakCoveredActual PeakCoveredRequired Total_Miles TotalTime Best_Objective Current_Run_Number IndexSequence IndexSequenceAnchor InterHikeDistance NumStartingSolutions SelectedTrips TotalTrips Park_Nodes Hike_Hike_Dist RandIndex Best_Index_Sequence Reference =Model_Cover!$C$61 =Model_Cover!$H$52:$BC$52 =Model_Cover!$H$53:$BC$53 =Model_Cover!$D$56 =Model_Cover!$C$56 =Model_Sequence!$M$33 =Model_Sequence!$M$32 =Model_Sequence!$F$10:$F$51 =Model_Sequence!$F$10 =Model_Sequence!$M$12 =Model_Sequence!$M$31 =Model_Sequence!$B$7 =Model_Sequence!$B$6 =Drives!$E$4:$AC$28 =Hike_Hike_Dist!$B$8:$AR$50 =Index_Randomizer!$C$6:$C$47 =VBA_Support_Sheet!$A$2:$A$4 3.2 Model_Cover Sheet: Select Hikes To Be Performed The detailed logic of the Model_Cover sheet is presented in this subsection Recall this solves the Phase I problem, to select the hikes to minimize the hiking objective, either time or distance Figure shows an overview of the Model_Cover sheet (note: columns U-AZ are hidden for readability) This is intended to give the overall structure; the discussion covers each key area in detail Table lists key formulas on the Model_Cover sheet 10 procedures/functions, which are well-documented online (Microsoft, 2020) Depending on the background and interest level of students, the instructor can show how to use VBA to automate Solver, or can add that expectation to the case assignment If students not have prior experience with VBA, it is suggested the instructor first demonstrate VBA/Solver with a different example, say a linear programming problem that has already been covered previously in the course The VBA code used on the Model_Sequence sheet to randomize the hike sequence, and to run Solver multiple times for different initial solutions, is somewhat more complex If students have some background in computer programming, there is nothing conceptually difficult about the code, and it can offer a good opportunity to discuss the pros and cons of using a worksheet of the model to store intermediate calculations as the code runs (e.g., the Index_Randomizer sheet is used to compute a randomly generated starting sequence of hikes) 4.2 Suggested Case Questions This section provides questions the instructor can use in a way deemed appropriate For example, a question could be used as a discussion/coverage question while introducing the case prior to students working on it, for discussion purposes in class after students work on the case, and/or as a specific part of the assignment to help guide students in the problem-solving process Each part of the case is considered, and within each, there are questions for the hike selection model and for the hike sequencing model Case A, Hike Selection Model • How can the hike-peak data (i.e., specification of which peaks are completed by each hike) be organized in the spreadsheet to a) make it easy to verify; b) easy to modify if needed; and c) amenable to efficient calculation formulas? Note: The available spreadsheet template essentially addresses this question The instructor could use the question as a pre-case discussion question before providing the template • Why are binary (0/1) matrices useful in spreadsheets for organizing yes/no data, with respect to writing formulas? Specifically, why are 0/1 numerical values a better choice than using words such as “no” and “yes?” • What is the best way to represent whether a hike is selected or not? How can this set of decision variables be used with the hike-peak data to compute whether a peak is climbed (“covered”) by a particular choice of decision variable values? • How can you easily calculate the total hiking time (and distance) of a particular choice of decision variable values? • Can you also easily calculate the total number of chain (one-way) hikes included in a particular choice of decision variables? 26 Case A, Hike Sequencing Model • Given a specific choice of hikes from the hike selection model, what does a solution for the hike sequencing model look like? For example, if there are 10 hikes selected, how many possible sequences exist of those hikes? • How you know if one hike sequence is better than another? That is, how you measure the quality of a sequence of hikes? • Data is provided for the driving distances between parking nodes, and the hike data includes the starting and ending nodes for each hike How can this information be used to generate a matrix of driving distances between hikes (interhike distance) and within hikes (intra-hike distance)? Note the intra-hike distances for cyclical hikes will be zero and will be greater than zero for chain hikes to account for the car shuttling needed Note: Transforming the node-node distance matrix into a hike-hike distance matrix is a key part of being able to automatically compute the total driving required for a particular hike sequence • Manually experiment with at least three different sequences of hikes, and calculate the total driving required for those sequences Find the best sequence you can What is important to consider when trying to find a good sequence of hikes? • (Advanced) How could formulas be used to automatically extract the hike ID values for selected hikes into the hike sequencing model? Case B, Hike Selection Model • For the hike selection model, what are the decision variables, objective function, and constraints? • What is the optimal solution and objective value? Verify that all constraints are satisfied • Do you think there are other solutions that have the same objective value (i.e., are there alternate optimal solutions)? (Instructor note: for the current list of hikes, there are alternate optimal solutions.) • If the user decides that a particular mountain does not need to be climbed (or alternately, to be visited more than once), what changes are needed in order to find the new optimal solution? • If a new restriction were added to put a limit on the number of chain (one-way) hikes, what changes to the model are needed to find the new optimal solution? • If the user wanted to minimize hiking distance instead of hiking time, what changes to the model are needed to find the new optimal solution? Case B, Hike Sequencing Model • Based on the solution of the hike selection model, which hikes need to be sequenced to minimize the driving distance? 27 • • • • • • • How could we use Solver’s Evolutionary Algorithm and the “All Different” constraint type to sequence the hikes? For a given pair of hikes put in sequence next to one another, how can the driving distance between the hikes (and within each hike if a chain hike) be determined? (This is the critical step to being able to create a model that seeks to minimize driving distance.) If the overall objective is to minimize the total driving distance (including both cars), is the intra-hike distance affected by the sequence in which we the hikes? Is the inter-hike distance affected? (This is an example where one part of the overall objective is a constant value, and so does not need to be an explicit part of the objective function that we tell Solver to minimize.) Do the normal linear programming type of constraints apply for this problem, at least the way you have set it up? Why or why not? Why is the Evolutionary Algorithm required? Note: This can be used to initiate a discussion of different classes of algorithms in as much detail as desired What are the decision variables, objective function, and constraints, as specified to Solver? What is the best solution you can find with the objective to minimize driving distance? Try a few different starting sequences (i.e., manually reorder the hikes before running Solver) Do you get the same final (“best”) solution after running Solver for all the different starting sequences? (This question can be used to illustrate that the starting solution can make a difference in the final solution found, because the Evolutionary Algorithm is really a heuristic algorithm, without a guarantee of finding the global minimum.) 5.0 Summary The problem and solution approach presented in this paper can be used in multiple ways in an educational environment It provides a stretch from a traditional textbook-based problem, especially with the two-phased solution approach At the same time, it ties in with classic optimization models in Operations Research such as the Set Covering Problem and the Traveling Salesman Problem Opportunities to use the example in multiple ways were discussed The Excel workbook for the problem is available upon request from the author, as is a data/template file suitable for distribution with the case if the instructor desires 6.0 References Applegate, D.L.; Bixby, R.E.; Chvatal, V.; Cook, W.J (2007) The Traveling Salesman Problem: A Computational Study Princeton University Press 28 Braekers, K., K Ramaekers, and I.V Nieuwenhuyse 2016 The Vehicle Routing Problem: State of the Art Classification and Review Computers and Industrial Engineering, 99, 300-313 Current, J.R and D.A Schilling 1989 The Covering Salesman Problem Transportation Science, 23, 208-213 Golden, B.L.; Raghavan, S.; Wasil, E.A., eds (2008) The Vehicle Routing Problem: Latest Advances and New Challenges Springer Grinde, R (2017) A Bi-Modal Routing Problem with Cyclical and One-Way Trips: Formulation and Heuristic Solution Information Technology and Management Science, 20:79-84 Gutin, G., ed (2007) The Traveling Salesman Problem and Its Variations Springer Jozefowiez, N., F Semet, and E.G Talbi 2008 Multi-Objective Vehicle Routing Problems European Journal of Operational Research, 189:2, 293-309 Levy, L and L Bodin 1988 Scheduling the Postal Carriers for the United States Postal Service: An Application of Arc Partitioning and Routing In Vehicle Routing: Methods and Studies, Golden, B.L and A.A Assad (eds.) North-Holland, Amsterdam 359-394 Microsoft (2020) Using the Solver VBA Functions Retrieved from https://docs.microsoft.com/en-us/office/vba/excel/concepts/functions/using-the-solvervba-functions Smith, S.D.; Dickerman, M eds (2012) AMC White Mountain Guide With Maps, The Appalachian Mountain Club, 29th edition 29 Appendix A VBA Code for Model_Cover Sheet Option Explicit Sub BuildCoverModel() 'First resets the Solver settings, then rebuilds the solver model ' 'Reset Solver settings SolverReset 'Set up Solver model, using named ranges on Model_Cover sheet SolverOk SetCell:=Range("TotalTime"), MaxMinVal:=2, ValueOf:=0, _ ByChange:=Range("HikeChosen"), Engine:=2, EngineDesc:="Simplex LP" 'Add the constraints SolverAdd CellRef:=Range("HikeChosen"), Relation:=5, FormulaText:="Binary" SolverAdd CellRef:=Range("PeakCoveredActual"), Relation:=3, FormulaText:="PeakCoveredRequired" SolverAdd CellRef:=Range("TotalTime"), Relation:=1, FormulaText:="Max_Allowed_Hiking_Time" SolverAdd CellRef:=Range("Number_Hikes_Chosen"), Relation:=3, FormulaText:="Min_Number_Hikes" SolverAdd CellRef:=Range("Number_Hikes_Chosen"), Relation:=1, FormulaText:="Max_Number_Hikes" SolverAdd CellRef:=Range("Number_Chain_Hikes"), Relation:=3, FormulaText:="Min_Chain_Hikes" SolverAdd CellRef:=Range("Number_Chain_Hikes"), Relation:=1, FormulaText:="Max_Chain_Hikes" End Sub Sub BuildCoverModel_Distance() 'First resets the Solver settings, then rebuilds the solver model ' 'Reset Solver settings SolverReset 'Set up Solver model, using named ranges on Model_Cover sheet SolverOk SetCell:=Range("Total_Miles"), MaxMinVal:=2, ValueOf:=0, _ ByChange:=Range("HikeChosen"), Engine:=2, EngineDesc:="Simplex LP" 'Add the constraints SolverAdd CellRef:=Range("HikeChosen"), Relation:=5, FormulaText:="Binary" SolverAdd CellRef:=Range("PeakCoveredActual"), Relation:=3, FormulaText:="PeakCoveredRequired" SolverAdd CellRef:=Range("TotalTime"), Relation:=1, FormulaText:="Max_Allowed_Hiking_Time" SolverAdd CellRef:=Range("Number_Hikes_Chosen"), Relation:=3, FormulaText:="Min_Number_Hikes" SolverAdd CellRef:=Range("Number_Hikes_Chosen"), Relation:=1, FormulaText:="Max_Number_Hikes" SolverAdd CellRef:=Range("Number_Chain_Hikes"), Relation:=3, FormulaText:="Min_Chain_Hikes" SolverAdd CellRef:=Range("Number_Chain_Hikes"), Relation:=1, FormulaText:="Max_Chain_Hikes" End Sub Sub SolveCoverModel() ' Run Solver Don't display dialog box, but error checking and report to user if there is a problem Dim SolverResult As Integer 'Run Solver The UserFinish:=True suppresses the final dialog box SolverResult = SolverSolve(UserFinish:=True) 'Check different result codes; see https://www.solver.com/excel-solver-solversolve-function for explanation of codes If (SolverResult = 4) Then MsgBox ("Solution Error Problem is Unbounded") ElseIf (SolverResult = 5) Then MsgBox ("Solution Error Problem is Infeasible") ElseIf (SolverResult >= 6) Then MsgBox ("Problem in model or solution process.") Else MsgBox ("Solver successful Click to continue.") End If End Sub 30 Appendix B VBA Code for Model_Sequence Sheet Option Explicit Sub ResetIndexSequence() 'Orders the IndexSequence from N, where N is the total number of hikes defined in the workbook Dim i As Integer For i = To Range("TotalTrips").Value Range("IndexSequence").Cells(i) = i Next i End Sub Sub RandomizeIndexSequence() 'Randomly orders the IndexSequence of the n hikes currently selected Note that n

Ngày đăng: 25/10/2022, 04:31

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w