最初は、何のこの本?と思って団代数からPerplexityに聞いた。
ちょっとずれた答えを返してくる(笑)
ん? ”トロピカル幾何学の概念は、工程計画問題の解決に応用されています” だと?
役に立つのは知っていたが、そうか。一般的にも知られているのか。
ではこうだ。
import numpy as np
def tropical_add(a, b):
return max(a, b)
def tropical_multiply(a, b):
return a + b
tasks = [3, 5, 2, 6]
completion_time = tasks[0]
for task in tasks[1:]:
completion_time = tropical_multiply(completion_time, task)
print("全体の完了時間:", completion_time)
import torch
import torch.nn.functional as F
from torch_geometric.nn import MessagePassing
class TropicalGNN(MessagePassing):
def __init__(self, in_channels, out_channels):
super().__init__(aggr='max')
self.linear = torch.nn.Linear(in_channels, out_channels)
def forward(self, x, edge_index):
return self.propagate(edge_index, x=x)
def message(self, x_i, x_j):
return torch.max(x_i, x_j)