2024,江端さんの忘備録

今回の震災で、マスコミ各局のレポータの皆さんが、現地からの報告を行って頂いております(特にNHK)。

Reporters from various media outlets have been reporting from the disaster site (especially NHK).

大変お疲れ様でございます。

Thank you very much for your hard work.

辛い現場をご覧になって、心底疲れられているものと、推察申し上げます。

I assume that you are genuinely exhausted after seeing the painful scene.

そのような、お疲れのところ、このようなことを申し上げるのは、大変心苦しいのですが、それでも一言申し上げたいと思います。

It pains me greatly to say this at such a weary time, but I would like to say something nonetheless.

―― 生中継のレポートでスマホを見ながら、その文面を読み上げるだけのレポートなら、それ、スマホの「音声AI」に読み上げさせればいいんじゃない?

"If it's a live report and you're just looking at your phone and reading the text of the report, why not just have the "voice AI" on your phone read that out loud?"

-----

私は、災害現場のレポーターというのは、災害現場の代弁者と思っています。

I consider a disaster site reporter to be the disaster site's voice.

ならば、現場の状態を言語化して、御自分の目で見て、御自分で感じたことを、御自分の選んだ言葉と、御自分の肉声でで語って頂くことこそが、その任務だと思います。

Then, I believe that you must verbalize the conditions on the ground, to speak what you see and feel with your own eyes, in your own words of your choosing, and in your voice.

もちろん「レポーターは役者ではない」というのであれば、それはそれで納得できます。

Of course, if you say reporters are not actors, that makes sense.

それなら、『スマホの音声AI機能』を使って、報告して頂いて結構です。

Then, you can use the "voice AI function of your smartphone" to report back to us.

しゃべる時間も、予定通りピッタリと収まるでしょう。

The speaking time will also fit perfectly into the schedule.

-----

ただ、私たち視聴者は、そういうものを聞きたい訳ではないのです。

But we, the viewers, do not want to hear those things.

現場を直接見た人の、肚の底から絞り出される、生きている人間の感情が入りつつも、それでも冷静に客観的な報告を行いつづける ―― そういう姿を見て、私たちは被災者の皆さんの状況に寄り添えると思うのです。

The person who saw the disaster site firsthand, who squeezed out from the depths of their heart the emotions of a living person, and yet continued to report calmly and objectively - I believe we can be close to the tragedy of the disaster victims by seeing this.

私に、報道のプロのレポータとしての技と矜持を見せて下さい。

Please show me the skill and pride of being a professional press reporter.

リビングのテレビをつけたら、アナウンサーが、恐しい声で避難を叫んでいました ―― 息も切れんばかりの勢いで。

2024,江端さんの忘備録

NHK紅白歌合戦の視聴率が、史上最低の30%になったとのことで、批判されいるようです。

NHK's Kohaku Uta Gassen has been criticized for its viewership ratings, which are at an all-time low of 30%.

でも、私は、"30%"って、結構、凄い数値だと思っています。

But I think "30%" is a pretty impressive figure.

だって、全世代向けの歌をメインとする番組ですよ。

Because it is a program that focuses on songs for all generations.

全世代向け歌番組というコンテンツ縛りで、30%を叩き出すなんて、たいしたものだと思います。

I think it's quite a feat to hit 30% for an all-generational singing program.

ちなみに、過去のNHK紅白歌合戦の最高視聴率は、1963年(昭和38年)の視聴率81.4%だそうです。これは、恐るべき数値です。

Incidentally, the highest viewership rating for NHK's Kohaku Uta Gassen in the past was 81.4% in 1963 (Showa 38). This is a frightening figure.

-----

私は、NHK紅白歌合戦を楽しく試聴するには、ちゃんとした「訓練」が必要で、さらには「才能」も必要であると思っています。

I believe proper "training" and even more "talent" are required to enjoy listening to NHK Kohaku Uta Gassen.

普段から、ちゃんと歌番組を繰り返し試聴し、自分の中で熟成させるだけの時間が必要になります。

You will usually need to listen to the song program properly and repeatedly and only allow time for it to mature in your mind.

これは、自分の時間を、テレビなどの歌番組などのメディアに費すことができる、いわゆる『時間富裕層』にのみ許された特権です。

This privilege is reserved for the so-called "time rich" who can spend their time on TV and other media such as singing shows.

つまり、NHK紅白歌合戦は、時間富裕層という特権的階級であって、楽曲を楽しめる楽曲リテラシーを有する、エリート向けの番組なんですよ。

In other words, NHK Kohaku Uta Gassen is a program for the elite, the privileged class of time-rich people with music literacy, to enjoy the songs.

NHK紅白歌合戦と同じ時間帯に行っていた、N響「第9」演奏会とクラシック名演・名舞台と同じ位置付けになっているのです。

It is in the same position as the NHK Symphony Orchestra's "9th" concert, classic masterpieces, and famous performances, which were held at the same time as the NHK Kohaku Uta Gassen.

つまりクラッシック音楽を楽しむ為には、クラッシック音楽のリテラシーが必要となるように、NHK紅白歌合戦を楽しむ為には、NHK紅白歌合戦のリテラシーが必要となる ―― そういう時代になったのだと思います。

In other words, just as classical music literacy is necessary to enjoy classical music, NHK Kohaku Uta Gassen literacy is required to enjoy the NHK Kohaku Uta Gassen -- I think we are in such an era now.

-----

私、録画で、YOASOBIの「アイドル」だけ見ました(それしか、知っている楽曲がなかったので)。

On the recording, I only watched "Idol" by YOASOBI (since that was the only song I knew).

私がティーンエイジャだったころ、バックダンサーやっていたアイドルたちは、実にヘラヘラした踊りをしていました(だいたい歌が下手で聞いていられなかった)が、今のアイドルって、本当に凄いんですね。

When I was a teenager, the idols who were backup dancers were goofy dancers (and usually sang so badly that I couldn't even listen to them).

精錬されたパフォーマンスを楽しませて頂きました。

I enjoyed the refined performance.

アイドルという名のプロの矜持を見せつけられた気がします。

I feel like I was shown the pride of being a professional in the name of an idol.

この多様性を理解するためには、私自身が『アイドルの追っかけ』に参入しなければならない、と。

2024,江端さんの忘備録

震災になると、物資が来ないだけでなく、水もガスも来なくなります。

When the earthquake strikes, not only will supplies not come, but also water and gas will not come.

せめて情報だけでも入手したいと思っても、電気が来ないので、テレビは使えません。インターネットは言うまでもありません。

Even if you want to get some information, you cannot use the TV because there is no electricity. Not to mention the Internet. Smartphones are just a matter of time.

私は、一応、手回し発電機を入手しています。

I am getting a hand-cranked generator.

残った情報取得手段は、ラジオくらいですが、数年前に購入したラジオは、多分、電池から液漏れを起こしていて、動かなくなっています(あれは、定期的にスイッチを入れないと、ダメなものなのです)。

The only remaining means of obtaining information is a radio. Still, the radio I bought a few years ago has probably stopped working because the batteries are leaking (that thing is no good unless you turn it on regularly).

しかし、電源不要で、半永久に動き続けるラジオというものがあります。

However, some radios do not require a power source and work semi-permanently.

「ゲルマニウムラジオ」です。

"Germanium Radio."

受信アンテナからのラジオ波をゲルマニウムダイオード(整流器)を使用して検波し、それによって音声信号を取り出します。つまり、電源供給が不要で、単にアンテナとスピーカー(またはヘッドフォン)を接続するだけで動作します。

Radio waves from the receiving antenna are detected using a germanium diode (rectifier), extracting the audio signal. This means no power supply is required; simply connecting the antenna and speakers (or headphones) is all that is needed to operate.

基本的には検波が簡単なAM放送に使われますが、災害情報は、現時点ではNHKラジオ放送だけが頼りです。

It is used for AM broadcasts, which are easier to detect, but NHK radio broadcasts are the only reliable source for disaster information.

(ちょっと驚いたのですが、無電源のFMラジオを試している方がいらっしゃるようです)

(I was surprised that some people are trying out the powerless FM radio.)

私がNHK受信料を支払っている理由の一つには、この「災害情報インフラへの継続的投資」があります。

One of the reasons I pay NHK subscription fees is this "ongoing investment in disaster information infrastructure."

個人的な見解ですが、我が家のNHK受信料の支払いは、ある種の保険料であって、災害大国日本では、十分に『元が取れている』と思っています。

In my opinion, the NHK subscription fee paid by my family is a kind of insurance premium, and in Japan, a disaster-prone country, I believe it is well "paid for."

-----

ゲルマニウムラジオを製品化して販売した売れるんじゃないかな、と思っているのですが、見つけられていません。

I think a Germanium radio could be commercialized and sold, but I have not found one.

(子どもの科学向けのキットがありますが、ちゃんとパッケージ化された製品は見つかりません)。

(There are kits for children's science, but I can't find an adequately packaged product.)

まあ、あまり利益が出せそうにはないのですが。

Well, it is not going to be very profitable.

私なら、そのラジオを、天井の火災報知器の横に貼りつけておきます。

I would stick that radio following the fire alarm in the ceiling.

-----

そういう訳で、私、NHKラジオ第1・第2の統合は良いと思っているのですが、FM局への全転換は、よくよく考えた方が良いと思っています。

Integrating NHK Radio 1 and 2 is a good idea, but the total conversion to an FM station should be well thought out.

もう一度、あの日の恐怖を思い出してみましょう。

 

 

2024,江端さんの忘備録

先日嫁さんと話していたのですが、私は世間の人とは若干価値観が違うところがあるようです。

I was talking to my wife the other day, and it seems I have slightly different values than the rest of the world.

(1)自分より背の高い女性とか低い女性とか、そういうことを考えたことがない

(1) I've never considered women taller or shorter than me.

以前から申し上げている通り、私の恋愛対象の第一印象の価値基準は「自分の好みの顔」です。

As I have said before, my value criterion for first impressions in a relationship is "the face I like."

但し、世間の多数によって認定されている"美人"というものとは違うようです。

However, it seems this is not the same as the "beauty" most public recognizes.

女性:「では、先ず、ダイエットをしましょうか」

(2)事故物件(自殺者や殺人事件があった借家等)は、採否の判断基準にならない

(2)Accidental properties (e.g., houses that have had suicides or murders) are not a criterion for acceptance or rejection.

私は、いわゆる、霊魂やお化けの存在を否定していません。むしろ、個人的には『存在していて欲しい』と思っている方です。

I do not deny the existence of so-called spirits or ghosts. Instead, I am one who 'wants them to exist.

自分の五感で確認したいし、可能なら「場」の観測をさせて欲しいと思っています。かなり真剣に。

I want to confirm them with my senses, and if possible, I would like to be allowed to observe the "place." Quite seriously.

ただ、エネルギー保存法則的には、質量を有しないモノが、現実世界に与える影響は非常に小さいと思うので、日常生活に支障を与えることは、かなり難しいだろう、と考えているだけです。

From the point of view of the law of conservation of energy, I think it would be pretty difficult for things without mass to interfere with our daily lives because their impact on the real world would be minimal.

そもそも、「見えなくても存在するもの」は、世の中に腐るほどあります。重力場、電磁場などです。

To begin with, there are plenty of "things that exist even if you can't see them" in the world. These include gravitational fields, electromagnetic fields, etc.

ぶっちゃけ、私は、霊魂やお化けより、量子力学の方が怖いです(本当)。

I am more afraid of quantum mechanics than I am of spirits and ghosts (really).

逆に、事故物件は、安く借りられるそうなので、これは私には福音です。

On the other hand, I hear that accidental properties can be rented at a discount, which is gospel to me.

(3)インテリア、エクステリアへの興味が希薄

(3) Lack of interest in interior and exterior design

私は、徹底した機能主義者なので、美醜や意匠(デザイン)に、あまり興味がありません。

I am a thorough functionalist, so I am not interested in beauty, ugliness, or design.

静かに高速にスマートに走る高級車なんぞに、1mmも価値を感じられません。

I don't feel a millimeter of value in a luxury car that runs quietly, fast, and smartly.

エンジンが設置された位置から、異音や異常な振動を感じられるような、古くて、壊れかけた車の方が好きです。

I prefer older, broken-down cars where I can hear unusual noises and feel abnormal vibrations from where the engine is installed.

自動車の構造を体感できるからです。

This is because I can experience the structure of an automobile.

ただ、マーケットにおいて、「機能」が「意匠(デザイン)」に負けることは、思い知っています。

However, I know that "function" loses out to "design" in the marketplace.

視覚に訴える媒体(ここでは「デザイン」という)のパワーは恐るべきものがあります。

-----

なんとなく思い出したので、書き出してみました。

I remembered it, so I wrote them down.

2024,江端さんの忘備録

今回の地震の第1報で、私の中に最初に出てきた記憶が「スキップとローファー」でした。

The first memory that came to my mind at the first report of this earthquake was "Skips and Loafers."

今回の被災地には、私の親戚も思い当たる友人もいないのですが、それと同等、あるいはそれ以上に、コミックの登場人物を現在被災している方々に重ねて、思いを馳せる ――

I have no relatives or friends in the disaster area; however, I come to overlap the characters in the comic and the people who are currently suffering from the disaster.

これは、不謹慎なことではないと、私は思う(そう信じる)。

This is not inappropriate, I think (and believe).

『自分が何をしなければならないか、ようやく気がついた時、それは、非常に小さくて基本的なものであった』

2024,江端さんの忘備録

世界的に有名なアルゴリズムの改良版を考えていました。

Last night, I contemplated an improved version of the world-famous algorithm, which I believe is the most popular and effective.

しかし、先行研究を調べても、私の考えと同じん内容の論文が出てこなくて、不思議に思っていました。

However, I wondered why I could not find any papers describing the same ideas as mine when I checked the previous studies.

―― もしかして、私が世界初?

"Perhaps I am the first in the world?"

もしそうなら、『これで、1本(の論文)稼げた!』てなことを考えていました。

If so, "Now I've earned one (thesis)!" I thought to myself.

-----

まいったなぁ。

Oh, man.

これから、『江端法』なんて名前が付くアルゴリズムが世界で使われるようになるのかなぁ。

I wonder if algorithms with names like the "Ebata Method" will be used.

自己紹介の時に、「あの『江端法』の江端です」なんて、言わなくちゃならないのかなぁ。

I wonder if I have to say, "I am Ebata of that 'Ebata Method'" when I introduce myself.

偉そうに聞こえないように、言い方をちょっと工夫しなければ。

I have to be a little creative in how I say it so that I don't sound like a pompous ass.

などと考えながら、コーディングをしていたのですが、

I was coding, thinking about things such as the above.

『あれ? コスト値が状態に対して変動的であったとしても、従来法がそのまま適用できるんじゃないか?』

'Huh? Even if cost values were variable for the state, wouldn't the conventional method still apply?'

と気がついたのは、朝の5時でした。

I realized that it was 5:00 in the morning.

-----

1時間を稼ぐのに、ゼーゼー言っている最中に、この「頭脳をフル回転させながら、失なった無意味な数時間」は ――

While heaving to earn an hour, these "meaningless hours lost while racking your brains at full speed"--

死ぬほど痛い。

Hurts to death for me.

 

時間のない中での、こういう一日は ―― 本当に痛い。

 

2024,江端さんの技術メモ

運行情報(ダイヤグラム)を反映した最短時間で到着する計算方法は、通常のダイクストラ法を拡張して実行することができます。以下は、ダイヤ情報を考慮する最短到着時間を計算する一般的なアプローチです:

  1. グラフの作成:
    • ダイヤグラムに基づいて、駅間の接続を表すグラフを作成します。各エッジ(駅間の接続)には、所要時間が含まれます。
    • グラフのノードは駅を表し、エッジの重みは駅間の移動にかかる時間です。
    • 通常のダイクストラ法と同様に、出発駅を始点としてグラフを探索します。
  2. ノードの拡張と更新:
    • 通常のダイクストラ法と同様に、出発駅から各駅への最短到着時間を記録するデータ構造を使用します。初期状態では、出発駅の最短到着時間を0に設定し、他の駅は無限大(無効値)とします。
    • プライオリティキューを使用して、最短到着時間が最小の駅を選択します。
  3. ダイヤ情報の適用:
    • 選択した駅から出発するエッジを調べ、ダイヤ情報を考慮して最短到着時間を計算します。
    • ダイヤ情報には、駅への到着時間や運行間隔などが含まれます。現在の到着時間とダイヤ情報を使用して、次の駅への最短到着時間を計算します。
    • 新しい到着時間が現在の最短到着時間よりも短い場合、その駅の最短到着時間を更新します。
  4. プライオリティキューから次の最短到着時間の駅を選択し、ステップ3を繰り返します。目的の駅に到達した場合、計算を終了します。
  5. 最短到着時間を使用して、目的の駅への最短経路を復元します。

このアプローチを使用すると、ダイヤ情報を反映した最短到着時間を計算できます。ダイヤ情報は、駅への到着時間や運行間隔を正確に取得し、計算に組み込む必要があります。また、プライオリティキューの実装や適切なデータ構造の設計も重要です。

2024,江端さんの技術メモ

/* 
   簡易バスダイヤ作成プログラム    c:\users\ebata\dummy1.go

   (1)バス路線があり、5つの停留所("A0", "A1", "A2", "A3", "A4", "A5")があります。
   (2)このバスは始点から運行を開始し、路線の終点でで一定時間停車した後、再び逆方向に運行を開始します。
   (3)バスは朝6時に出発して、5分単位で次の停留所で停止し、終端で10分間停止します。
   (4)これを3往復するものとします。

*/



package main

import (
	"fmt"
	"strings" // strings パッケージをインポート
	"time"
)

// バスのダイヤグラム
type BusSchedule struct {
	Route             []string             // 停留所のリスト
	DepartureTime     time.Time            // 出発時刻
	ArrivalTimeStops  map[string][]string // 各停留所の到着時刻
	ArrivalTimeRounds int                  // 往復回数
}

// バスのダイヤグラムを生成する関数
func GenerateBusSchedule(route []string, departureTime time.Time, numRoundTrips int) *BusSchedule {
	schedule := &BusSchedule{
		Route:             route,
		DepartureTime:     departureTime,
		ArrivalTimeStops:  make(map[string][]string),
		ArrivalTimeRounds: numRoundTrips,
	}

	currentTime := departureTime
	reverse := false // 逆向き運行を切り替えるフラグ

	for round := 0; round < numRoundTrips; round++ {
		routeOrder := make([]string, 0, len(route)*2-1)

		if reverse {
			// 逆向き運行の場合、終点から始点に戻る
			for i := len(route) - 1; i >= 0; i-- {
				stop := route[i]
				arrivalTime := currentTime.Format("15:04")
				schedule.ArrivalTimeStops[stop] = append(schedule.ArrivalTimeStops[stop], arrivalTime)
				routeOrder = append(routeOrder, fmt.Sprintf("%s(%d): %s", stop, len(schedule.ArrivalTimeStops[stop]), arrivalTime))
				if i > 0 {
					currentTime = currentTime.Add(5 * time.Minute)
				}
			}
			reverse = false
		} else {
			// 正向き運行の場合、始点から終点に向かう
			for i := 0; i < len(route); i++ {
				stop := route[i]
				arrivalTime := currentTime.Format("15:04")
				schedule.ArrivalTimeStops[stop] = append(schedule.ArrivalTimeStops[stop], arrivalTime)
				routeOrder = append(routeOrder, fmt.Sprintf("%s(%d): %s", stop, len(schedule.ArrivalTimeStops[stop]), arrivalTime))
				if i < len(route)-1 {
					currentTime = currentTime.Add(5 * time.Minute)
				}
			}
			reverse = true
		}

		fmt.Println(strings.Join(routeOrder, "->"))
		currentTime = currentTime.Add(10 * time.Minute) // 終点での停止時間
	}

	return schedule
}

func main() {
	route := []string{"A0", "A1", "A2", "A3", "A4", "A5"}
	departureTime := time.Date(2024, 1, 6, 6, 0, 0, 0, time.UTC)
	numRoundTrips := 3

	schedule := GenerateBusSchedule(route, departureTime, numRoundTrips)

	// routeOrder を表示
	fmt.Println("routeOrder:")
	for _, stop := range schedule.Route {
		fmt.Printf("%s:\n", stop)
		for i, arrivalTime := range schedule.ArrivalTimeStops[stop] {
			fmt.Printf("  通過%d: %s\n", i+1, arrivalTime)
		}
	}
}

出力結果

C:\Users\ebata>go run dummy1.go
A0(1): 06:00->A1(1): 06:05->A2(1): 06:10->A3(1): 06:15->A4(1): 06:20->A5(1): 06:25
A5(2): 06:35->A4(2): 06:40->A3(2): 06:45->A2(2): 06:50->A1(2): 06:55->A0(2): 07:00
A0(3): 07:10->A1(3): 07:15->A2(3): 07:20->A3(3): 07:25->A4(3): 07:30->A5(3): 07:35
routeOrder:
A0:
通過1: 06:00
通過2: 07:00
通過3: 07:10
A1:
通過1: 06:05
通過2: 06:55
通過3: 07:15
A2:
通過1: 06:10
通過2: 06:50
通過3: 07:20
A3:
通過1: 06:15
通過2: 06:45
通過3: 07:25
A4:
通過1: 06:20
通過2: 06:40
通過3: 07:30
A5:
通過1: 06:25
通過2: 06:35
通過3: 07:35

2024,江端さんの忘備録

NHKの『平安時代サミット2024 本当に「平安」だったのか』を見ました。

I watched NHK's "Heian Period Summit 2024: Was it really "Heian"?

いわゆる、今年の大河ドラマの番宣番組ですが、面白かったです。

It's a so-called "promotion program" for this year's history drama, but it was interesting.

今回は3つほど頂きました。

This time, I received three of them.

-----

(1)『平安時代の呪詛と、現代のSNSは同じである』

(1) "Curses in the Heian period and social networking sites today are the same."

至言だよなぁ、と思いました。

I thought, "That's a supreme word.

SNSの誹謗中傷は物理的な攻撃ではないのに、人を殺す力があります。

Social networking slander is not a physical attack, yet it has the power to kill.

これを「呪詛」と言わずに、何と言いましょうか。

What shall we call this without calling it a curse?

やはり、SNSなんぞには手を出さないのが良いのです。

After all, it is better to stay away from social networking sites.

(2)『光源氏が"クズ"なのは、もう共通認識ですよね』

(2) "It is already common knowledge that Hikaru Genji is a scumbag.

うん、もう、これはもう、議論の余地なく、奴はクズです。

Yeah, now, this is no longer debatable, the guy is a scumbag.

源氏物語

(3)『"光源氏"を"推し"と置き換えると、その存在を認めることができます』

(3) "If you replace "Hikaru Genji" with "fave", we can recognize its existence.

私、この"推し"は知っているのですが、上記のフレーズの意味が分からなくて、嫁さんに尋ねました。

I know this "fave," but I don't know what the above phrase means, so I asked my wife.

私:「これは、自分の応援している"推し"のアイドルであるなら、クズでも構わんということ?」

Me: "Does this mean you don't care if he's a bum as long as he's your "fave" that you support?"

嫁さん:「そういうこと。"推し"とは、何をしても許される存在のことだから」

Wife: "Right." A "fave" is someone who is allowed to do whatever he wants."

やっぱり私には良く分かりませんでしたが、『"推し"って怖いものなんだなぁ』ということだけは分かりました。

I still didn't understand it well, but I did understand that "fave" is scary.

-----

私が、今でも疑問に思っていることは、

I am still wondering about the question,

『なんで源氏物語は、検閲、発行禁止を免れたのだろう?』

Why did The Tale of Genji escape censorship and a publication ban?"

ということです。

だって、あの話、皇室への不敬のオンパレードですよ。

Because that story is a parade of disrespect to the imperial family.

当時、不敬罪があったかどうかは知りませんが、基本的に皇族に対する不敬が許される時代だったとは思えません。

I don't know if there was a crime of disrespect at the time, but I don't think it was when disrespect for the royal family was tolerated.

帝(桐壺帝)の妻(藤壺)を妊娠させておいて、この子の後見人になるなんて ―― どんな"托卵"だよ!と突っ込みたくなります。

How could he get the wife (Fujitsubo) of the emperor (Kiritsubo) pregnant and then become the child's guardian? I am tempted to say, "What kind of "mendicancy" is this?

-----

さらに、私が、本当に訳が分からんのが、一条天皇が「源氏物語の愛読者」だった、という点です。

Furthermore, I don't understand that Emperor Ichijo was a "lover of the Tale of Genji."

(一条天皇と藤原氏の関係は、説明が面倒なので割愛(ググって下さい))。

(The explanation of the relationship between Emperor Ichijo and the Fujiwara clan will be cut (please Google)).

フィクションとはいえ、自分の家系が、最大級の侮辱を受けている、とは思わなったのでしょうか。

Even though it was fiction, did Emperor Ichijo ever think that his family lineage was being insulted in the greatest possible way?

私、このあたりがどうしても良く分からないので、「源氏物語文学」に詳しい方に解説頂ければ、嬉しいです。

I am unsure I understand this part very well, so I would be glad if someone familiar with "Tale of Genji Literature" could explain it.

-----

ちなみに、上記の私の疑問に応える一つの解釈はあります。

By the way, there is one interpretation that answers my question above. That means,

―― 源氏物語は、あの時代における、異世界ファンタジーであった

"The Tale of Genji was an otherworldly fantasy of its time."

ということです。

または、実世界(α世界線)に類似した、別の世界(β世界線)だった、という、平行世界線解釈です。

Or, it is a parallel worldline interpretation that the real world (alpha worldline) was similar to another world (beta worldline).

ここに、私は、

Here, I would like to propose a new interpretation of

『源氏物語 ≒ シュタインズゲート』

"The Tale of Genji ≒ Steins;Gate."

という、新解釈を提唱したいと思います。

未分類

ノード間のコストが与えられているダイクストラ計算を行うノードのそれぞれに数値が設定されていて、ノードが持っている数値より小さい数値のノードとは繋がることができない、というアルゴリズムをGo言語で作成する

main2.goで、ノードのコストが分からない場合でも対応できるように改良したもの。

package main

import (
	"fmt"
	"math"
)

type Node struct {
	Name  string
	Value float64 // 各ノードに設定された数値 (負数の場合、この数値を無視する)
}

type Edge struct {
	From   *Node
	To     *Node
	Weight float64
}

func main() {
	/*
		// ノードとエッジを初期化
		nodeA := &Node{Name: "A", Value: 5}
		nodeB := &Node{Name: "B", Value: 8}
		nodeC := &Node{Name: "C", Value: 6}
		nodeD := &Node{Name: "D", Value: 2}
		nodeE := &Node{Name: "E", Value: 4}
	*/

	// ノードとエッジを初期化
	nodeA := &Node{Name: "A", Value: 3}
	nodeB := &Node{Name: "B", Value: -1} // 負数の場合無視
	nodeC := &Node{Name: "C", Value: -1} // 負数の場合無視
	nodeD := &Node{Name: "D", Value: 2}
	nodeE := &Node{Name: "E", Value: -1} // 負数の場合無視
	nodeF := &Node{Name: "F", Value: -1} // 負数の場合無視
	nodeG := &Node{Name: "G", Value: 1}

	/*
		edges := []Edge{
			{nodeA, nodeB, 2},
			{nodeA, nodeC, 4},
			{nodeB, nodeC, 1},
			{nodeB, nodeD, 7},
			{nodeC, nodeD, 3},
			{nodeC, nodeE, 5},
			{nodeE, nodeD, 2},
		}
	*/

	edges := []Edge{ // A,B,C,D,E,Fの順で双方向をしてい
		{nodeA, nodeB, 1},
		{nodeB, nodeA, 1},

		{nodeB, nodeC, 1},
		{nodeC, nodeB, 1},

		{nodeC, nodeD, 1},
		{nodeD, nodeC, 1},

		{nodeD, nodeE, 1},
		{nodeE, nodeD, 1},

		{nodeE, nodeF, 1},
		{nodeF, nodeE, 1},

		{nodeF, nodeG, 1},
		{nodeG, nodeF, 1},
	}

	startNode := nodeG
	targetNode := nodeA

	// ダイクストラアルゴリズムを実行
	shortestPath, totalWeight := dijkstra(startNode, targetNode, edges)

	if shortestPath == nil {
		fmt.Println("最短経路が見つかりませんでした。")
	} else {
		fmt.Printf("最短経路: %v\n", getNodeNames(shortestPath))
		fmt.Printf("最短経路の総重み: %.2f\n", totalWeight)
	}

	fmt.Println(nodeA.Value)
	fmt.Println(nodeB.Value)
	fmt.Println(nodeC.Value)
	fmt.Println(nodeD.Value)
	fmt.Println(nodeE.Value)
	fmt.Println(nodeF.Value)
	fmt.Println(nodeG.Value)

}

func dijkstra(startNode, targetNode *Node, edges []Edge) ([]*Node, float64) {
	// ノード間の最短距離を格納するマップを初期化
	shortestDistances := make(map[*Node]float64)
	// 各ノードの前のノードを格納するマップを初期化
	predecessors := make(map[*Node]*Node)

	// 最短距離を無限大で初期化し、開始ノードの最短距離を0に設定
	for _, edge := range edges {
		shortestDistances[edge.From] = math.Inf(1)
		shortestDistances[edge.To] = math.Inf(1)
	}
	shortestDistances[startNode] = 0

	// 訪問済みのノードを格納するセットを初期化
	visitedNodes := make(map[*Node]bool)

	// まだ訪問していないノードが残っている間ループ
	for len(visitedNodes) < len(shortestDistances) {
		// 未訪問のノードの中から最短距離のノードを選択
		currentNode := getClosestUnvisitedNode(shortestDistances, visitedNodes)

		// ノードがない場合やターゲットノードに到達した場合は終了
		if currentNode == nil || currentNode == targetNode {
			break
		}

		for _, edge := range edges {
			if edge.From == currentNode {
				if edge.To.Value < 0 { // -1などの負数が入っていたら、更新してしまう
					edge.To.Value = currentNode.Value // 下のif文を通す為の手続(書き換えても大丈夫かな(今のところ大丈夫そうだけど))
				}
				if edge.To.Value >= currentNode.Value { //
					distance := shortestDistances[currentNode] + edge.Weight
					if distance < shortestDistances[edge.To] {
						shortestDistances[edge.To] = distance
						predecessors[edge.To] = currentNode
					}
				}
			}
		}

		// このノードを訪問済みとしてマーク
		visitedNodes[currentNode] = true
	}

	// 最短経路を復元
	shortestPath := make([]*Node, 0)
	currentNode := targetNode
	for currentNode != nil {
		shortestPath = append([]*Node{currentNode}, shortestPath...)
		currentNode = predecessors[currentNode]
	}

	// 最短経路の総重みを計算
	totalWeight := shortestDistances[targetNode]

	return shortestPath, totalWeight
}

func getClosestUnvisitedNode(distances map[*Node]float64, visitedNodes map[*Node]bool) *Node {
	minDistance := math.Inf(1)
	var closestNode *Node

	for node, distance := range distances {
		if !visitedNodes[node] && distance < minDistance {
			minDistance = distance
			closestNode = node
		}
	}

	return closestNode
}

func getNodeNames(nodes []*Node) []string {
	names := make([]string, len(nodes))
	for i, node := range nodes {
		names[i] = node.Name
	}
	return names
}