Exemplo n.º 1
0
 def configure_param_lmme_dialog(self):
     w = Toplevel()
     w.protocol('WM_DELETE_WINDOW', self.hide_param_dialog)
     self.param_dlg = w
     w.withdraw()  # cache la fenetre
     w.rowconfigure(0, weight=1)
     w.columnconfigure(0, weight=1)
     prm = ParamModeLMME(
         w, "Paramètres du calcul modal pour la méthode LMME",
         relief='sunken', borderwidth=2)
     prm.grid(row=0, column=0)
     self.param_mode_iter_simult_lmme = prm
     Button(w, text="Appliquer", command=self.anything_changed).grid(
         row=1, column=0)
     Button(w, text="OK", command=self.hide_param_dialog).grid(
         row=2, column=0)
Exemplo n.º 2
0
    def construct(self):
        """
        Construct the window and the frame used to display the XML
        :return:
        """
        top = Toplevel()
        top.withdraw()
        top.protocol("WM_DELETE_WINDOW", self.view_xml_pane)
        top.columnconfigure(0, weight=1)
        top.rowconfigure(0, weight=1)
        top.title("XML Preview")
        self._pane = top

        xml_area = Text(top, borderwidth=2, relief="sunken")
        xml_area.config(font=("consolas", 12), undo=True, wrap='word', state=DISABLED)
        xml_area.grid(row=0, column=0, sticky="nsew", padx=2, pady=2)

        scrollbar = Scrollbar(top, command=xml_area.yview)
        scrollbar.grid(row=0, column=1, sticky='nsew')
        xml_area['yscrollcommand'] = scrollbar.set

        self._text_area = xml_area
Exemplo n.º 3
0
    def visu_mac(self, mac, resu1, resu2):

        titre = "matrice de MAC pour " + resu1.nom + " et " + resu2.nom

        f = Toplevel()
        size = (20, 300)
        f.columnconfigure(0, weight=1)
        f.rowconfigure(0, weight=1)
        mac_win = MacWindowFrame(f, titre, resu1.nom, resu2.nom, size)
        mac_win.grid(row=0, column=0, sticky='nsew')
        afreq1 = resu1.get_modes_data()['FREQ']
        noeud_cmp1 = resu1.get_modes_data()['NOEUD_CMP']
        afreq2 = resu2.get_modes_data()['FREQ']
        noeud_cmp2 = resu2.get_modes_data()['NOEUD_CMP']
        # si mode statique, on donne le champ NOEUD_CMP a la place de la
        # frequence
        for ind_ordr in range(len(afreq1)):
            if afreq1[ind_ordr] == None:
                afreq1[ind_ordr] = noeud_cmp1[ind_ordr]
        for ind_ordr in range(len(afreq2)):
            if afreq2[ind_ordr] == None:
                afreq2[ind_ordr] = noeud_cmp2[ind_ordr]
        mac_win.set_modes(afreq1, afreq2, mac)
class InstructionsFrame(Frame):
    def __init__(self, parent, width=500, height=200, background="white"):
        Frame.__init__(self, parent)
        self.initialize()

    def initialize(self):
        self.instructions_text = \
    """
    Seating Chart Creator makes an optimal seating chart for a given set of people, tables, and days. It generates a preliminary chart, then searches for a better one by switching people around.\n"""
        self.instructions_label = Label(self, text=self.instructions_text,
                                        font=("Optima", 14), anchor=W,
                                        justify=LEFT)
        self.instructions_label.grid(row=0, column=0, sticky=(W))

        miniframe = Frame(self)
        miniframe.grid(row=1, column=0, padx=0, pady=(0, 20))
        self.rules_button = Button(miniframe,
                                   text="View list of optimization rules",
                                   command=self.show_rules)
        self.rules_button.grid(row=1, column=0, sticky=(W), padx=10)

        self.people_example = Button(miniframe,
                                     text="View example people input file",
                                     command=self.show_people_example)
        self.people_example.grid(row=1, column=1, sticky=(W), padx=10)

        self.tables_example = Button(miniframe,
                                     text="View example tables input file",
                                     command=self.show_tables_example)
        self.tables_example.grid(row=1, column=2, sticky=(W), padx=10)

    def show_rules(self):
        self.windowr = Toplevel(self)
        self.windowr.wm_title("Optimization Rules")
        self.windowr.rowconfigure(0, weight=1)
        self.windowr.rowconfigure(1, weight=1)
        self.windowr.columnconfigure(0, weight=1)

        innerwindowr = Canvas(self.windowr)
        innerwindowr.pack()
        myscrollbar=Scrollbar(self.windowr, orient="vertical",
                              command=innerwindowr.yview)
        innerwindowr.configure(yscrollcommand=myscrollbar.set)
        myscrollbar.pack(side="right",fill="y")

        #self.rtitle_label2 = Label(z,
        #                           text="Seating Chart Creator's Optimization Rules",
        #                           font=("Optima Italic", 24))
        #self.rtitle_label2.pack()

        rtext1 = \
"""
*** Seating Chart Creator's Optimization Rules ***

Depending on the input data, it may or may not be possible to create a perfect seating
chart. Even if there is a perfect solution, there is no fast or easy way to find it.

Seating Chart Creator searches for that perfect solution using an optimization algorithm.
It specifies the criteria to evaluate the solution with, then searches for the
solution that best meets that criteria.

The search process involves random factors, so if you run it multiple times, you will
get different answers.


*** The Criteria ***

SCC looks for a solution with the lowest 'cost'. The cost of a solution is determined by:

* The number of people sitting in the same spot multiple times.
* The number of pairs sitting together multiple times.
* The number of trios sitting together multiple times.
* The distance of each table from its optimal category balance.

The table sizes always correspond with those in the input file.


*** The Process ***

Step 1: Building the First Guess

SCC loops through the days of the event. On each day, it considers each person individually
and places him or her in the best spot available. People are shuffled each round so that
no one consistently gets the 'last pick' of the tables.

When considering where to seat a person, the following tables are excluded:
- Tables that are already full
- Tables that already have enough people of the same category as the person to be seated.

The person is then assigned to the table with the fewest people he/she has already sat with.


Step 2: Switching People Around

The strategy above is fairly good, but not perfect. SCC uses it as a starting point,
then generates new solutions by repeatedly switching individuals. The 'cost' is
calculated for each new solution. If a new solution is better than the current solution,
it is used as the starting point for the next round.

The technique SCC uses is called 'simulated annealing'. It is a frequently-used and
highly-regarded method for solving problems like this one. However, it is not guaranteed
to find a perfect solution.

The switching steps take a very long time (minutes - hours) because of the computational
complexity of counting the number of times everyone sits together.

"""
        #scrollbar = Scrollbar(innerwindowr)
        #scrollbar.pack(side=RIGHT, fill=Y)
        #self.foo = Label(innerwindowr, text=rtext1)
        self.rules_text_box = Text(innerwindowr, width=100)
        self.rules_text_box.insert(INSERT, rtext1)
        self.rules_text_box.config(highlightthickness=0)
        self.rules_text_box.pack(padx=20)
        #self.foo.config(yscrollcommand=scrollbar.set)
        #scrollbar.config(command=self.foo.yview)

    def show_people_example(self):
        self.window = Toplevel(self)
        self.window.wm_title = "People Example"
        self.window.rowconfigure(0, weight=1)
        self.window.rowconfigure(1, weight=1)
        self.window.columnconfigure(0, weight=1)

        innerwindowp = Frame(self.window)
        innerwindowp.grid(row=0, column=0)
        self.ptitle_label2 = Label(innerwindowp,
                                   text="Example People Input File",
                                   font=("Optima Italic", 24))
        self.ptitle_label2.grid(row=0, column=0)
        ptext1 = \
"""
The 'People' input file contains information about the people to be seated and where they might have been preassigned to sit.
It should be saved in CSV format."""
        pheader1 = "COLUMN NAMES"
        ptext2 = \
"""The file should contain the column headers 'First Name', 'Last Name', and 'Category', written exactly as printed here -
capitalization is important.

All other columns are assumed to be the names of the days you are making the chart for. They must match the days in your
'Tables' input file exactly (again, capitalization is important)."""
        pheader2 = "NOTES"
        ptext3 = \
"""Each person should be assigned a category. You can name the categories whatever you like.

If a person has been preassigned to the head table on a particular day, write 'Head' (with a capital 'H') in the corresponding
cell."""
        ptext1label = Label(innerwindowp, text=ptext1, justify=LEFT)
        ptext1label.grid(row=1, column=0, padx=20, sticky=(W))

        pheader1label = Label(innerwindowp, text=pheader1,
                              font=("Optima Italic", 14), justify=LEFT)
        pheader1label.grid(row=2, column=0, padx=20, pady=(20, 0), sticky=(W))

        ptext2label = Label(innerwindowp, text=ptext2, justify=LEFT)
        ptext2label.grid(row=3, column=0, padx=20, sticky=(W))

        pheader2label = Label(innerwindowp, text=pheader2,
                              font=("Optima Italic", 14), justify=LEFT)
        pheader2label.grid(row=4, column=0, padx=20, pady=(20,0), sticky=(W))

        ptext3label = Label(innerwindowp, text=ptext3, justify=LEFT)
        ptext3label.grid(row=5, column=0, padx=20, sticky=(W))

        self.picture2p = PhotoImage(file=find_data_file('static/people-example.gif'))
        self.picture_label2p = Label(self.window, image = self.picture2p)
        self.picture_label2p.grid(row=2, column=0)

    def show_tables_example(self):
        self.window2 = Toplevel(self)
        self.window2.wm_title = "Tables Example"
        self.window2.rowconfigure(0, weight=1)
        self.window2.rowconfigure(1, weight=1)
        self.window2.columnconfigure(0, weight=1)

        innerwindow = Frame(self.window2)
        innerwindow.grid(row=0, column=0)
        self.title_label2 = Label(innerwindow,
                                  text="Example Tables Input File",
                                  font=("Optima Italic", 24))
        self.title_label2.grid(row=0, column=0)
        text1 = \
"""
The 'Tables' input file contains information about the individual tables' names and capacities. It should be saved in CSV
format."""
        header1 = "COLUMN NAMES"
        text2 = \
"""The file should contain the column header 'Table Name', written exactly as printed here - capitalization is important.

All other columns are assumed to be the names of the days you are making the chart for. They must match the days in your
'People' input file exactly (again, capitalization is important)."""
        header2 = "NOTES"
        text3= \
"""You can choose arbitrary table names. If you include a table named 'Head', it will be populated exclusively with the people
preassigned to it in the 'People' input file.

The number in each cell represents the table's capacity on that day. Make sure the overall capacity is at least as great as
the number of people to be seated!"""
        text1label = Label(innerwindow, text=text1, justify=LEFT)
        text1label.grid(row=1, column=0, padx=20, sticky=(W))

        header1label = Label(innerwindow, text=header1,
                             font=("Optima Italic", 14), justify=LEFT)
        header1label.grid(row=2, column=0, padx=20, pady=(20, 0), sticky=(W))

        text2label = Label(innerwindow, text=text2, justify=LEFT)
        text2label.grid(row=3, column=0, padx=20, sticky=(W))

        header2label = Label(innerwindow, text=header2,
                             font=("Optima Italic", 14), justify=LEFT)
        header2label.grid(row=4, column=0, padx=20, pady=(20, 0), sticky=(W))

        text3label = Label(innerwindow, text=text3, justify=LEFT)
        text3label.grid(row=5, column=0, padx=20, sticky=(W))

        self.picture2 = PhotoImage(file=find_data_file('static/tables-example.gif'))
        self.picture_label2 = Label(self.window2, image=self.picture2)
        self.picture_label2.grid(row=2, column=0)