2022/09,未分類,江端さんの技術メモ

ホームページを丸ごとダウンロードできる便利ツールHTTrack(WinHTTrack)の使い方

EE Times Japan風のスタイルサンプル


<!-- globalStylesheet -->

<link rel="stylesheet" href="https://www.itmedia.co.jp/css/ee/base.css?201908291653" type="text/css" media="all">
<link rel="stylesheet" href="https://www.itmedia.co.jp/css/ee/ad.css?202106291147" type="text/css" media="all">
<link rel="stylesheet" href="https://www.itmedia.co.jp/css/ee/article.css?202208011700" type="text/css" media="all">

<!-- /globalStylesheet -->

<div class="lpanIn">


<script type="text/javascript">
var str = document.title.replace(/\<\!\-\-EDIT START\-\-\>/g,'').replace(/\<\!\-\-EDIT END\-\-\>/g,'').replace(' - EE Times Japan','');
str = cutString(str,50);
document.write(str);
</script>

</div>
</div>
</div>
</div>
</div>

</div>


<div id="masterContents"><div id="globalContents">
<div id="masterMain">

<!---->


<div id="tmplNews" class="tmplArticle"><div id="tmplNewsIn" class="tmplArticleIn">

	


<!--EDIT START-->
<!--EDIT END-->



<div id="cmsTitle"><div class="inner">
<h1 class="title"><span class="title__maintext">老後を生き残る「戦略としての信仰」は存在するのか</span><i class="title__delimiter">:</i><i class="title__subtitle">「お金に愛されないエンジニア」のための新行動論(6)</i><span class="title__pagenumber">(4/12 ページ)</span></h1>
</div></div>
<div id="tmplMark"></div>


<div id="cmsAbstract"><div class="inner"><h2></h2></div></div>


<!---->

<div id="cmsByline"></div>
<div id="cmsByline"></div>


<div id="cmsByline"><div class="inner" id="byline"><b>[</b><b>]</b></div></div>
<div id="cmsByline"><div class="inner" id="byline"><b>[</b>江端智一,<b>EE Times Japan]</b></div></div>



<!-- cmsHoleBodyWrapStart -->
<div id="cmsBody"><div class="inner">

<script>
(function(){
	var d = document;
	var date = d.getElementById('cmsDate');
	var type = d.getElementById('cmsType');
	var abstract = d.getElementById('cmsAbstract');
	var byline = d.getElementById('cmsByline');
	// 位置を移動
	byline.parentNode.insertBefore(date,byline);
	// 要素を削除
	type.parentNode.removeChild(type);
	abstract.parentNode.removeChild(abstract);
})();
</script>



<link rel="stylesheet" href="https://www.itmedia.co.jp/css/socialbutton.css?202001221022">
<script>
var msbBtnLoadScript = [];
</script>
<script src="https://eetimes.itmedia.co.jp/js/socialbutton.js?202111161930"></script>
<div id="masterSocialbuttonTop" class="masterSocialbutton"><div class="msbOut" id="msbTopOut"></div></div>




<!-- BCP Text -->


<div id="cmsMark"><!-- null for itmedia-->
</div>
<!-- cmsBodyCtrlTop -->
<div class="ctrl">
<span id="prev"><a href="news047_3.html">前のページへ</a></span>
<span id="numb"><a href="news047.html">1</a>|<a href="news047_2.html">2</a>|<a href="news047_3.html">3</a>|<strong>4</strong>|<a href="news047_5.html">5</a>|<a href="news047_6.html">6</a>|<a href="news047_7.html">7</a>|<a href="news047_8.html">8</a>|<a href="news047_9.html">9</a>|<a href="news047_10.html">10</a>|<a href="news047_11.html">11</a>|<a href="news047_12.html">12</a></span>
<span id="next"><a href="news047_5.html">次のページへ</a></span>
</div>

<!-- cmsBodyMainStart -->
<!-- cxenseparse_start -->
<div class="subscription">
<a name="point2"></a>
<h4>私(江端)がカルト宗教(江端教)の教祖になった件</h4>
<p> さて、キリスト教系のカルト宗教団体の多くは、キリスト教の根幹とも言える、この"原罪"ストーリーに、壮大なラクガキ・・・もとい、上書きを施します。これらのカルト宗教に見られる「上書き」パターンには以下のようなものがあります(というか、私が知る限り、『これしかない』という感じです)。</p>
<p> カルト宗教団体や、その教祖のイメージをしやすくするために、『<strong>私(江端)がカルト宗教(江端教)の教祖になった件</strong>』、という架空の話で説明を行います。</p>
<p> まず、教祖である私は、原作である失楽園での、「アダムとイブによるリンゴ食」のストーリーを、ヘビ(ルシファー)とイブの性交(SEX)と、さらに、イブとアダムとの性交(SEX)という、「ヘビとアダムとイヴの3P(Three persons SEX)」が実施された、という「上書き」を施します。これによって、精神的または肉体的な純潔が犯された(堕落した)という概念を挿入しました。</p>
<p> 次に、私は、『イエス・キリストの救済は、万能ではなかった』、という「上書き」を加えます ―― といっても、イエス・キリストの働きを全面的に否定するのではなく、精神的または肉体的な純潔という2つの純潔のうち、<strong>「精神面」だけは解決してくれた</strong>、というストーリーに改ざんします。</p>
<p> イエス・キリストを全面否定すると、信者が集まりにくくなると考えたので、ここは、イエス・キリストを活用する方向でストーリーを作りました。</p>
<p> しかし、<strong>肉体的な純潔は、まだ回復されていない</strong>、という課題を残しつつ、ついに、ここに私(江端)が登場するのです。</p>
<!--CAP-->
<div id="col600c"><a name="mm220831_money02_w570.jpg"></a><img src="https://image.itmedia.co.jp/ee/articles/2208/31/mm220831_money02_w570.jpg" width="570" height="981"></div>
<!--CAPEND-->
<p> <strong>“メシア the final” こそが、この私江端智一、偉大なる江端、『<span class="cmsFontsize1">エバ・カンターレ</span>』です。</strong></p>
<p> 以上をまとめますと ―― イエス・キリスト製ワクチンは、”魂(スピリッツ)の原罪”には効果はあったが、<strong>肉体(フィジカル)の原罪には、その効力が及んでいない</strong>、という、<strong>壮大なシナリオ変更をぶっこむ</strong>のです。この肉体版”原罪”のワクチンとなるのが、この私、エバ・カンターレなのです。</p>
<p> 私(江端)は、『<strong>イエス・キリストは完全な”原罪”ウイルス向けワクチンを提供していない</strong>』と、キリスト教に対する強烈なディスリスペクトをかました上で、<strong>自分(江端)こそが最終救済者(メシア the final)であると言い切ります</strong>。もちろん、これは、世界中のキリスト教徒全てにケンカを売る行為です<sup>*)</sup>。</p>
<p><span class="cmsFontsize-1">*)ただ、世界中のカルトの教祖のほぼ全てが、「自分こそが”メシアthe final”」と主張しているので、逆に、「ありふれている」と言えるかもしれませんが。</span></p>
<!--CAP-->
<div id="col600c"><a name="mm220831_money02a_w570.jpg"></a><img src="https://image.itmedia.co.jp/ee/articles/2208/31/mm220831_money02a_w570.jpg" width="570" height="428"></div>
<!--CAPEND-->
<p> 江端教の目的が、肉体向け”原罪”に対抗するワクチン接種行為と考えるわけです。</p>
<p> しかし、肉体向け"原罪"の消滅は、mRNAのようなワクチン接種では実現できません。そこで、私は、AI技術の一つである、遺伝的アルゴリズム<sup>*)</sup>のアプローチ、すなわち、人為的なエリート製造戦略で、この問題の解決を試みます。</p>
<p><span class="cmsFontsize-1">*関連記事:「<A HREF="https://eetimes.itmedia.co.jp/ee/articles/1701/31/news031.html" target="_blank">抹殺する人工知能 ~ 生存競争と自然淘汰で、最適解にたどりつく</A>」</span></p>
<p> つまり、<strong>肉体向け”原罪”をうまいこと消滅できる組み合わせのカップルを作る</strong>のです。『そんなこと、どうやってできるのか』などとは、考えてはなりません。</p>
<p> 私はたった一人で、誰にも相談せずに、この組み合わせをコンピュータと直感でデザインするのです。しかし、1組、2組程度をちんたらやっていたら、人類の救済などできません。</p>
<p> ですので、カップルを、数千から数万単位で同時に量産するのです。その上、私は、男女の顔写真と全身写真”だけ”で、<A HREF="https://eetimes.itmedia.co.jp/ee/articles/1804/27/news093_2.html" target="_blank">ニューラルネットワーク</A>と、<A HREF="https://eetimes.itmedia.co.jp/ee/articles/1711/30/news019_2.html" target="_blank">最適化アルゴリズム</A>を使ってマッチングさせます。</p>
<p> 私はコンピュータを使った組み合わせ問題のエキスパートでもありますので、この問題の困難性を完璧に理解しています。恐らく、完璧な量子コンピュータが開発されたとしても、この組み合わせを完成させるのには、宇宙の年齢を、宇宙の年齢分繰り返しても、全然足りないくらいの時間が必要です<sup>*)</sup>。</p>
<p><span class="cmsFontsize-1">*)「NP困難問題」でググってみてください。</span></p>
<p> しかし、忘れてなりません。私は、最終救済者、”メシア the final”なのです。<strong>私のコンピュータの中には、神が常駐しており、私には、計算中のコンピュータから、常に神の声が聞こえてくるのです</strong>。</p>
<p> このように、この私は、肉体版”原罪”を消滅させうる超高度な医学的(遺伝子学)組み合わせを、写真だけを使って、膨大(という言葉では語れないくらいの膨大)な数でデザインします。</p>
<p> この程度のこと、”メシア the final”である私にとっては、ピース・オブ・ケーキ(朝飯前)です。</p>
<p> 人類は、最終救済のためであれば、自由恋愛やら、出会いの場やら、合コンやら、結婚相談所やら、そのような些事(さじ)に関わっている暇はありません。</p>
<p> 神の声を聞くことのできる唯一のメシアである私は、堕落した近代の<strong>自由恋愛結婚観を完全否定</strong>して、現実世界において、豪快かつ壮大な数の遺伝的アルゴリズムを地上で実現しなければならないという使命があるのです ―― つまり、一斉集団結婚です<sup>*)</sup>。</p>
<p><span class="cmsFontsize-1">*)純潔を守るという名目の、「村の中のみで閉じた結婚制度」、あるいは、「一夫多妻」「一妻多夫」などのような形態でも同じ効果を得られます。</span></p>
<p> すなわち、江端教においては、肉体版"原罪"を消滅させうる手段として、一斉集団結婚は、絶対に避けて通ることができない一大イベントなのです。</p>
<div id="notice"><a href="news047_5.html">「江端原理」通称”エバタ・プリンシプル”を説明する</a></div>
</div><!-- subscription end -->

<!-- cxenseparse_end -->

<!-- cmsBodyMainEnd -->

<!-- cmsBodyRelated -->
<div class="ctrl">
<span id="prev"><a href="news047_3.html">前のページへ</a></span>
<span id="numb"><a href="news047.html">1</a>|<a href="news047_2.html">2</a>|<a href="news047_3.html">3</a>|<strong>4</strong>|<a href="news047_5.html">5</a>|<a href="news047_6.html">6</a>|<a href="news047_7.html">7</a>|<a href="news047_8.html">8</a>|<a href="news047_9.html">9</a>|<a href="news047_10.html">10</a>|<a href="news047_11.html">11</a>|<a href="news047_12.html">12</a></span>
<span id="next"><a href="news047_5.html">次のページへ</a></span>
</div>

2022/09,江端さんの忘備録

アウトカムやら、ロジックモデル、ロジックツリーなど、毎日新しい用語を覚えさせられる日々を送っております。

Every day I am forced to learn new terms such as outcome, logic model, logic tree, and so on.

興味のある方はググって頂ければ結構ですが、これらは、私が見る限り、すでに存在していた考え方の「再定義」に過ぎません。

If you are interested, you can Google it, but as far as I can tell, these are just "redefinitions" of ideas that already existed.

これらの用語の意味を、現存する技術に落し込んで考えたいエンジニアの方には ――

For engineers who want to understand the mieaning of terms by matching existing technologies

『ベイジアンネットワーク』が、てっとり早いかなぁ、と思っています。

I think that "Bayesian Network" would be the quickest way to understand them.

私は、

I think that

『「ロジックモデル」や「ロジックツリー」とは、つまるところ、ベイジアンネットワークの設計プロセスだろ?』

"Logic models and logic trees are, after all, the design process of a Bayesian network, right?"

と思ってます。

本件に関して、ご見識のある方からのコメント歓迎致します。

I welcome comments from those who have insight on this matter.

-----

さて、その覚えなければならない用語の一つとして、最近、「EBPM」なるものを、取り扱っています。

Well, recently I use "EBPM" as one of terms which I have to understand.

EBPMとは、エビデンス・ベースト・ポリシー・メイキング、証拠に基づく政策立案というものです。

EBPM means "evidence-based policy making".

"EBPM"でググって頂けると分かることですが、『劇的につまらない話』が、わんさか登場してきます。

If you google "EBPM," you will find that a lot of "dramatically boring stories" will appear.

加えて、「これまでの政策って、EBPMで動いていなかったのか?」と、逆に驚いてしまうくらいです。

In addition, I was really suprised to know that "Has our goverment not worked by EBPM yet?"

-----

現時点で、EBPMに関する、もっとも分かりやすい解説の一つが、こちらのYouTubeのビデオクリップです。

At this time, one of the most comprehensive explanations of EBPM is this YouTube video clip.

このプレゼンの結論の

The conclusion of this presentation

「EBPMは今は忘れろ。まずは、現場のデジタル化だ」

"Forget EBPM for now. First, we need to digitize the field."

と、

and

「デジタル傭兵部隊ヘッジファンド」

"Digital Mercenary Force Hedge Fund."

の話が、私の胸を打ちました。

made me move.

2022/09,江端さんの技術メモ

/*

golangで時刻(time)情報を生成して、その情報をpostgresqlに格納して、さらに読み出す実験

テスト用DB環境の作り方

C:\Users\ebata>psql -U postgres -p 15432
Password for user postgres:
psql (13.4, server 12.5 (Debian 12.5-1.pgdg100+1))
Type "help" for help.

postgres=# create database agent_db;
CREATE DATABASE

postgres-# \c agent_db
psql (13.4, server 12.5 (Debian 12.5-1.pgdg100+1))
You are now connected to database "agent_db" as user "postgres".

agent_db-# create table LocMessage(
agent_db(# ID     int,
agent_db(# dt     timestamp,
agent_db(# Lat    double precision,
agent_db(# Lng    double precision,
agent_db(# TYPE   varchar(10),
agent_db(# POPUP  int
agent_db(# );

agent_db=# \dt
           List of relations
 Schema |    Name    | Type  |  Owner
--------+------------+-------+----------
 public | locmessage | table | postgres
(1 row)


agent_db=# select * from locmessage;
 id | dt | lat | lng | type | popup
----+----+-----+-----+------+-------
(0 rows)

と、まあ、こんな感じ

*/

package main

import (
	"database/sql"
	"fmt"
	"log"
	"time"

	_ "github.com/lib/pq" // ←これを追記
)

func main() {

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

	ins, err := db.Prepare("insert into locmessage(id,dt,lat,lng,type,popup) VALUES($1,$2,$3,$4,$5,$6)")
	if err != nil {
		log.Fatal("db.Exec Error: ", err)
	}

	a := 1
	b := time.Now()
	c := 139.02
	d := 38.02
	e := 1
	f := 1

	ins.Exec(a, b, c, d, e, f)

	///// 書き込みここまで
	// 書き込まれたデータはこんな感じになっている (2回プログラムを実施)
	/*
		agent_db=# select * from locmessage;
		 id |             dt             |  lat   |  lng  | type | popup
		----+----------------------------+--------+-------+------+-------
		  1 | 2022-09-15 23:54:36.877274 | 139.02 | 38.02 | 1    |     1
		  1 | 2022-09-15 23:55:16.574776 | 139.02 | 38.02 | 1    |     1
		(2 rows)
	*/
	// さて、このDBからどうやって、時間情報を取り出すか?

	rows, err := db.Query("select dt from locmessage")
	if err != nil {
		log.Fatal(err)
	}
	defer rows.Close()

	var dt time.Time

	for rows.Next() {
		if err := rows.Scan(&dt); err != nil {
			fmt.Println(err)
		}

		fmt.Println(dt)

		// 出力結果が、こんな感じになって、ちょっと変 "+0000 +0000"は、いらん
		/*
			2022-09-15 23:54:36.877274 +0000 +0000
			2022-09-15 23:55:16.574776 +0000 +0000
			2022-09-16 00:06:18.870051 +0000 +0000
			2022-09-16 00:12:51.251972 +0000 +0000
			.....
			2022-09-16 13:57:46.704896 +0000 +0000
		*/

		// こんな感じにすれば、整数などでデータ取り出せる
		fmt.Println(dt.Date())   // e.g 2022 September 16
		fmt.Println(dt.Clock())  // 13 57 46
		fmt.Println(dt.Minute()) // 57
		fmt.Println(dt.Hour())   // 13
		fmt.Println(dt.Day())    // 16

	}

}

こんだけのことがやりたかっただけなのに、"golang" "postgresql", "timestamp", "time.Time"で検索しても、ドンピシャの情報が出てこないんですよ、不思議なことに。

2022/09,江端さんの技術メモ

dis: 0.2839182387773051
dis: 0.09663299157559467
dis: 1.2640838214822172
dis: 0.2725675930110564
fatal error: concurrent map iteration and map write
goroutine 26 [running]:
runtime.throw({0x432b38, 0xc000292000})
        c:/go/src/runtime/panic.go:1198 +0x76 fp=0xc00033d858 sp=0xc00033d828 pc=0x196416
runtime.mapiternext(0x48a620)
        c:/go/src/runtime/map.go:858 +0x4eb fp=0xc00033d8c8 sp=0xc00033d858 pc=0x16f8cb
main.echo3({0x48f558, 0xc00013e2a0}, 0x0)
---
さて、やっつけますか。
「mapの競合状態のはなし」のページを参考にさせて頂き、新しく作ったmapが悪さをしているとアタリをつけました。
で、当初、sync.Mutexでロックしていたのですが、デッドロックが発生してしまいました。
そこで、sync.RWMutexに変更したところ、デッドロックが発生しなくなりました。
―― というのは気のせいのようで、RWMutex でも メソッドにLock Unlockを使えば、Mutexと同じらしいので、たまたま偶然だったようです。
RWMutexのウリは、
RLock : 読み取り用のロック。RLock同士はブロックせず、Lockのみがブロックされる。解除時は RUnlockを使う
Lock : Mutexと同じロック。RLock, Lock双方をブロックする。
のようです。今回は、読み出し中に、書き込みや削除処理が走ることがあったのですが、読み出し場所が一箇所だけだったので、普通に、Lock, Unlockを使用することにしました。
これでサーバがダウンすることはなくなりました。
以上

2022/09,江端さんの忘備録

「GO言語でクラスっぽいことをする」をレビューする

こちらにも書きましたが、今回、初めて、HP、AP、MPの意味をきちんと調べてみました。

As I wrote in this page, this time, I study the meaning of terms of "HP", "AP", "MP".

HP:ヒットポイント: ゲームにおいてキャラの体力や生命力を示すステータスの一つ

HP: Hit Points: A statistic that indicates a character's strength or vitality in a game.

AP:アタックポイント: ゲームにおいてキャラの行動力などを示すステータスの一つ

AP: Attack Points: A status that indicates a character's ability to take action, etc.

MP:マジックポイント: ゲームにおいてキャラの魔法や呪文を使う力を示すステータスの一つ

MP: Magic Point: A status that indicates a character's ability to use magic or spells in a game.

となっておりました。

当初、私は、「ステータス(地位)」という言葉に違和感を感じました。

Initially, I felt uncomfortable with the term 'status'.

ステータスというと、もっと静的なもの、例えば、社会的地位をイメージしていました。

Because I thought that the word of 'status' is something static, like social status.

でも、ちょっと調べてみたら、

However, I did a little digging more,

『コンピューターゲーム、とくにオンラインゲームやロールプレーイングゲームに登場するキャラクターの状態。能力、経験値、所持する武器などを指す』

"The state of a character in computer games, especially online games and role-playing games like, capabilities, experience, and weapons possessed by the character"

という意味で、すでに、ゲームの世界に、この用語「ステータス」がデフォルトとなっていることを知りました。

As the above meaning, I know that the word of 'status' has already been default in the game word.

-----

私、これまで、コンピュータで取り扱える「人間エージェント」の設計と開発をやってきました。

I have been designing and developing "human agents" that can be handled by computers.

そして、それらのエージェントを、主に街の中での住民の移動やら、交通機関の利用などのシミュレーションで使っています。

And I use these agents mainly in simulating the movement of residents and transportation in the city.

私がエージェントを設計すると、「住所」「年齢」「性別」「職業」のような『静的なもの』から着手することになります。

When I design an agent, I start with 'static' things like 'address', 'age', 'gender', and 'occupation'.

-----

で、今回、私のエージェントに、HP、AP、MPのステータスを入れたらどうなるかなぁ、と考えてみたのですが、

So, I wondered what would happen if I put the HP, AP, and MP stats into my agent this time.

―― 『住民が、バス停や駅、または、バスや電車の中で、乗車や座席を巡ってバトルを始める』というシナリオが必要になる

"I need a scenario where 'residents start battling over boarding and seating at bus stops, train stations, or on buses and trains"

なぁ、と思いました。

should be needed.

この辺が、ゲームと、私のシミュレーションの、決定的な違いかなぁ、と考えています。

I think this is the crucial difference between the game and my simulation.

-----

しかし、別の分野、例えば、「学校におけるいじめシミュレーション」「オフィスにおけるパワハラシミュレーション」では、使えるような気がします。

However, I feel that it could be used in other areas, e.g., "bullying simulation in schools" or "power harassment simulation in offices",

こんなのですね。

like this one.

2022/09,江端さんの技術メモ

C言語によるファジィ(Fuzzy)推論コード

をGo言語に移植してみました。

で、できるだけ、

「GO言語でクラスっぽいことをする」をレビューする

に近づけてみました。

コメントのPrint分は、C++のを残しています(面倒だったので)。あとenum型がないので、テキトーに文字列を使うことにしました。

以前のコードには、豪快なバグがありましたので、ソックリ差し替えします。

設定条件は以下の通りです(テーブルの内容は、負荷量です)

package main

import (
	"fmt"
	"os"
)

func max_2(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func min_2(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

type condition_MF3 struct { // condition_MF3の基底クラス
	center  float64
	width   float64
	express string
}

func new_condition_MF3(_center, _width float64, _express string) *condition_MF3 {
	c3 := new(condition_MF3)
	c3.center = _center
	c3.width = _width
	c3.express = _express
	return c3
}

// 前件部メンバーシップ関数(山3つ)クラス
func (c3 *condition_MF3) func_X(_x float64) float64 {
	// x,yは、メンバーシップ関数上の座標を示す
	x := _x
	y := 0.0 // yの値は、必ず0以上1以下になる

	if c3.express == "LESS" {
		if x <= c3.center-c3.width {
			y = 1.0
		} else if x <= c3.center {
			y = -1.0 / c3.width * (x - c3.center)
		} else {
			y = 0.0
		}
	} else if c3.express == "COMMON" {
		if x <= c3.center-c3.width {
			y = 0.0
		} else if x <= c3.center {
			y = 1.0/c3.width*(x-c3.center) + 1.0
		} else if x <= c3.center+c3.width {
			y = -1.0/c3.width*(x-c3.center) + 1.0
		} else {
			y = 0.0
		}
	} else if c3.express == "MORE" {
		if x <= c3.center {
			y = 0.0
		} else if x <= c3.center+c3.width {
			y = 1.0 / c3.width * (x - c3.center)
		} else {
			y = 1.0
		}
	} else {
		fmt.Println("MF3: wrong expression")
		os.Exit(1)
	}
	return y
}

type condition_MF5 struct { // condition_MF5の基底クラス
	center  float64
	width   float64
	express string
}

func new_condition_MF5(_center, _width float64, _express string) *condition_MF5 {
	c5 := new(condition_MF5)
	c5.center = _center
	c5.width = _width
	c5.express = _express
	return c5
}

func (c5 *condition_MF5) func_X(_x float64) float64 {
	// 前件部メンバーシップ関数(山5つ)クラス
	// x,yは、メンバーシップ関数上の座標を示す
	x := _x
	y := 0.0 // yの値は、必ず0以上1以下になる

	if c5.express == "LESSLESS" {
		if x <= c5.center-2.0*c5.width {
			y = 1.0
		} else if x <= c5.center-c5.width {
			y = -1.0/c5.width*(x-(c5.center-2.0*c5.width)) + 1.0
		} else {
			y = 0.0
		}
	} else if c5.express == "LESS" {
		if x <= c5.center-2.0*c5.width {
			y = 0.0
		} else if x <= c5.center-c5.width {
			y = 1.0/c5.width*(x-(c5.center-c5.width)) + 1.0
		} else if x <= c5.center {
			y = -1.0/c5.width*(x-(c5.center-c5.width)) + 1.0
		} else {
			y = 0.0
		}
	} else if c5.express == "COMMON" {
		if x <= c5.center-c5.width {
			y = 0.0
		} else if x <= c5.center {
			y = 1.0/c5.width*(x-c5.center) + 1.0
		} else if x <= c5.center+c5.width {
			y = -1.0/c5.width*(x-c5.center) + 1.0
		} else {
			y = 0.0
		}
	} else if c5.express == "MORE" {
		if x <= c5.center {
			y = 0.0
		} else if x <= c5.center+c5.width {
			y = 1.0/c5.width*(x-(c5.center+c5.width)) + 1.0
		} else if x <= c5.center+2.0*c5.width {
			y = -1.0/c5.width*(x-(c5.center+c5.width)) + 1.0
		} else {
			y = 0.0
		}
	} else if c5.express == "MOREMORE" {
		if x <= c5.center+c5.width {
			y = 0.0
		} else if x <= c5.center+2.0*c5.width {
			y = 1.0/c5.width*(x-(c5.center+2.0*c5.width)) + 1.0
		} else {
			y = 1.0
		}
	} else {
		fmt.Println("MF5 func_X(): wrong expression")
		os.Exit(1)
	}

	return y
}

/////////////////////////////

type action_MF5 struct { // condition_MF5の基底クラス
	center  float64
	width   float64
	express string
	x       float64
	y       float64
}

func new_action_MF5(_center, _width float64, _express string) *action_MF5 {
	a5 := new(action_MF5)
	a5.center = _center
	a5.width = _width
	a5.express = _express

	if a5.express == "LESSLESS" {
		a5.x = a5.center - 2.0*a5.width
	} else if a5.express == "LESS" {
		a5.x = a5.center - a5.width
	} else if a5.express == "COMMON" {
		a5.x = a5.center
	} else if a5.express == "MORE" {
		a5.x = a5.center + a5.width
	} else if a5.express == "MOREMORE" {
		a5.x = a5.center + 2.0*a5.width
	} else {
		fmt.Println("new_action_MF5: wrong scale expression")
		os.Exit(-1)
	}

	a5.y = 0.0

	return a5
}

// 後件部メンバーシップ関数(山3つ)クラス
func (a5 *action_MF5) func_Y() float64 {
	// x,yは、メンバーシップ関数上の座標を示す

	return a5.y
}

func (a5 *action_MF5) func_Max(b float64) {
	a5.y = max_2(b, a5.y)
}

func (a5 *action_MF5) func_X() float64 {
	return a5.x
}

func complain_reasoning(dis, age float64) float64 {

	// Walking(前件部)
	Walk_Less := new_condition_MF3(1.4, 0.4, "LESS")
	Walk_Common := new_condition_MF3(1.4, 0.4, "COMMON")
	Walk_More := new_condition_MF3(1.4, 0.4, "MORE")

	// Age(前件部)
	Age_LessLess := new_condition_MF5(42, 15, "LESSLESS")
	Age_Less := new_condition_MF5(42, 15, "LESS")
	Age_Common := new_condition_MF5(42, 15, "COMMON") // 中央が 42歳
	Age_More := new_condition_MF5(42, 15, "MORE")
	Age_MoreMore := new_condition_MF5(42, 15, "MOREMORE")

	// Complain(後件部)
	Complain_LessLess := new_action_MF5(0.5, 0.25, "LESSLESS") // 不満の中央値が0.5   0.0/0.25/0.50/0.75/1.00 の5段階

	Complain_Less := new_action_MF5(0.5, 0.25, "LESS")
	Complain_Common := new_action_MF5(0.5, 0.25, "COMMON")
	Complain_More := new_action_MF5(0.5, 0.25, "MORE")
	Complain_MoreMore := new_action_MF5(0.5, 0.25, "MOREMORE")

	// [ルール00] 歩行距離:少0 年令:子供0
	Rule00 := min_2(Walk_Less.func_X(dis), Age_LessLess.func_X(age))
	Complain_LessLess.func_Max(Rule00) // 後件部は上書きされていく
	//fmt.Println("Rule00", Rule00)

	// [ルール01] 歩行距離:少0 年令:若年1
	Rule01 := min_2(Walk_Less.func_X(dis), Age_Less.func_X(age))
	Complain_LessLess.func_Max(Rule01) // 後件部は上書きされていく
	//fmt.Println("Rule01", Rule01)

	// [ルール02] 歩行距離:少0 年令:壮年2
	Rule02 := min_2(Walk_Less.func_X(dis), Age_Common.func_X(age))
	Complain_Common.func_Max(Rule02) // 後件部は上書きされていく
	//fmt.Println("Rule02", Rule02)

	// [ルール03] 歩行距離:少0 年令:高齢3
	Rule03 := min_2(Walk_Less.func_X(dis), Age_More.func_X(age))
	Complain_Common.func_Max(Rule03) // 後件部は上書きされていく
	//fmt.Println("Rule03", Rule03)

	// [ルール04] 歩行距離:少0 年令:老齢4
	Rule04 := min_2(Walk_Less.func_X(dis), Age_MoreMore.func_X(age))
	Complain_More.func_Max(Rule04) // 後件部は上書きされていく
	//fmt.Println("Rule04", Rule04)

	// [ルール10] 歩行距離:普通1 年令:子供0
	Rule10 := min_2(Walk_Common.func_X(dis), Age_LessLess.func_X(age))
	Complain_LessLess.func_Max(Rule10) // 後件部は上書きされていく
	//fmt.Println("Rule10", Rule10)

	// [ルール11] 歩行距離:普通1 年令:若年1
	Rule11 := min_2(Walk_Common.func_X(dis), Age_Less.func_X(age))
	Complain_Less.func_Max(Rule11) // 後件部は上書きされていく
	//fmt.Println("Rule11", Rule11)

	// [ルール12] 歩行距離:普通1 年令:壮年2
	Rule12 := min_2(Walk_Common.func_X(dis), Age_Common.func_X(age))
	Complain_Common.func_Max(Rule12) // 後件部は上書きされていく
	//fmt.Println("Rule12", Rule12)

	// [ルール13] 歩行距離:普通1 年令:高齢3
	Rule13 := min_2(Walk_Common.func_X(dis), Age_More.func_X(age))
	Complain_More.func_Max(Rule13) // 後件部は上書きされていく
	//fmt.Println("Rule13", Rule13)

	// [ルール14] 歩行距離:普通1 年令:老齢4
	Rule14 := min_2(Walk_Common.func_X(dis), Age_MoreMore.func_X(age))
	Complain_MoreMore.func_Max(Rule14) // 後件部は上書きされていく
	//fmt.Println("Rule14", Rule14)

	// [ルール20] 歩行距離:多2 年令:こども0
	Rule20 := min_2(Walk_More.func_X(dis), Age_LessLess.func_X(age))
	Complain_Less.func_Max(Rule20) // 後件部は上書きされていく
	//fmt.Println("Rule20", Rule20)

	// [ルール21] 歩行距離:多2 年令:若年1
	Rule21 := min_2(Walk_More.func_X(dis), Age_Less.func_X(age))
	Complain_Common.func_Max(Rule21) // 後件部は上書きされていく
	//fmt.Println("Rule21", Rule21)

	// [ルール22] 歩行距離:多2 年令:壮年2
	Rule22 := min_2(Walk_More.func_X(dis), Age_Common.func_X(age))
	Complain_More.func_Max(Rule22) // 後件部は上書きされていく
	//fmt.Println("Rule22", Rule22)

	// [ルール23] 歩行距離:多2 年令:高齢3
	Rule23 := min_2(Walk_More.func_X(dis), Age_More.func_X(age))
	Complain_MoreMore.func_Max(Rule23) // 後件部は上書きされていく
	//fmt.Println("Rule23", Rule23)

	// [ルール24] 歩行距離:多2 年令:老齢4
	Rule24 := min_2(Walk_More.func_X(dis), Age_MoreMore.func_X(age))
	Complain_MoreMore.func_Max(Rule24) // 後件部は上書きされていく
	//fmt.Println("Rule24", Rule24)

	// 推論計算
	numerator :=
		Complain_LessLess.func_X()*Complain_LessLess.func_Y() +
			Complain_Less.func_X()*Complain_Less.func_Y() +
			Complain_Common.func_X()*Complain_Common.func_Y() +
			Complain_More.func_X()*Complain_More.func_Y() +
			Complain_MoreMore.func_X()*Complain_MoreMore.func_Y()

	denominator :=
		Complain_LessLess.func_Y() +
			Complain_Less.func_Y() +
			Complain_Common.func_Y() +
			Complain_More.func_Y() +
			Complain_MoreMore.func_Y()

	complain := numerator / denominator

	return complain

}

2022/09,江端さんの技術メモ

Goにはクラスの概念がありません。

C++で作ってきたプログラムをGoに移植しているのですが、クラスで記載した部分を上手いこと使い回したくても、それができなくて困っていました。

で、

GO言語でクラスっぽいことをする

という記事を見つけて、これを使って勉強させて頂いていますが、困ったことがあります。

プログラムの中の変数の意味が分からない ―― HPとか、MPとか、APは、アニメ(多分ゲームも?)の中では頻繁に登場するのですが、私は何の略号か分からなかったので、サンプルプログラムの意味が読み解けませんでした。

そこで、上記記事に記載されていたプログラムに、そのまま、私の為に、コメントを付けさせて頂きました。

package main

import (
	"fmt"
)

const line = "--------------------"

func main() {
	wiz := newWizard("魔法少女", 10, 10, 5)
	war := newWarrior("+‡†狂戦士†‡+", 10, 15, 30)

	fmt.Println(wiz.hello())
	fmt.Println(war.hello())

	fmt.Println(line)
	fmt.Println(wiz.attack())
	fmt.Println(war.attack())

	fmt.Println(line)
	fmt.Println(wiz.magic())
	fmt.Println(war.attack())
}

type human struct { // "人間"という基底クラス
	name string
	hp   int
	ap   int
}

func (h *human) init(name string, hp, ap int) { // "人間"という基底クラスのコンストラクタ(3つの初期値を入れていることに注意))
	h.name = name // 名前
	h.hp = hp     // ヒットポイント: ゲームにおいてキャラの体力や生命力を示すステータスの一つ
	h.ap = ap     // アタックポイント: ゲームにおいてキャラの行動力などを示すステータスの一つ
}

func (h *human) hello() string { // "人間"という基底クラスのメソッド1
	return fmt.Sprintf("こんにちは、私は%sです。", h.name)
}

func (h *human) attack() string { // "人間"という基底クラスのメソッド2
	return fmt.Sprintf("%sの攻撃!%dのダメージ!", h.name, h.ap)
}

type wizard struct { // "魔法使い"というクラス
	human     // "人間の属性"を手動挿入
	mp    int // マジックポイント: ゲームにおいてキャラの魔法や呪文を使う力を示すステータスの一つ
}

func newWizard(name string, hp, ap, mp int) *wizard { // "魔法使い"クラスのコンストラクタ(4つの初期値を入れていることに注意))
	w := new(wizard)     // "魔法使い"の実体生成
	w.init(name, hp, ap) // "基底クラス"の属性値の設定
	w.mp = mp            // 新しい属性値の設定
	return w
}

func (w *wizard) magic() string {
	if w.mp <= 0 {
		return fmt.Sprintf("%sは力がでない", w.name)
	}
	w.mp -= 1
	return fmt.Sprintf("%sは魔法を使った!30のダメージ!", w.name)
}

type warrior struct {
	human // "人間の属性"のみを手動挿入
}

func newWarrior(name string, hp, ap, mp int) *warrior {
	w := new(warrior)
	w.init(name, hp, ap)
	// mpは使わない? Warrior(戦士)は、マジックポイントを持たないものなの?
	return w
}

func (w *warrior) attack() string {
	return fmt.Sprintf("%sの攻撃!%dのダメージ!", w.name, w.ap*2)
}

なるほど、変数の意味が分かれば、プログラムの趣旨が読み取れました ―― 加えて、アニメの中の台詞も理解できるようになり、一石二鳥でした。
ゲームをやっている人であれば、「今更なこと」だったんだろうな、と思っています。


とほほのGo言語入門 構造体(struct)

を読んでいたら、構造体(struct)でクラスと同じことができることが分かりました。

また、インタフェース(interface)を使えばポリモーフィズムもできるみたいでした。

しかも、コンストラクタとかデストラクタとか、面倒なものもを入れていないという点も好印象です。

Golangの設計者、よく分かってるじゃん!』と、絶賛賞賛中です。

2022/09,江端さんの忘備録

私は、「撤収」が、超高度な技術であることを知っています。

I know that "Withdrawal" is a super advanced technology.

"技術"に留まらず、"哲学"である、とすら思っています。

I believe that it is not only a "technique" but also a "philosophy".

そのようなマインドを持っている私にとって、

For me, with that kind of mindset,

■NHK「解体キングダム」

- NHK program "Kaitai Kingdom"

■Nスペ「廃炉への道」

- NKS Special "The Road to Decommissioning."

は、手に汗握るスリルに満ちた貴重なコンテンツです。

are valuable contents full of thrills.

-----

我が国は、原爆被害、原発事故など、いわゆる「"核災害"先進国」です。

Japan is an advanced country in terms of nuclear disasters, including atomic bombings and nuclear accidents.

しかし、同時に、これらの不幸な災害は、我が国の"核"災害対策の技術を高めていると思います。

At the same time, however, I believe that these unfortunate disasters have enhanced our nation's "nuclear" disaster preparedness techniques.

私は、システム屋として、『事故を起こさないシステムなど、絶対的な意味において「ない」』という事実を知っています。

As a systems engineer, I know for a fact that 'there is no such thing as an accident-free system' in the absolute sense of the word.

ですから、これからも、世界中で、核の事故は続きます。

New "nuclear" accidents will continue to occur in the world.

なぜなら、当面の間、人類が「核」を手放せる目処がない以上、「核」の事故は必ず発生するからです。

This is because, as long as humanity has no prospect of giving up "nuclear" in the foreseeable future, nuclear accidents are bound to occur.

以下は、「原発事故発生"10億年に1回"とは、笑わせる」を図解したものです。

The following is an illustration of the "1 in a billion years" accident rate, which make me laugh.

米国(スリーマイル)、ソ連、あらためロシア(チェルノブイリ、改めチョルノービリ)、日本(福島)、と、これまで「大事故」と断定できるものは3回ありました。

There have been three major accidents in the United States (Three Mile), in Russia changed the Soviet Union(Chernobyl, and in Japan (Fukushima).

今度は、どこか?

"Where is the next?"

直感の域を出ませんが、国外であれば、我が国の近隣国がヤバい気がします。

It is just my imagination, I am concern that that our nearby countries will be in trouble.

-----

という訳で、解体や廃炉に特化した技術、さらには、それを日常生活から国家の政策にまで適用可能な、一般的思想(哲学)にまで高めた総合的な学問としての、

Therefore, not only as technologies for demolition and decommissioning a nuclear reactor, but also, as comprehensive study to be general thoughts (or philosophy) which apply for From everyday life to state policy, I will propose

『撤収学』

"Withdrawal Study"

の設立を提案したいと思います。

「XX大学工学部撤収学科」、とか、「XX大学経済学部撤収学科」、という称呼が一般的になって欲しいです。

I would like to see the term "XX University, Faculty of Engineering withdrawn" or "XX University, Faculty of Economics withdrawn" become more common.

2022/09,江端さんの忘備録

マッチョな体になって、女性にモテたい、という心理は、私の人生で、1ナノ秒も登場したことがありません。

上記を経て、「江端マッチョ化計画」・・・もとい、「江端介護向け身体改造計画」を進めております。

Through the above, I am proceeding with the "Ebata Machoization Plan"...or rather, the "Ebata Body Modification Plan as a caregiver".

観点は、以下のような感じです。

The viewpoints are as follows.

(0)外出(フィットネスセンターなど)が面倒くさい。

(0) Going out (e.g., to a fitness center) is a hassle.

(1)バーベルやダンベル等のごっついデバイスは、いずれ「漬物石」になる

(1) Burly devices such as barbells and dumbbells will eventually become "pickle stones".

(2)トレーニングマシンは、置く場所がない上に、とても高価。

(2) Training machines are very expensive as well as there is no place to put them.

(3)基本的に私が欲しいものは、腹筋運動や背筋運動を手伝ってくれる「補助」

(3) Basically what I want is an "assistant" to help me with abdominal and back exercises.

てなことを考えているうちに ―― 昨日衝動的に「買っちった」

I was thinking about it -- I impulsively "bought it" yesterday.

-----

鉄棒(懸垂)はルティーン化できたのですが、この腹筋・背筋運動を含めることができるか、今後の課題です。

I was able to lutinize the bars (pull-ups), but it remains to be seen if I can include these abdominal and back exercises.

2022/09,江端さんの技術メモ

Golangで "OpenError: sql: unknown driver "postgres" (forgotten import?) "で悩まされていました。

よく分かりませんが、"go.mod", "go.sum"とかをいじることなく

(1)ターミナルから、

go get github.com/lib/pq

として、

(2)import に

import (
   //  色々
    _ "github.com/lib/pq" // ←これを追記
)

で動きました。