VCML / ResearchProgress

0 stars 0 forks source link

[20180819] Bi-objective optimization for a single machine / Research progress - coding #2

Open freebluebird1218 opened 6 years ago

freebluebird1218 commented 6 years ago

Research Progress - coding

This research is using genetic algorithm to solve the problem, especially NSGA -ii. You can see the sketchy flowchart of the NSGA - ii in the quoted site below.

https://www.researchgate.net/figure/NSGA-II-algorithm-flowchart_fig2_283129353

Currently all of the code was done, except for mutation. However, the mutation code is almost finished.

The only thing to do is coding the mutation code for last job and checking practicality of it.

`

mutation code for last job

        # If last job cannot move
        if jobs.index(job_number) - 1 == mutated_jobs.index(job_number - 1) and jobs.index(job_number) == len(jobs)-2:

            mutated_jobs+=jobs[mutated_jobs.index(job_number-1)+1:len(jobs)]

        # If last job can only move forward
        if jobs.index(job_number) - 1 != mutated_jobs.index(job_number - 1) and jobs.index(job_number) == len(jobs) - 2:

            start_point = mutated_jobs.index(job_number-1)+1
            end_point = len(jobs)-1

            job_moving(jobs, job_number, start_point, end_point, JOB_COUNT_mutation_set, mutated_jobs)

            job_count_energy = list(map(lambda energy1: function1(energy1), JOB_COUNT_mutation_set))

            mutated_jobs += cost_compare(job_count_energy, JOB_COUNT_mutation_set, job_number, jobs)

        # If last job can only move backward
        if jobs.index(job_number) - 1 == mutated_jobs.index(job_number - 1) and jobs.index(job_number) != len(jobs) - 2:
            start_point = jobs.index(job_number)
            end_point = len(jobs) - 2

        # If last job can move to both side 
        if jobs.index(job_number) - 1 != mutated_jobs.index(job_number - 1) and jobs.index(job_number) != len(jobs) - 2:
            start_point = mutated_jobs.index(job_number - 1)+1
            end_point = len(jobs) - 2`

Works for next week

davinnovation commented 6 years ago

nice work! try to dividing code with functions!

for job in jobs:
  if job == first job:
    first_job_input()
  elif job == middle job:
    middle_job_input()
  elif job == last job:
    last_job_input()