Skip to content

Commit

Permalink
Merge pull request #11 from ppaauuoo/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ppaauuoo authored Aug 10, 2024
2 parents 1db5371 + 9850165 commit a2e499a
Show file tree
Hide file tree
Showing 11 changed files with 358 additions and 694 deletions.
Binary file modified db.sqlite3
Binary file not shown.
8 changes: 0 additions & 8 deletions media/data/test_common_logic.csv

This file was deleted.

118 changes: 0 additions & 118 deletions order_optimization/getter.py

This file was deleted.

191 changes: 0 additions & 191 deletions order_optimization/handler.py

This file was deleted.

21 changes: 8 additions & 13 deletions order_optimization/modules/ga.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
import numpy
import pandas as pd
from .ordplan import ORD
from typing import Dict

class GA:
def __init__(self, orders: ORD, size: float, num_generations: int, out_range: int,showOutput:bool = False, save_solutions:bool = False, showZero: bool = False, selector: Dict = None)->None:
def __init__(self, orders: ORD, size: float, num_generations: int, out_range: int,showOutput:bool = False, save_solutions:bool = False, showZero: bool = False)->None:
self.orders = orders
self.PAPER_SIZE = size
self.showOutput = showOutput
self.save_solutions = save_solutions
self.showZero = showZero
self.selector = selector

self.num_generations = num_generations
# num_parents_mating = len(orders)
Expand Down Expand Up @@ -60,7 +59,8 @@ def __init__(self, orders: ORD, size: float, num_generations: int, out_range: in
)

self.current_generation = 0



def paper_type_logic(self, solution):
init_type = None
orders = self.orders
Expand Down Expand Up @@ -108,15 +108,10 @@ def fitness_function(self, ga_instance, solution, solution_idx):
self.penalty = 0
self.penalty_value = 1000

if self.selector:
solution[0]=self.selector['out']

self.paper_type_logic(solution)

self.paper_out_logic(solution)



output = numpy.sum(solution * self.orders["กว้างผลิต"]) # ผลรวมของตัดกว้างทั้งหมด
self.paper_size_logic(output)

Expand All @@ -128,9 +123,9 @@ def fitness_function(self, ga_instance, solution, solution_idx):
def on_gen(self, ga_instance):

self.current_generation += 1
if self.set_progress:
if self.update_progress:
progress = (self.current_generation / self.num_generations) * 100
self.set_progress(progress)
self.update_progress(progress)

orders = self.orders

Expand Down Expand Up @@ -178,6 +173,6 @@ def show(self, ga_instance, output):
print("Trim :", abs(self.fitness_values))
print("\n")

def get(self, set_progress):
self.set_progress= set_progress
def get(self, update_progress):
self.update_progress= update_progress
return self.model
Loading

0 comments on commit a2e499a

Please sign in to comment.