2023,江端さんの忘備録

私が大学生の頃、カルト教団批判を続けてきた人が『空気銃で狙撃された』という話を聞きました。

When I was a college student, I heard that someone who had been a critic of cults had been 'shot with an air gun.

―― 私も危ないかもしれない

"I might be in danger, too."

と、危機感を持っています。

I have a sense of urgency.

江端家は、私の作った24時間体制の監視システムが動き続けています。

The Ebata family has a 24-hour surveillance system that I created that keeps it running.

しかし、仮にこのシステムで犯人が特定できても、私や家族が襲撃され殺傷されたら、それは『負け』です。

However, even if this system can identify the culprits, it would be a loss if they attacked and killed me or my family.

以前から申し上げている通り『テロは襲撃側が必ず勝つ』し、『自爆テロを防ぐ手段はない』からです。

As I have said, the attacker always wins in terrorism, and there is no way to prevent suicide bombings.

-----

私の場合、屋外で襲撃されたら、手も足も出ません。

In my case, if I am attacked outdoors, I have nothing to do.

だから、(他の人は知りませんが)私に関して言えば、

So, as far as (I don't know about others),

―― リモートワークによる「引きこもり」という自衛手段

"Self-defense by "shutting myself away" through remote work"

は重要なのです。

is important.

ですから、「出社が面倒」―― そんなこと、1mmも思っていません。

So, "Going to the office is a hassle" - I don't think that for a single millimeter.

という訳で ―― この平和な時代にあっても、「武装」という概念を持ち続けているシニアが存在していることを、覚えておいて下さいね。

2023,江端さんの忘備録

ジャニーズ事務所の社名変更問題ですが、私は、

As for the issue of changing the company name of Johnny's Office, I think

―― 大都芸能

"Daito Entertainment"

が、いいんじゃないかと思うんですが、いかがでしょうか?

is a good name.

「紅天女」の上映権を取得して、現実世界で「ガラスの仮面」の幕を引く、というのは、なかなか良いアプローチだと自負しております。

I am proud that acquiring the rights to screen "Red Tennyo" and pulling back the curtain on "The Glass Mask" in the real world is a good approach.

『"紅天女"なんぞに、どれだけのコストと時間をかけているんだ?』と

2023,江端さんの技術メモ

今迄、エージェントプログラムでは、エージェントの中に内部時計(正確にはSleep())を組み込んで、エージェント間の時刻同期については、無視してきたのですが、交通シミュレーションに時刻表を入れる必要になって、無視できなくなってきました。

今や、私の十八番となったredisを使ったgolangのgoroutineで作った複数エージェントへのメッセージのブロードキャストを使って、時刻同期をするサンプルプログラムを作ってみました。

BaseClock()から、所定時間間隔で、シミュレーション共通の時刻をブロードキャストして、person()のエージェントで、その時刻情報を割り込み受信させることにしました。

ブロードキャストによる遅延や割り込み取りこぼしが心配ではありますが、これまでの経験上redisのブロードキャストは十分に高速なようなので、多分大丈夫だと思います。

// C:\Users\ebata\tomioka3B\src\others\main26.go

package main

import (
	"encoding/json"
	"fmt"
	"sync"
	"time"

	"github.com/gomodule/redigo/redis"
)

var Clock1 chan interface{}

type Clock_Info struct {
	VirtualTime time.Time
	RealTime    time.Time
}

func BaseClock(wg *sync.WaitGroup) {
	defer wg.Done()

	// 接続
	conn, err := redis.Dial("tcp", "localhost:6379")
	if err != nil {
		panic(err)
	}
	defer conn.Close()

	// スタート時刻を指定
	startTime := time.Date(2023, 10, 1, 7, 0, 0, 0, time.UTC)

	// 1秒値を保持する変数
	seconds := 0

	var ci Clock_Info

	// ループを開始
	for {
		// 現在の時刻を計算
		ci.VirtualTime = startTime.Add(time.Duration(seconds) * time.Second)
		ci.RealTime = time.Now()

		// 現在の時刻を表示
		fmt.Println("シミュレータの時刻:", ci.VirtualTime.Format("2006/01/02 15:04:05"))
		fmt.Println("現在の時刻:", ci.RealTime.Format("2006/01/02 15:04:05")) // "2006/01/02 15:04:05"はフォーマットの形を真似るもので、内容に意味なし

		// パブリッシュ
		json_ci, _ := json.Marshal(ci)
		r, err := redis.Int(conn.Do("PUBLISH", "ClockInfo_1", json_ci))
		if err != nil {
			panic(err)
		}
		fmt.Println(r)

		// 5秒待つ (実際は、0.05秒くらいだが、確認用に長くしている)
		time.Sleep(5000 * time.Millisecond)

		// 1秒値を増加させる
		seconds++
	}
}

func person(person_num int, wg *sync.WaitGroup) {
	defer wg.Done()
	// 接続
	conn, err := redis.Dial("tcp", "localhost:6379")
	if err != nil {
		panic(err)
	}
	defer conn.Close()

	psc := redis.PubSubConn{Conn: conn}
	psc.Subscribe("ClockInfo_1")

	for {
		ci := new(Clock_Info)
		switch v := psc.Receive().(type) {
		case redis.Message:
			_ = json.Unmarshal(v.Data, &ci)
			fmt.Println("Person:", person_num, "VirtualTime:", ci.VirtualTime)
			fmt.Println("Person:", person_num, "RealTime:", ci.RealTime)

		case redis.Subscription:
			fmt.Printf("%s: %s %d\n", v.Channel, v.Kind, v.Count)

		case error:
			return
		}
	}
}

func main() {

	wg := sync.WaitGroup{}

	wg.Add(1)
	go BaseClock(&wg)

	for i := 0; i < 10; i++ { // 10人
		wg.Add(1)
		go person(i, &wg)
	}

	wg.Wait()
	fmt.Println("end of ... main()")
}

 

 

2023,江端さんの忘備録

今の日本には、同性婚、ジャニー喜多川性犯罪、新しい資本主義、少子化対策、拉致、年金 ・・・ 色々あります。

In Japan today, there are many things: same-sex marriage, Janie Kitagawa's sex crimes, new capitalism, declining birthrate, abductions, pensions, etc.

何かの問題が出れば、SNSで叫んで、自分の気分をすっきりさせて、すぐに忘れる人間 ―― 彼らのやっていることは、詰るところ、自慰行為です。

Whenever a problem arises, people shout about it on social media to make themselves feel better and quickly forget about it. What they are doing is, after all, masturbation.

以前、私は、この「自慰行為を見せつけらている被害者」として、このような人々を批判したことがあります。

As a "victim," I have previously criticized those who show me the masturbation.

世の中のかなり多くの人が、『私の記事を一行も読まない』まま、私の記事に対して批判や非難をしてくるからです。

私の「浅学」「狭量」「卑怯」の中でも、得に「卑怯」の面目躍如と言えましょう。

とは言え、私のブログも、自慰行為と言えば、自慰行為です ―― ですが、私は、それが自慰行為であったとしても、そのオカズのエロ本は、一冊に集中したいと考えています。

However, my blog is also a masturbatory act. But I want to focus on one erotic book, even if it is a masturbatory act.

という訳で、今の私は、『旧統一教会の解散請求』の問題に集中しています。

This is why I am now concentrating on the issue of the "Request for Dissolution of the former Unification Church."

-----

旧統一教会は、我が国が保証する「宗教性善説に基づく宗教の自由」の解釈のスキを付いた、(何回もの警告にも関わらず)人権無視の非人道的行為を行い続け、それによって法律が改正されるまでに至りました。

The former Unification Church continued to engage in inhumane acts of disregard for human rights (despite numerous warnings) that skirted the interpretation of our country's guarantee of "freedom of religion based on the goodness of faith. This has led to the law being amended.

この私ですら、『やむを得ない』と思える改正でした。

Even I, here, found the revision 'unavoidable.

ともあれ、旧統一教会の宗教法人格を認め続ければ、第2、第3の旧統一教会の登場を許すことになります。

At any rate, if we continue to recognize the religious juridical status of the former Unification Church, we will allow a second or third former Unification Church to emerge.

これまでの対応(文化庁の質問権に対する反応を含める)で、旧統一教会に、全うな人権の考え方や、現代の社会通念や、法治の概念が発生してくることを期待するのは、『全くの無駄』だと理解しました。

From the responses so far (including the response to the right of the Cultural Affairs Ministry to ask questions), I understand that it is 'completely futile' to expect the former Unification Church to come up with a full concept of human rights, modern social conventions, and the rule of law.

詐欺まがいの寄付(犯罪)をやるなら、―― 社会問題にならない程度の金額や規模に抑える、という程度の『犯罪の運用・管理』もできないほどに、絶望的にマヌケなんですよ、ヤツら(旧称統一教会)は。

―― 当たり前だバカ。この異常な養子縁組の上、金銭の授受までやっていたら、お前らは『本物の悪魔』だ

(2)(黙示的な内容)人の心の弱さに付け込んで、信者の生命と生活を危機に陥れて、なお、それを"献金"だの"浄財"だのと言い張る宗教団体ふぜいが「宗教の自由(憲法第20条)」を語るんじゃねえ

では、今回の解散請求の意義は何か?

So, what is the significance of this dissolution request?

このような、法を濫用し、人権を踏み躙る宗教団体が、再び「国家の庇護対象」とならないよう『旧統一教会にその先例となって貰う』ことです。

We must "let the former Unification Church set a precedent" so that religious organizations that abuse the law and trample on human rights will not again become "state patronage targets.

----

『宗教というのは人の心を救済するものであり、人々を幸せにするものであり、それゆえに、国家によって保護される必要がある』と、私は心底から信じています。

I believe wholeheartedly that 'religion is something that saves people's hearts and makes them happy and, therefore, needs to be protected by the state.

それ故、信者を洗脳し、家族の絆を破壊し、誰一人として見たこともない来世をエサにして個人財産を巻き上げるような集団に、宗教を名乗る資格はない。

Therefore, a group that brainwashes its followers destroys family ties and uses the afterlife, which none have seen as bait to take their personal property. It has no right to call itself a religion.

いや、正確言えば、こんな団体であってさえ、宗教を名乗っても良いのです。どんな宗教であれ「宗教」は「自由」なのですから(日本国憲法第20条)。

No, to be precise, even such an organization may call itself a religion. Because "religion" of any kind is "freedom" (Article 20 of the Constitution of Japan).

しかし、国家が法律で、そして我々日本国の国民の血税で、やつらの宗教法人格による特権を、守ってやる義理も義務もありません。

However, the state has neither the obligation nor the duty to protect the privileges of their religious juridical status by law and with the blood taxes of the Japanese people.

旧統一教会にとっても、これが「一番かっこいい国家との決別」だと思います。

未分類

ラプラス分布は、ランデル分布とも言われて、交通工学のシミュレーションでは非常に重要な確率分布として使われているようです。

パラメータとして、平均(location parameter)を表す μ と尺度(scale parameter)を表すbを持ち、ラプラス分布の確率密度関数は、 f(xμ,b)=1/2b exp(bxμ∣​) と表される。

でもって、

交通シミュレーションで使われる場面

■交通の到着間隔のモデリング → 乗客の到着間隔をモデル化するため

■トラフィックの所要時間の予測 → 自動車の移動時間やトラフィックの所要時間を予測するため

■信号制御の最適化 → 信号のサイクルタイムやフェーズの最適化を行うため

■交通事故の発生確率の評価 → 交通事故の発生確率を評価するため

と、まあ、ここまでは分かったのですが、この分布の数学的な意義が分かりません。(正規分布や指数分布などは、理解できていると思います)

ですが、ラプラス分布の数学的な意義が分かりません。

で、以下のように推察しているのですが、私のこの推察は正しいでしょうか?

ラプラス分布を使う理由(江端の私見)

■外れ値のモデル化の為

→ そもそも、バスの到着時間が、正規分布のように曖昧に分散していたらとても困る。情報通信についても同様。とは言え、外れ値を完全に無視することはできない。そこで、このような、交通、情報を扱う分布として、(積分して1になる関数として)便利なツールとして、ラプラス分布が使われている

どなたか、ご見解を頂ければ幸いです。

江端

2023,江端さんの忘備録

「育児を手伝う」とか「家事を手伝う」などと、この時にあって、まだこんな『ふざけた』ことを平気でいっている、低能な男性芸能人のコメントに、腹を立てています

I am offended by the comments of lowly male entertainers who, in this day and age, are still talking about "helping with childcare" and "helping with household chores" and such "ridiculous" things.

―― 「育児は『する』もの」であり「家事は『する』もの」である

"Raising children is a 'doing' and housework is a 'doing'."

その程度の認識のない人間は、結婚はもちろん、育児に関わるべき人間ではありません。

People who do not have that level of awareness should not be involved in marriage, let alone raising children.

-----

最近の私は、世間の価値観が『2週間』で更新され続けていることを、痛感しています。

I have been acutely aware that the world's values continue to be updated in 'two weeks.'

ちょっと油断していると、世間の価値観から乖離してしまいます。

If I am not careful for a moment, I can diverge from the world's values.

ですので、私は、新聞、ニュース、その他のメディアを、頻繁にキャッチし続けるようにしています。

So, I try to keep up with the newspapers, news, and other media as often as possible.

もちろん、個人の信念や価値観(ポリシー)は、個人として持ち続ければ良いです。

Of course, you can continue to hold on to your personal beliefs and values (policies).

ただし、それは、世間との乖離を客観的に把握し続けた上で、のことです。

However, this is only after keeping an objective eye on the divergence from the public.

無知や無能だけで支えられている個人のポリシーなんぞ、私は、指を差して、罵倒して、嗤(わら)ってやります。

I will point, abuse, and sneer at any personal policy supported only by ignorance and incompetence.

-----

男性の育休に関して、私は一つの社会実証実験を提案しています。

About male maternity leave, I am proposing a social experiment.

『男性(夫)の育休休暇期間中の、女性(妻)の一定期間(例、3日~1週間)の外泊』です。

"During the husband's parental leave period, the wife stays out for a certain period (e.g., three days to 1 week)."

夫の寄与率100%の育児期間を設ける ―― これが絶対的に必要だと思います。

A period of childcare for the husband with a 100% contribution rate -- I think this is necessary.

そもそも、"育児の地獄"を体感できない人間が、"親"をかたるべきではないのです。

To begin with, a person who cannot experience the "hell of child-rearing" should not call himself a "parent."

―― この子を殺して、ぐっすり眠りたい

-----

しかし、この実証実験については、嫁さんが強い難色を示しています。

However, my wife has expressed strong reservations about this social experiment.

嫁さん:「その実証実験を実施すれは、かなり多くの幼児が"死ぬ"ことになるよ」

Wife: "If you do that experiment, many toddlers will "die."

江端:「私もそう思う。しかし、このくらいの危機感を与えないと、バカな男は、いつまでも"バカ"のままだ。だから、社会実証実験では、各種のセーフネットも併わせて準備する」

Ebata: "I agree. However, unless we give them a sense of crisis like this, stupid men will always remain stupid. Hence, we must prepare various safety nets for the social experiment."

モニタリング、コールセンタ、緊急救命派遣などを準備する必要があると思います。

We must prepare for monitoring, call centers, emergency life-saving dispatches, etc.

これらのセーフネットは、実験コストを高いものにするかもしれません。

These safety nets may make the cost of experimentation high.

しかし、「育児を手伝う」とか言っているバカに、「育児は『する』もの」であるという認識を叩き込むコストとしては、妥当なようにも思えます。

However, it seems reasonable as a cost to knock the perception that "Raising children is a 'doing' into the idiots who say they are going to "help with childcare."

この『男性(夫)の育休休暇機関中の、女性(妻)の一定期間(例、3日~1週間)の外泊』が、社会に定着すれば、セーフネットのコストも減少していく、と期待しています。

I expect the safety net cost will decrease if "during the husband's parental leave period, the wife stays out for a certain period (e.g., three days to 1 week)" becomes a common practice in society.

もう一つの可能性としては、「驚愕的な未婚率の上昇」という悪夢もありえます。

Another possibility could be the nightmare of a "startling increase in lifetime unmarried rates.

まあ、私たちが、"それ"を選ぶのであれば、粛々と、穏やかな我が国の死を受けいれるしかないでしょう。

Well, if that's what we choose, we will have to accept the death of our country solemnly and peacefully.

-----

では、現在のような育児休暇の考え方がなかった世代の、私のようなシニアはどうなるか?

So what happens to seniors like me, a generation that did not have the current concept of parental leave?

私(江端)は、逃げ得か?

Am I only gaining by running away?

いやいや、これからは、育児という概念がシニアの男に拡大すると思いますし、そうさせなければなりません。

No, I believe that childcare will expand to senior men and must be allowed to do so.

要介護フェーズに入っていない健康なシニアは、そのリソースを「育児」に向ける時代になります。

Healthy seniors who have not entered the phase of needing nursing care should direct their resources to "childcare."

娘たちの子どもの育児を、一定期間、私(江端)が一人でやる ―― 私には、その覚悟ができています。

I (Ebata) will be raising my daughters' children by myself for a certain period -- I am ready to do so.

-----

―― 私の過失で幼児を殺すことになるか、あるいは、私が育児過労で死ぬか

"My negligence will kill my toddler, or I will die from overworked childcare."

今、命をかけた、新しい育児の形が問われています。

Now, a new form of childcare is being questioned, putting life on the line.

2023,江端さんの忘備録

ドラマ「VIVANT」というのが大変人気のようだったので、ちょっと見てみました。

The drama "VIVANT" seemed to be very popular, so I took a look at it.

面白かったです。

It was interesting.

このドラマは、自衛隊の中でも、非公開で非合法の組織の暗躍を取り扱ったもの(のよう)です。

This drama deals with the darker side of the IDF, an undisclosed and illegal organization.

いわゆる、『イリーガル(非合法)』と言われているものです。

This is what is known as "ILLEGAL."

法治国家においては、どのようなものであれ、イリーガルは文字通り不法行為であり、刑罰(処罰)の対象であり、国庫からの予算は憲法違反です。

In a nation governed by the rule of law, ILLEGALs of any kind are illegal and subject to punishment (penalty), and budgeting from the national treasury violates the Constitution.

また、歴史上、このような政府の子飼いであるはずのイリーガルが、逆に、自国の政府を転覆させた事例など、山ほどあります。

History is replete with examples of cases in which the supposed child of a government, the ILLEGAL, has, on the contrary, overthrown its government.

つまるところ、イリーガルは、シビリアンコントロール(文民統制)の原則に反するものであり、一言で言えば、法治国家の敵です。

In short, ILLEGALs violate the principle of civilian control and are, in a word, enemies of the rule of law.

―― というような、シラけたことを書き込みしている人は、さすがにいないようですね(ちゃんと調べていませんが)。

No one has written something like that (I haven't appropriately checked).

まあ、『そういう非合法組織がないと、国家の運営が困るだろうな』ということは、国民もなんとなく理解していると思います。

The public somewhat understands that 'without such illegal organizations, the state would have trouble running the country.

-----

イリーガルと言えば、コミック「スケバン刑事」は、イリーガルの極とも言えるものでした。

Speaking of ILLEGALs, the comic " Sukeban Deka(Police of a female gang)" was the extreme of illegalism.

こちらは、警察組織のイリーガルです。

This is the police organization ILLEGALs.

この物語に登場する「暗闇警視」は、違法行為を承知の上で、学生をスパイとして学校に潜入させる確信犯でした。

The "Inspector Darkness" in this story was a crime of conscience who knowingly infiltrated students into the school as spies, knowing it was illegal.

そして、「スケバン刑事」である麻宮サキは、潜入、調査のみならず、銃刀法違反に問われない武器(ヨーヨー)を使って、違法暴力行為で被疑者を制圧するという、テロ行為まで認容されていました。

And Saki Asamiya, a "Sukeban Deka," was authorized not only to infiltrate and investigate but also to commit acts of terrorism, using a weapon (yo-yo), which is not charged with violating the Firearms Act, to subdue suspects in acts of illegal violence.

-----

ふと思ったのですが、もしかしたら、今なら、学校のいじめの実体把握に、警察の手先となった子どもが配備されているかもしれません。

It occurred to me that perhaps now, a child who has become a pawn of the police might be deployed to help the school identify the substance of the bullying.

それはそれで、有効かもしれませんし、正直支援したい気持ちがあります。

That may be valid, and frankly, I would support it.

まあ、それはさておき。

Well, let's put that aside.

-----

国家権力(警察)による潜入工作(や破壊工作)は、普通に行われています。

Infiltration (and sabotage) by state power (police) is standard.

これは、陰謀論ではなく、関係者(下手すると警察当局自身が)公表していることですし、裁判所の認可を受ければ、潜入工作自体は合法です。

This is not a conspiracy theory but something publicized by the people involved (and if poorly done, by the police authorities themselves), and the infiltration operation itself is legal if approved by the court.

最近では、テロを伴う左翼団体は、警察のスパイによってほぼ壊滅され尽くされましたし、反社(暴力団)なども内部の潜入やタレコミによって、全滅に向かって進められています。

Recently, leftist groups with terrorist activities have been almost destroyed by police spies, and anti-social groups (gangs) are also being advanced toward destruction by inside infiltration and tip-offs.

ただし、裁判において、潜入工作による証拠が採用できるかどうかは、不明です(ご存知の方は教えて下さい)。

However, it is unclear whether evidence from undercover operations can be adopted in a court of law (please let me know if you know).

最高の笑顔

ただ、裁判所は、「VIVANT」や「スケバン刑事」の活動を、絶対に認可しないと思います(高度な政治的圧力があれば別かもしれませんが)。

However, I don't think the courts will ever sanction the activities of "VIVANT" or "Sukeban Deka" (unless there is a high level of political pressure to do so).

-----

ともあれ、このような話は、ドラマやコミックを楽しんでいる人の横で、語ってはなりません。

Anyway, such stories should not be told besides those enjoying the drama and comics.

絶対に嫌われます。

They absolutely come to hate you.

2023,江端さんの技術メモ

pgr_dijkstra()で、ダイクストラの順番を壊さずにルートの座標を得る方法(getDijkstraPath())

ノードの切断を発生させず、ノード10~ノード20と、ノード30~ノード40を回避するダイクストラ計算を行うPostGISのクエリー

をベースとしたGo言語のプログラムになります。

// C:\Users\ebata\tomioka3B\src\others\main23.go
package main

import (
	"database/sql"
	"fmt"
	"log"
	"m/src/ldarp"
	"strconv"

	_ "github.com/lib/pq"
)

func main() {
	db, err := sql.Open("postgres",
		"user=postgres password=password host=192.168.0.23 port=15432 dbname=tomioka_db_c sslmode=disable")
	if err != nil {
		log.Fatal("OpenError: ", err)
	}
	defer db.Close()

	/*
		以下のldarp.LocInfoの内容は、
		type LocInfo struct {
			Lon    float64
			Lat    float64
			Source int
		}
		となっています。
		このプログラムファイルでは、上記を定義して、ldarp.LocInfoを、LocInfoと変換すれば動きます

		ただ、前提とするpostgresqlのpostGISが取り扱うデータベースは、
		mapconfig_for_cars.xml をベースとして構築しているものになりますので、ご留意下さい
		https://github.com/pgRouting/osm2pgrouting/blob/main/mapconfig_for_cars.xml
	*/

	var a_Point, b_Point ldarp.LocInfo

	a_Point.Source = 1  // 出発ノード
	b_Point.Source = 50 // 到着ノード

	var del_start1, del_end1, del_start2, del_end2 ldarp.LocInfo
	//var del_start3, del_end3 ldarp.LocInfo

	del_start1.Source = 10 // 1つ目の無効としたいノード番号(開始番号)
	del_end1.Source = 20   // 1つ目の無効としたいノード番号(終了番号)
	del_start2.Source = 30 // 2つ目の無効としたいノード番号(開始番号)
	del_end2.Source = 40   // 2つ目の無効としたいノード番号(開始番号)
	//del_start3.Source = 30
	//del_end3.Source = 35

	array1 := []ldarp.LocInfo{del_start1, del_end1} // 上記の無効としたいノード番号を登録する
	array2 := []ldarp.LocInfo{del_start2, del_end2} // 上記の無効としたいノード番号を登録する
	//array3 := []ldarp.LocInfo{del_start3, del_end3}

	//delSourceArray := [][]ldarp.LocInfo{array1, array2, array3}
	delSourceArray := [][]ldarp.LocInfo{array1, array2} // 登録したノード番号をarraysの変数に纏める
	//delSourceArray = [][]ldarp.LocInfo{}

	// arrays変数への挿入
	//for _, arr := range arrays {
	//	delSourceArray = append(delSourceArray, arr)
	//}

	// fmt.Println(delSourceArray)

	path, dist := getDijkstraPath(db, a_Point, b_Point, delSourceArray)

	fmt.Println("path:", path)
	fmt.Println("dist:", dist)

}

// 江端再修正版(2023/09/29)
/*
出発ノードと到着ノードと、通過したくないノード(無効したいノード)を登録して、ダイクストラ計算によるルートを選ぶ
*/

func getDijkstraPath(dbMap *sql.DB, locInfoStart, locInfoGoal ldarp.LocInfo, delSourceArray [][]ldarp.LocInfo) ([]ldarp.LocInfo, float64) {
	log.Println("getDijkstraPath", locInfoStart, locInfoGoal)

	sql_str := "" // SQL文を作る文字列の初期値

	// delSourceArray の解析
	fmt.Println("delSourceArray:", delSourceArray)

	if len(delSourceArray) != 0 { // delSourceArrayに要素が入っていれば

		// forとrangeを使用して各要素のSource値を取得
		sql_str = "WHERE "

		for _, arr := range delSourceArray {
			/*
				for _, loc := range arr {
					fmt.Printf("Sourceの値: %d\n", loc.Source)
				}
			*/
			fmt.Println(arr[0].Source, arr[1].Source)
			//str += "( source NOT BETWEEN " + arr[0].Source + " AND " + arr[1].Source + " AND target NOT BETWEEN " + arr[0].Source + " AND " + arr[1].Source + ")"
			sql_str += "(source NOT BETWEEN " + strconv.Itoa(arr[0].Source) + " AND " + strconv.Itoa(arr[1].Source) + " AND target NOT BETWEEN " + strconv.Itoa(arr[0].Source) + " AND " + strconv.Itoa(arr[1].Source) + ") AND "
			//fmt.Println(str)
		}
		strlen := len(sql_str)
		sql_str = sql_str[:strlen-5] // ラストの" AND "の5文字を削除する
		//fmt.Println(str)
	}

	sql_str = "SELECT seq,source, target, x1, y1, x2, y2, agg_cost FROM pgr_dijkstra('SELECT gid as id, source, target, cost, reverse_cost FROM ways " + sql_str + "', $1::bigint , $2::bigint , directed:=false ) a INNER JOIN ways b ON (a.edge = b.gid) ORDER BY seq"

	//fmt.Println(sql_str)

	var path []ldarp.LocInfo // 経路 (返り値の一つ目)
	var totalDistanceKm float64

	rowsDijkstra, errDijkstra := dbMap.Query(
		//"SELECT seq,source, target, x1, y1, x2, y2, agg_cost FROM pgr_dijkstra('SELECT gid as id, source, target, length_m as cost FROM ways', $1::bigint , $2::bigint , directed:=false ) a INNER JOIN ways b ON (a.edge = b.gid) ORDER BY seq",
		//"SELECT seq,source, target, x1, y1, x2, y2, agg_cost FROM pgr_dijkstra('SELECT gid as id, source, target, length_m as cost FROM ways WHERE (source NOT BETWEEN 10 AND 20 AND target NOT BETWEEN 10 AND 20) AND (source NOT BETWEEN 30 AND 40 AND target NOT BETWEEN 30 AND 40)', $1::bigint , $2::bigint , directed:=false ) a INNER JOIN ways b ON (a.edge = b.gid) ORDER BY seq",
		sql_str,
		locInfoStart.Source,
		locInfoGoal.Source)

	if errDijkstra != nil {
		log.Fatal(errDijkstra)
	}
	defer rowsDijkstra.Close()

	var agg_cost float64

	var loc ldarp.LocInfo
	var x1, y1, x2, y2 float64
	var seq int
	var target int
	var source int

	isFirstCheck := true
	isSourceCheck := true

	for rowsDijkstra.Next() {

		// まずnodeを読む
		if err := rowsDijkstra.Scan(&seq, &source, &target, &x1, &y1, &x2, &y2, &agg_cost); err != nil {
			fmt.Println(err)
		}

		// 最初の1回だけチェックのために入る これについては、https://wp.kobore.net/江端さんの技術メモ/post-7668/を参照のこと
		// もし rowsDijkstra.Scanで最初のsource値を読みとり、locInfoStart.Source の値と同じであれば、x1,y1をベースとして、異なる値であれば、x2,y2をベースとする

		if isFirstCheck {
			if source == locInfoStart.Source {
				isSourceCheck = true // x1, y1をベースとする処理になる
			} else {
				isSourceCheck = false // x2,y2をベースとする処理になる
			}
			isFirstCheck = false // 最初の1回をチェックすることで、2回目はこのループには入らなくなる
		}

		//var loc ldarp.LocInfo

		if isSourceCheck { // x1, y1をベースとする処理
			loc.Source = source
			loc.Lon = x1
			loc.Lat = y1
		} else { // x2,y2をベースとする処理
			loc.Source = target
			loc.Lon = x2
			loc.Lat = y2
		}
		path = append(path, loc)
	}

	// ラストノードだけはsourceとtargetを引っくり返す
	if isSourceCheck { // x1, y1をベースとする処理
		loc.Source = target
		loc.Lon = x2
		loc.Lat = y2
	} else { // x2,y2をベースとする処理
		loc.Source = source
		loc.Lon = x1
		loc.Lat = y1
	}

	path = append(path, loc)

	totalDistanceKm = agg_cost / 1000.0
	return path, totalDistanceKm
}

2023,江端さんの忘備録

先日、BSで、映画「十戒」が放送されていたので、録画しました。

The other day, the movie "The Ten Commandments" was broadcast on BS, and I recorded it.

江端:「『十戒』を録画しておいたので、興味があれば見て」

Ebata: "I recorded 'The Ten Commandments' for you to watch if you are interested."

嫁さん:「うーん、あまり興味ないかな」

Wife: "Hmmm, not interested."

江端:「旧約聖書を読むより、ラクに理解できるよ」

Ebata: "It's easier to understand than reading the Old Testament."

嫁さん:「なんで、旧約聖書の内容を理解しなければならないの?」

Wife: "Why do I have to understand the Old Testament?"

と言われて、「確かに、そうだ」と、納得してしまいました。

I thought, "Sure, that's right," and agreed.

日本人なら、「日本神話」の方が先だと思ったのですが、よく考えたら「いやいや、別に、それすらも必要ないだろう」と自分で、自分に突っ込んでしまいました。

I thought "Japanese mythology" would be the first thing a Japanese person would think of, but then I thought about it and said, "No, no, not really, we don't even need that either."

私は、日本の神様(天皇陛下のご先祖)が、結構「ポンコツ」だったという話が、結構好きです。

旧約聖書の内容を知っていると、トクになることって何だろうなぁ、と考えてみたのですが、現在の問題に限定すれば「パレスチナ問題」の見通しが良くなるくらいですかね。

I wondered what the benefits of knowing the contents of the Old Testament would be, and I thought that if limited to current issues, it would only improve the outlook on the "Palestinian problem."

-----

個人的には、「旧約聖書」より「新約聖書」の方が面白いです。

I find the "New Testament" more interesting than the "Old Testament".

といっても、わざわざ「新約聖書」を読む必要なんぞななくて、関連するアニメや映画やコミックで、断片的に内容を繋げれば十分だと思います。

However, reading the "New Testament" all the way through is unnecessary. It is enough to connect the contents of the New Testament with related anime, movies, and comics in bits and pieces.

そもそも、その「新約聖書」は、ナザレのイエス没300年後(西暦325年)に、編集会議(ニケーア公会議)で、その内容を、各宗派の議論と投票で決定したものです。

To begin with, the contents of the "New Testament" were decided by the editorial council (Council of Nicea) 300 years after the death of Jesus of Nazareth through discussion and voting by the various denominations.

新約聖書の編集会議は、少年ジャンプの新連載マンガを決定する、または連載打ち切りを決定する会議と、基本的に同じだったのです。

The New Testament editorial meeting was essentially the same as the meeting that decided on a new manga series for Shonen Jump or decided to discontinue the series.

まあ、そう考えていくと、ルターの宗教改革から始まったプロテスタントキリスト教や、その「聖書至上主義」も、私の心にはヒットしません。

When I think about it, Protestant Christianity and its "biblical supremacy" that began with Luther's Reformation doesn't hit me either.

―― 人間が会議で編纂した書物(新約聖書)が、「神の言葉」なんぞである訳がない

"How can a book (the New Testament) compiled by a conference of men be the "Word of God"?"

と。

カソリックキリスト教については、言うに及ばずです。

Not to mention Catholic Christianity.

ちなみに、仏教の各宗派に関しては、私は、異なる同人誌のサークルくらいの意識しか持っていません。

By the way, I know that Buddhist sects are the same as doujinshi circles.

―― ゴーダマシッダールタさん没後、2500年オーダの時間をかけて創作され続けた膨大な物量の「同人誌」

もちろん、私は、コミケサークルの活動を尊重しているくらいですから、世界中の宗教も ―― アホなカルト宗教団体や原理主義者を除けば ―― 同様に敬意を払っています。

Of course, I respect the activities of the Comic Circle so much that I appreciate all the religions of the world -- except for the idiotic cult groups and fundamentalists -- as well.

-----

『では「神学」は無意味な学問か』と問われれば、そうではないようです。

If you ask, 'Then is "theology" a meaningless discipline?' it seems not.

「神学」は、哲学でもあり、論理学でもあり、法学でもあり、見方によっては科学や数学(の証明)とも言えるもののようです。

"Theology" appears to be a philosophy, a logic, a jurisprudence, and, depending on one's point of view, a science or a mathematical (proof of) science.

私に来世があるなら、「神学」の勉強をしてみたいと思っています(現世は、ちょっと忙しすぎるようなので)。

If I have a next life, I would like to study "theology" (this life seems a bit too busy for me).

-----

「旧約」も「新約」も「日本神話」も、私たちには、別段必要ではありません。

We don't need "Old Testament," "New Testament," or "Japanese mythology.

という訳で、本日の日記は、スルーして頂いて結構です。

Therefore, you may pass through today's diary.

あなたたちの中で、不要不急の外出をしたことがない者が、政府または東京都に、まず石を投げなさい