Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using System; using System.Collections.Generic; using System.Linq; namespace AssemblyLineAlgorithm { class Program { / / Define operation durations static readonly Dictionary operationDurations = new Dictionary {

using System;
using System.Collections.Generic;
using System.Linq;
namespace AssemblyLineAlgorithm
{
class Program
{
// Define operation durations
static readonly Dictionary operationDurations = new Dictionary
{
{1,4},{2,3},{3,2},{4,5},{5,3},
{6,4},{7,3},{8,4},{9,2},{10,2},{11,5}
};
// Define premise relationships using a matrix
static readonly int[,] premisesMatrix = new int[,]
{
// Op: 1234567891011
/*1*/{0,0,1,1,0,0,1,0,1,0,0},// No dependencies for op 1
/*2*/{0,0,0,0,1,1,1,1,1,1,1},// No dependencies for op 2
/*3*/{0,0,0,0,0,0,1,0,1,0,0},// Dependency: 1 for op 3
/*4*/{0,0,0,0,0,0,1,0,1,0,0},// Dependency: 1 for op 4
/*5*/{0,0,0,0,0,0,1,0,1,0,0},// Dependency: 2 for op 5
/*6*/{0,0,0,0,0,0,0,1,0,1,1},// Dependency: 2 for op 6
/*7*/{0,0,0,0,0,0,0,0,1,0,0},// Dependencies: 1,2,3,4,5 for op 7
/*8*/{0,0,0,0,0,0,0,0,0,1,0},// Dependencies: 2,6 for op 8
/*9*/{0,0,0,0,0,0,0,0,0,0,0},// Dependencies: 1,2,3,4,5,7 for op 9
/*10*/{0,0,0,0,0,0,0,0,0,0,0},// Dependencies: 2,6,8 for op 10
/*11*/{0,0,0,0,0,0,0,0,0,0,0},// Dependencies: 2,6 for op 11
};
static void Main()
{
int cycleTime =10;
int maxStations =2;
int maxWorkers =3;
List unassignedOperations = new List(operationDurations.Keys);
List assignedOperations = new List();
int[] workerTimes = new int[maxWorkers]; // Initialize worker times for workers at a station
int currentStation =1;
while (currentStation <= maxStations && unassignedOperations.Count >0)
{
Console.WriteLine($"Station {currentStation} starts:");
while (unassignedOperations.Count >0)
{
// Identify assignable operations
var AL = unassignedOperations
.Where(op => premisesMatrix[op -1,0]==0|| premisesMatrix[op -1,0]==1 && assignedOperations.Contains(premisesMatrix[op -1,0]))
.ToList();
if (AL.Count ==0) break;
// Select the operation with the smallest positional weight
var selectedOp = AL
.OrderBy(op => premisesMatrix[op -1,1])
.ThenBy(op => op)
.First();
// Find the earliest time for assignment
int earliestTime = workerTimes.Min();
if (earliestTime + operationDurations[selectedOp]> cycleTime)
{
break; // Operation doesn't fit in cycle time
}
// Assign the operation to a worker at the earliest time
int workerIndex = Array.IndexOf(workerTimes, earliestTime);
workerTimes[workerIndex]+= operationDurations[selectedOp];
Console.WriteLine($"Assigned operation {selectedOp} to worker {workerIndex +1} at time {earliestTime}, will finish at {workerTimes[workerIndex]}");
// Update lists
assignedOperations.Add(selectedOp);
unassignedOperations.Remove(selectedOp);
}
Console.WriteLine($"Station {currentStation} assignments completed.");
Console.WriteLine();
// Move to the next station
currentStation++;
if (currentStation <= maxStations)
{
workerTimes = new int[maxWorkers]; // Reset worker times for the new station
}
}
// Print final status
if (unassignedOperations.Count >0)
{
Console.WriteLine("All operations could not be assigned within the given constraints.");
foreach (var op in unassignedOperations)
{
Console.WriteLine($"Operation {op} was not assigned.");
}
}
else
{
Console.WriteLine("All operations assigned.");
}
}
}
}
My Output like that:
Station 1 starts:
Assigned operation 1 to worker 1 at time 0, will finish at 4
Assigned operation 2 to worker 2 at time 0, will finish at 3
Assigned operation 3 to worker 3 at time 0, will finish at 2
Assigned operation 4 to worker 3 at time 2, will finish at 7
Assigned operation 5 to worker 2 at time 3, will finish at 6
Assigned operation 6 to worker 1 at time 4, will finish at 8
Assigned operation 7 to worker 2 at time 6, will finish at 9
Station 1 assignments completed.
Station 2 starts:
Assigned operation

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Describe the social tasks and challenges of adolescence.

Answered: 1 week ago

Question

LO 1-5 What the basic criteria for effective messages are.

Answered: 1 week ago

Question

What will you do or say to Anthony about this issue?

Answered: 1 week ago