aristotaly
aristotaly

Reputation: 399

Implementing a "table" in C#

I'm working on Etp (employee timetabling problem) problem using RSSHC algorithem from the hill climbing family .

From this matter I need to create a "table " like this:

    s1   s2   s3   s4   s5 S6   
------
e1  5                   8       
e2       3    4     
e3
e4
e5

The rows represent the employees (employee number); the columns represent the the shift (shift ID) and the value represent the task number (task ID). All those taken from the database. On this table I will need to switch tasks between employees and run constraint checks every time there is a switch. Is there any datatype that will support this layout (I'm new at C#)? Or maybe it would be better to do it via stored proc on my database?

The constraints will be calculated via 'cost function' and give a penalty point for every constraint violation. For example:

e2 doing task 2 on S2 and task 4 on S3 maybe e2 can't do task 2 (abilities) or do not have enough workload (I need to look on e2 vector and count that ) or maybe according to my rules an employee can't do 2 shifts in a row. (I will need to look for values on s1 and s3) Perhaps the employee can't work today (preference) (I will need to check that ). That's the main constraints.

Upvotes: 0

Views: 160

Answers (2)

Oliver
Oliver

Reputation: 45109

If your shiftIDs are known you could create an class like:

public class Employee
{
    public int S1 { get; set; }
    public int S2 { get; set; }
    public int S3 { get; set; }
    public int S4 { get; set; }
}

This class would be put into an List<Employee>. This list would then be put into a BindingSource.DataSource and last but not least you put this into a DataTable.DataSource.

With this you can simply make any changes within the DataGrid, which will directly reflected into your List.

Upvotes: 1

devnull
devnull

Reputation: 2860

You can use a DataTable or a multidimensional array, depending on your performance requirements.

Upvotes: 1

Related Questions