Mechanics and Brands Optimization with VB.NET

For this assignment you are going to develop an application that assigns mechanics to stations of different car brands to maximize total expertise. For this problem, you will need to solve an assignment problem using linear mathematical programming. The set of mechanics and brands are:

Mechanics = {Anderson, Brown, Clark, Davis, Evans, Foster, Garcia, Harris, Iceman, Jackson}

Brands = {Audi, BMW, Chevrolet, Dodge, Ford, GMC, Honda, Infiniti, Jeep, Mazda}.

The decision variables for your assignment model is Xij, which indicate whether mechanic i is assigned to brand j. Eij is the expertise level of mechanic i in brand j. The model can be written as:

Maximize Sum(for all mechanic i and brand j) Eij * Xij

Constraint 1: For each mechanic i: Sum(for all brand j) Xij = 1

Constraint 2: For each brand j: Sum(for all mechanic i) Xij = 1

Bounding Constraints: For all mechanic i and brand j: 0 <= Xij <= 1

This application uses a database with the expertise level of each mechanic for each brand. The main form has two list boxes showing mechanics and brands, one button for solving the assignment problem, and two labels for showing results. Once the problem is solved, the user can click on a particular mechanic in the mechanic list box, and the assigned brand would be highlighted in the list box for brand. Similarly, the user can click on a brand in the brand list box, and the mechanic assigned to that brand would be highlighted in the mechanic list box. The two labels show the particular assignment and expertise level, and the total expertise level of all assignments. A screenshot of the application is provided at the bottom. Download the file Homework4.zip in your BIT 3444 folder and extract it. Then follow the instructions below to complete the assignment:

  1. Create the Assignment Class with the following properties: Mechanic as String, Brand as String, Expertise as Integer, Assigned as Boolean. Create and override the ToString function, where it returns the the String in <Mechanic> -> <Brand> : <Expertise> format. (See screenshot below).
  2. Download the file Optimization.vbPreview the document to your homework folder. Then, add this file to your project by using the "Add Existing Item" command under the "Project" menu in Visual Studio, selecting the "Optimization.vb" file, and clicking on the "Add" button.
  3. Create the Database Class, which should read data from the database into a table in a dataset. Then a function should create a list of Assignment objects, then in a for loop read the data from the table one row at a time, create an instance of an Assignment object, set the properties of the Assignment object from this row, and add the object to the list. After the loop, the function should return this list. (Note that the database Mechanics.accdb is already added to the project).
  4. In frmAssignment.vb code page do the following with instructions in this and the remaining steps. At the module level, create a new instance of the Database Class, a pointer to list of Assignment objects (not a new instance), a new list of String for mechanic names, a new list of String for brand names, and a new instance of Optimization class.
  5. In the Load event handler of the form, first set the list of Assignment objects by calling the function of the Database Class that creates the list. Then, using a For Each loop that goes through the list of Assignment objects, add the mechanic information from the Assignment object to the mechanic list and the mechanic list box if the mechanic list does not already contain that mechanic. Similarly, populate the brand list and brand list box by checking if the brand of the Assignment object is already in the brand list or not.
  6. Create a sub to solve the problem by doing the following:
    1. Call InitSolve sub of the Optimization object.
    2. Go through the list of Assignment objects to add the decision variables, where the decision variable name is the mechanic name and brand name concatenated together, and the lower and upper bounds are 0 and 1, respectively (see Bounding Constraints above).
    3. Using a For Each loop, go through the mechanic list (created in step 5), add a constraint for each mechanic, where the name of the constraint is the same as the mechanic name, and the lower and upper bounds are both 1 (see Constraint 1 above). Use a LINQ query to find all Assignment objects in the list of Assignments with the current mechanic’s name (the variable of the For Each loop). Create another For Each loop (inside the outer For Each loop) to go through the output of the inner LINQ query in order to set the coefficients of the constraint for the current mechanic (of the outer loop). Note again that you will refer to the decision variables while setting coefficients by concatenating the mechanic name and the brand name.
    4. Create a For Each loop, this time to go through the list of brand names (created in Step 5) to add constraints for each brand name (see Constraint 2 above). Follow a similar logic as in the above step by naming constraint with the current brand name, setting lower and upper boundaries to 1, creating a LINQ query to find all assignments with the current brand name, and using an inner For Each loop for setting the coefficients.
    5. Call the sub for adding the objective to the Optimization object, and solve model for this objective while maximizing the objective. If the model is optimal, then get the values of the variables using a For Each loop over the list of Assignments, where you can refer to the decision variables by concatenating mechanic and brand information. If the decision variable is positive (say, greater than 0.1), then set the assigned property of the Assignment object to True.
  7. In the event handler of btnSolve, call the sub you created in Step 6, set the Text property of lblTotalExpertise to the value of the objective function value (using GetFunVal function of the optimization object), and select the first entry in the list box of mechanics.
  8. In the SelectedIndexChange event handler of lstMechanic (double click on the list box in the form to create the event handler) do the following: Create a LINQ query to return the Assignment object from the list of Assignment objects, where the mechanic is the same as the Text property of the list box for mechanics, and the Assigned property is True. Note that there is only one such Assignment object. Since the LINQ query still returns a list, you can refer to this object as list(0). Get the index of the brand assigned to the selected mechanic (use code similar to Dim bindex As Integer = lstBrand.Items.IndexOf(list(0).Brand)) and select the item in the brand list box with this index. Display the information of this Assignment object (using ToString function) in lblAssignment.
  9. Follow a similar logic as in Step 8 for creating the code for the SelectedIndexChange event handler of lstBrand so that when the user clicks on a brand in the brand list box, the mechanic assigned to that brand is selected in the mechanic list box.
  10. If you don’t have Microsoft Solver Foundation on your computer yet, go to https://msdn.microsoft.com/en-us/devlabs/hh145003 (Links to an external site.), click on the “Download Solver Foundation 64-bit” button on the right to download the installer. Double-click on the downloaded file and follow the instructions, selecting the default options. Then, in Visual Studio, go to Project > Homework4 properties; click on “References” on the left, click on the “Add button” at the bottom of the References list. Click on the “Browse” button and go the following location:
    C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.Solver.Foundation\v4.0_3.0.2.10889__31bf3856ad364e35
    Click on the file Microsoft.Solver.Foundation.dll, and click on Add.

When you are done, please save all of your work and close the project, zip the project folder, and name the zip file using the format <LastName>_HW4.zip if you are submitting by yourself, replacing <LastName> with your own lastname (e.g. Seref_HW4.zip). If you are submitting as a group of two students, then use the format <LastName1>_<LastName2>_HW4.zip (e.g. Seref_Skywalker_HW4.zip).If you are submitting as a group of two students, only one student should submit the assignment.

Need a custom answer at your budget?

This assignment has been answered 2 times in private sessions.

Or buy a ready solution below.

Buy ready solution

Solution previews

© 2024 Codify Tutor. All rights reserved