未分類

In the sightseeing tour of Taiwan, we, whole family went to National CKS Memorial Hall.

私は、太平洋戦争末期の、台中のドタバタについては、興味があるので、とても楽しみにしてたのですが、滞在時間が ―― たったの30分。

Personally, I am very interested in a history of confusion between Taiwan and China in the of WW2. However the residence time was just half an hour.

I wanted to say

「3時間くれよ」

"Give me three hours"

というのは無理なんだろうなー、ということは分かっています。

But even I know that it might be impossible.

私のような人間の数は、少ないのだろうと、自分でも思いますから。

Persons like me, are few, I also think.

-----

中正紀念堂内での、長女との会話です。

In the hall, I talked to senior daughter.

江端:「このあたりの歴史については、受験勉強で詳しく勉強したのだろう?」

Ebata:"Did you study the history around this period for college exams?"

長女:「あんまり好きじゃないんだよね、この時代は」

Daughter:"I don't like this era and area."

江端:「ふーん、なんで」

Ebata:"Well why?"

長女:「いや、『四人組』とか『文革』とか、嫌な話がテンコ盛りでしょう?」

Daughter:" "Gang of Four" and "cultural revolution", there were a lot of bad stories in this era"

江端:「・・・は?」

Ebata:"What?"

長女:「いや、だから、"革命"を叫ぶ若者が国内を滅茶苦茶にしたという・・・」

Daughter: "Well, young people shouting" Revolution "made domestic messy ..."

江端:「それは『大陸(中華人民共和国)』の話だ! 『島(台湾)』の方では、文化大革命など起きていない!!」

Ebata:"That was a story of the" Continent (People's Republic of China)". Cultural Revolution has not occurred in Island (Taiwan) ! "

長女:「え? 台湾って、中国でしょう?」

Daughter: "W-Taiwan, is China isn't it?"

-----

まさか、こんなローカル(江端家内部)で、こんな形の、こんなコテコテの、

No way, in such a local (inside the Ebata's), I didn't expect to face this stereotypical

―― 「二つの中国」問題

"Two Chinese" issues

に、遭遇するとは思いませんでした。

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

golangを使った、postgresqlのinsertの方法

/*

こんな感じで、DBとTableを作りました

create database agent_db;

create table LocMessage(
	ID     int,
	Lat    double precision,
	Lng    double precision,
	TYPE   varchar(10),
	POPUP  int,
	RealId int,
	PersonState      int,
	BikeState        int,
	StartStationLat  double precision,
	StartStationLng  double precision,
	GoalStationLat   double precision,
	GoalStationLng   double precision,
	StartStationName varchar(40),
	GoalStationName  varchar(40)
);

ちなみに、全部小文字になるみたいですねえ。
agent_db=# select * from locmessage;
 id |  lat   |  lng  |   type   | popup | realid | personstate | bikestate | startstationlat | startstationlng | goalstationlat | goalstationlng | startstationname | goalstationname
----+--------+-------+----------+-------+--------+-------------+-----------+-----------------+-----------------+----------------+----------------+------------------+-----------------

*/

package main

import (
	"database/sql"
	"log"

	_ "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()

	//_, err = db.Exec("insert into locmessage(id,lat,lng,type,popup,realid,startstationlng ) VALUES(1, 139.0, 38.0, 'PERSON',1,1,222.222);")
	// _, err = db.Exec("insert into locmessage(id,lat) VALUES(a, b);")
	//ins, err := db.Prepare("insert into locmessage(id,lat,lng,type,popup,realid,startstationlng ) VALUES(?,?,?,?,?,?,?)")
	ins, err := db.Prepare("insert into locmessage(id,lat,lng,type,popup,realid,startstationlng ) VALUES($1,$2,$3,$4,$5,$6,$7)")
	if err != nil {
		log.Fatal("db.Exec Error: ", err)
	}

	a := 1
	b := 139.02
	c := 38.02
	dd := "Tomoichi"
	e := 1
	f := 1
	g := 333.333

	//ins.Exec("1", "139.0", "38.0", "BIKE", "1", "1", "222.222")
	//ins.Exec(1, 139.01, 38.01, "BIKE", 1, 1, 222.222)
	//ins.Exec(1, 139.0, 38.0, 1, 1, 1, 222.222)
	ins.Exec(a, b, c, dd, e, f, g)

}

とりあえず、これでデータベースの書き込みはできるみたい。

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

「オリジナル原稿購読希望」をされる方が、止まりません。

The "original manuscript subscription applicants" are coming even now.

―― 『とある宗教団体』を直撃する内容

今ごろになって、『もし、期待外れだったら、どうしよう』と心配になってきました。

By now, I'm starting to worry, 'What if it's a disappointment for them?'

私は、「この内容なら大丈夫」と勝手に判断したもので、そんなに、凄い内容とは思っていなかったものなのです。

I had judged on my own that the content would be OK. and I did not think it would be that great.

(但し、編集部は"削除"を、嫁さんは"休載"を、要求する内容ではあったようですが)

(However, it seems that the editorial department demanded "deletion" and the wife demanded "suspension of publication.)

―― この教団に関する本(教義も含む)を数冊読めば、誰でも分かる程度の内容

"Enough for anyone to read a few books on this cult (including its doctrines)"

です。

―― 宗教団体のネタにコメントすると、面倒くさいことになる

(応募者が0人が、連続2日を経過した段階で、配布を予定しております) の要件が満たさていません。

(After zero applicant after two consecutive days, I will publish it. ) is not satisfied now.

この週末に編集作業を進めますが、リリースはもう少しお待ち頂くかもしれません。

I will work on editing this weekend, but may have to wait a little longer for release.

悪しからずご了承下さい。

Please understand that I apologize.

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

(Step.1) vscodeでmarkdownを使って本文を書いて、PDF(A4サイズ)にする

vscodeに以下の拡張機能は絶対に入れる

Visual Studio CodeのMarkdown編集から、いきなりPDFを作ったり、目次を追加したりできる件

vscodeでMarkdownを使って文章を書いている時、図面のコピペを文書の中にサクっと入れることができるアドイン "Paste Image"

(Step.1) SAIやPowerPointを使って、表紙と裏表紙を描いて、PDF(A4サイズ)にする

(Step.3) ConcatPDF(GUI)を使って、上記をマージして、書籍の名前のファイル名に保存する

(Step.4) 「江端さんの本屋さん」へアップロードする

新しいファイルをドラッグして、完了

ちなみに、以前のバージョンを購入して頂いた方は、最新版を無料で御提供する旨を、メッセージに追加(現在は、『メールでご連絡下さい』としているが、自動的にやる方法があるのか? 現在調査中)。

 

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

最近、自分が老害の側に立っているなぁ、と実感します。

Lately, I realize that I am standing on the side of the old man, that menas, problems caused by the elderly (esp. gerontocracy, and elderly people's control over the young)

なるべく、若い人の考える発想や感性に『手を出さないように』と心がけているのですが、これが、なかなか難しいです。

I am trying not to touch youth ideas and sensibility, however, it is hard for me.

ご存知とは思いますが、私は、社会的な正しさや、常識と言われているものに対して、『本当にそうだろうか?』と疑義を呈することを、仕事のネタにしています。

As you know, one of my businesses is to make questions against the social and political correctness.

そして、その正しさや常識を、『数字』を使ってひっくり返す、という趣旨のコラムの連載を続けています。

So I continue to write a series of columns with the aim of using "numbers" to to turn the correctness and common sense upside down.

つまり、

It means,

―― (主に、若い人の考えがちな)アイデアを、その場で叩き潰すことができるだけのネタが、頭の中に満載されている

"I have a lot of logics to knock down the ideas that young people tend in my mind"

のです。

しかも、そのネタとは、具体的な数値がスラスラ出てくる、という状況です。

To make the worst, I can show them using many specific numbers.

-----

私は、自慢をしている訳ではないのです。

I am not trying to brag.

「年齢を重ねる」ということは、こういう経験や計算をする時間が「長かった」という、それだけのことです。

"Getting older" menas that I have had "more time" to have these experiences and calculation. That is all.

シニアは、生きている期間が長いだけで『強い』のです ―― これが、権力です。

Senior is stronger, because of their life time. This is power.

-----

私は、若いころに、様々なアイデアや理想を、年上の人に叩き潰されてきました。

When I was youth, several ideas and ideals of mine had been broken by seniors.

年上の人のロジックは、常に完璧でした。ですので、私は常に挫折を続けてきました。

Their logics were always perfect, and I had to continue to lose.

それ故、私が、「人の言うことを聞かない能力」という観念に到達するまでには、随分時間がかかったものです。

Therefore, it took me a long time to arrive at the cencept of "the ability not to listen to others".

柔軟で、頭が良く、コミュニケーションが高い若者、いわゆる「有能な若者」は、簡単に『老害』の餌食にされる傾向が強いです。

Flexible, smart, and communicative young people, the so-called "competent young people", tend to be easily preyed upon by the "old".

私は、『潰される側』と『潰す側』の両方で、この事実を知っています。

I know this reality from the side of 'crushed side' and the 'crusher side'.

-----

ですから、今の私に必要なものは、

So, I think that what I have to have is

『知っていることを、沈黙し続ける能力』

'The ability to remain silent about what I know.'

です。

そして、その能力を最大限発揮する最も簡単なアプローチは『議論をしない』ということです。

And the easiest approach to maximize that ability is to 'not argue'.

今の私には、『"お互いに分かり合わない"努力』が求められていると、実感しています。

I realize that I am now required to make an effort to "not understand each other.

未分類

部屋に鉄棒を作ってみた

この鉄棒(正確には金属管)、ぶら下がっている最中に、回転してしまい、グリップで体を支えられない、という問題に気がつきました。

という訳で、鉄棒が回転しない方法を考えました。

アタッチメントを外して、ゴムなどを詰め込むという方法もありましが、アタッチメントを同じ木材の穴に取りつけると、強度が落ちると考えました。

そこで強制的に、アタッチメントと鉄棒(金属管)に穴を開けて、そこに、ネジを差しこむことにしました。

まず、センターポンチで小さい穴を開けて、そこに金属ドリルの先端を当てて、電動ドリルで穴を開けるのですが ―― 酷く苦労しました。

一つの穴を開けるのに20分間程度の時間がかかりました。

おまけに、ドリルが折れてしまったので、他のドリルを使いながら、何とか穴を貫通させて、ネジを差し込むことができました。

これは、ねじ山が折れてしまったケースです(結果として良くなりましたが)

微細な金属片が飛び回るので、メガネは必須でした(本当はスキーゴーグルを装着するべきだったと思います)。その後の部屋の掃除も大変でした。

-----

結果、鉄棒が回転しなくなり、ぶら下がりやすくなりました。

ちなみに、お世話になっている医療従事者の方から、以下のアドバイスを頂きました。

見た目はマヌケかもしれませんが、しっかりと安定した踏み台をおいて、足をつけた状態でぶら下がることからスタートすることをお勧めいたします。
このアドバイスは『とても』正しいです。
もし、天井の鉄棒にとびついて、ぶらさがったら、私は、高い確率で入院する自信があります(筋肉の裂傷とか、簡単に起きそう)。
そうなれば、家族だけでなく、担当されるお医者さんからも『バカ』と言われそうなので、当面は「ぶらさがり(仮)健康法」で、じっくりやっていきたいと思っております。
-----

ぶらさがり(仮)健康法」は、慣れてくると、なかなか気持ちが良く、スッキリした気分になります。

ぶらさがる」時に、体がコキコキと鳴って、正常な位置に骨が戻されているような感じもいいです ―― まあ、錯覚かもしれませんが。

2つめの鉄棒(木棒)を作りました。

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

昨日、以前自分で作ったはずの、Go言語のFuzzy推論ライブラリを探していました。

Yesterday, I was searched "fuzzy reasoning library with Golang" that I had made before.

ついでに、Go, Fuzzyでサーチエンジンをかけたのですが、"Go"、"Fuzzing"というWordで大量ヒットして、驚いています。

In addition, I ran a search engine, and I was surprised to find a large number of hits on the word "Go", "Fuzzing".

―― ここに至って、まさかのファジィ推論の復権? それもGolangで?

"Returning to 'Fuzzy Reasoning' ? with Golang? Now?"

と、思ったのですが、全く違う話でした。

I was foolish to think even for a moment.

-----

GolangのFuzzing機能とは、『プログラムの機能が想定していない入力を与える事でバグを発見するアプローチ』で、「プログラムのバグ発見用テストツール」ということのようです。

Golang's Fuzzing function is "an approach to finding bugs by providing input that is not expected by the program's functionality," and it is a "testing tool for finding bugs in programs.

fuzz: 警察(名詞)

fuzz: police (noun)

fuzzy: あいまいな(形容詞)

fuzzy: ambiguous (adjective)

名詞と形容詞で、これほど意味の変ってくる単語も珍しいなぁ、と思っています。

I think it is rare to change the meanings of word just between noun and adjective like this.

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

私の未来予想は、これまで、ダイナミックに外れてきました。

My future predictions has been out of mark dynamically.

ですので、皆さんは、私の言うことは、あまり信じない方がいい、と、かなり本心から思っています。

So I am sorry that you don't have to believe what Ebata says no much from the bottom of my heart,

と逃げをうった上で申し上げますが、

And I'm going to say this with an evasive answer.

―― ロボットによる介護は、(少なくとも、私のフェーズでは)ダメなんじゃないかな

"I think robotic caregiving is a no-go (at least in my phase)"

と、思うのです。

もっとも、これは「完全人型ロボット」という意味で、パワードスーツの方向は希望はあると思っていますが。

However it is the case of "full humanoid robot", on the other hand, I think that "powered suite" has a little hopes.

-----

最近、私がショックを受けたパラダイムは、『マッチョ介護』です。

The paradigm that has shocked me recently is 'macho caregiving'.

『ITや制御やロボットがナンボのもんだ。これが正解だ』

"IT, control, and robot are meaningless. The 'macho caregiving' is right answer".

と、頭をぶん殴られるほどの衝撃を受けました。

I was so shocked that I was hit over the head.

父と母が亡くなり、今後の介護フェーズは、私たち夫婦の問題に移行します。

Through the death of my father and mother, the caregiving phase is going to move to my wife and me.

その準備としては、お金や設備などもありますが、介護をする側になることを考えれば「マッチョ」は分かりやすく、おそらくはかなりコストパフォーマンスなアプローチです。

For the preparation, we will need money and devices, however, for the side of the caring , "macho" is easy to understand and a cheaper strategy.

被介護者になるリスクを減らすという観点でも、良いアプローチと思います。

From the viewpoint of risk management to avoid being a care receiver, this is a good approach.

-----

こういう考え方が出て来たのは、これを作ってからです。

This paradigm has come to me, since I made the following device.

部屋に鉄棒を作ってみた

今の私は、(ずるい方法の)懸垂20回、ぶらさがり時間は60秒を軽く越えることができます。

Now I can do 20 sneaky pull-ups and keep my body hanging over 60 seconds.

さらに、最近は、他のメニューも加えて、全身運動に工夫をするようにしています。

These days, I have added new menus for full body exercise.

―― まだ間に合うかもしれない

"It might be not too late"

と思い、現在は、筋トレ専用のスポーツジムなどの巡回ツアーを開催しています。

So, I am organizing a tour of gyms and other facilities for muscle training.

-----

ただ、月額費用、2万円/月は、ちょっと高いんですよね。

However, \20K yen/month is too expensive for me.

普通のフィットネスセンターは、人数が多いし、市民運動センターは遠い。

Ordinal fitness club has many members, and the civic exercise center is far from my house.

モチベーションも「介護」一択です。

My motivation of muscle training is just for "caregiving".

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

I have never wanted to have a macho body and be popular with the woman at all in my life.

(そもそも、私は、"マッチョ = バカ"という、酷い偏見を持っていた人間でした。今は、"尊敬"、"有用"にパラダイムシフトしています)

(To begin with, I thought "Macho is stupid" that is terrible prejudice. Now I change my mind to "respect" or "useful")

加えて、私は「"引きこもり"大好き人間」です。

In addition, I am a "recluse lover".

-----

先ずは、人間を運搬できるだけの筋力と、ぎっくり腰対策ができる程度のトレーニングを、『自宅』でできないものか模索しています。

So, I am searching how to get muscle to move a person, and avoid "strained back" just in my house.

上記の鉄棒のように、自宅を加工するのはことはO.K.で、工作は大好きなので、その方向から、皆さんのアドバイスを頂けると、大変助かります。

Like the the above "iron bar", I love DIY making or modifying my house, so I appreciate if you give me some advices.

よろしくお願い致します。

Thank you for your help in advance.

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

最近、スペルチェックをvscodeにやらせていて、emacsでのリロードを何度もやっているのだけど、これが中々に面倒で、これを一発でできないものか、色々調べた結果です。

方針: 面倒なので、".emacs" だけの記載で終了したい
操作:<F5>押すだけ
判ったこと: ".emacs"の最後に追記すると動かない(私の環境だけかもしれないが) → ".emacs"の真ん中あたりに突っ込んだ。

;;;; バッファを一発でリロードする (.emacsの最後に記載したら動かなかったので、真ん中くらいに移動)

(defun revert-buffer-no-confirm (&optional force-reverting)
  (interactive "P")
  ;;(message "force-reverting value is %s" force-reverting)
  (if (or force-reverting (not (buffer-modified-p)))
      (revert-buffer :ignore-auto :noconfirm)
    (error "The buffer has been modified")))

;; reload buffer
(global-set-key (kbd "<f5>") 'revert-buffer-no-confirm)
;;(global-set-key "\C-c\C-r" 'revert-buffer-no-confirm)
;;(global-set-key "\M-r" 'revert-buffer-no-confirm)
;(global-set-key "\C-c\C-m" 'revert-buffer-no-confirm)

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

Go言語を使った自作のファジィ(Fuzzy)推論コードを探していたのですが、見つけることができずにちょっとショックを受けております。

というか、Go言語どころか、C言語でも見つけられなかった(いや、あるはずだ)ので、今、PCの中探して見つかったものをアップしておきます。

毎回スクラッチから作るのも迂遠なので。

↓のコードですが、こちらのコラムで使ったものだと思います。

/*
  このプログラムをfuzzy.cpp"という名前で保存して、
  gcc -g fuzzy.cpp -o fuzzy
  でコンパイルして下さい。
*/



#include <stdio.h>
#include <stdlib.h>


// 共通関数
double max(double a){
    return a;
}

double max(double a, double b){
    if (a > b) 
        return a;
    else 
        return b;
};

double max(double a, double b, double c ){
    return max(max(a,b), max(b,c)); 
};

double max(double a, double b, double c, double d ){
    return max(max(a,b,c), d); 
};

double min(double a){
    return a;
}

double min(double a, double b){
    if (b > a) 
        return a;
    else 
        return b;
};

double min(double a, double b, double c ){
    return min(min(a,b), min(b,c)); 
};

double min(double a, double b, double c, double d ){
    return min(min(a,b,c), d); 
};


// ファジィ表現
typedef enum scale {LESSLESS, LESS, ZERO, MORE, MOREMORE} SCALE;

// 前件部メンバーシップ関数(山3つ)クラス
class condition_MF3
{
private:
    double center;
    double width;
    SCALE express;
   
public:
    condition_MF3(double _center, double _witdth, SCALE _express){
        center = _center;
        width = _witdth;
        express = _express;

        // 使用できないファジィ表現を使った場合は止める        
        if ((express == LESSLESS) || (express == MOREMORE)){
            printf("wrong expression used \n");
            exit(0);
        }

    };
    double func(double _x);
};

double condition_MF3::func(double _x)
{
// x,yは、メンバーシップ関数上の座標を示す
    double x = _x;
    double y = 0.0; // yの値は、必ず0以上1以下になる

    if (express == LESS){
        if (x <= center - width){
            y = 1.0;
        }
        else if (x <= center){
            y = - 1.0 / width * (x - center);
        }
        else{
            y = 0.0;
        }
    }
    else if (express == ZERO){
        if (x <= center - width){
            y = 0.0;
        }
        else if (x <= center){
            y = 1.0 / width * (x - center) + 1.0;
        }
        else if (x <= center + width){
            y = -1.0 / width * (x - center) + 1.0;
        }
        else{
            y = 0.0;
        }
    }
    else if (express == MORE){
        if (x <= center){
            y = 0.0;
        }
        else if (x <= center + width){
            y = 1.0 / width * (x - center);
        }
        else{
            y = 1.0;
        }
    }
    else {
        printf("wrong expression\n");
        exit(1);
    }

    return y;
};

// 前件部メンバーシップ関数(山5つ)クラス
class condition_MF5
{
private:
    double center;
    double width;
    SCALE express;
   
public:
    condition_MF5(double _center, double _witdth, SCALE _express){
        center = _center;
        width = _witdth;
        express = _express;
    };
    double func(double _x);
};


double condition_MF5::func(double _x)
{
// x,yは、メンバーシップ関数上の座標を示す
    double x = _x;
    double y = 0.0; // yの値は、必ず0以上1以下になる

    if (express == LESSLESS){
        if (x <= center - 2.0 * width){
            y = 1.0;
        }
        else if (x <= center - width){
            y = - 1.0 / width * (x - (center - 2.0 * width)) + 1.0;
        }
        else{
            y = 0.0;
        }
    }
    else if (express == LESS){
        if (x <= center - 2.0 * width){
            y = 0.0;
        }
        else if (x <= center - width){
            y = 1.0 / width * (x - (center - width)) + 1.0;
        }
        else if (x <= center){
            y = -1.0 / width * (x - (center - width)) + 1.0; 
        }
        else{
            y = 0.0;
        }
    }
    else if (express == ZERO){
        if (x <= center - width){
            y = 0.0;
        }
        else if (x <= center){
            y = 1.0 / width * (x - center) + 1.0;
        }
        else if (x <= center + width){
            y = -1.0 / width * (x - center) + 1.0;
        }
        else{
            y = 0.0;
        }
    }
    else if (express == MORE){
        if (x <= center){
            y = 0.0;
        }
        else if (x <= center + width){
            y = 1.0 / width * (x - (center + width)) + 1.0;
        }
        else if (x <= center + 2.0 * width){
            y = -1.0 / width * (x - (center + width)) + 1.0; 
        }
        else{
            y = 0.0;
        }
    }
    else if (express == MOREMORE){
        if (x <= center + width){
            y = 0.0;
        }
        else if (x <= center + 2.0 * width){
            y = 1.0 / width * (x - (center + 2.0 * width)) + 1.0;
        }
        else{
            y = 1.0;
        }
    }

    return y;
};

// 後件部メンバーシップ関数(山3つ)クラス  
class action_MF3
{
private:
    double center;
    double width;
    SCALE express;

    double x;
    double y;

public:
    action_MF3(double _center, double _witdth, SCALE _express){

        y = 0.0; // yの値は、必ず0以上1以下になる
       
        center = _center;
        width = _witdth;
        express = _express;
        
        if (express == LESS){
            x = center - width;
        }
        else if (express == ZERO){
            x = center;
        }
        else if (express == MORE){
            x = center + width;
        }
        else{
            printf("wrong scale expression\n");
            exit(0);
        }
    };
    
    void func_Max(double b){
        y = max(b, y);
    };
    
// X座標を返す
    double func_X(void){
        return x;
    };
    
    // (最大値で更新された、最後の)Y座標を返す
    double func_Y(){
        return y;
    };

};

// 後件部メンバーシップ関数(山5つ)クラス  
class action_MF5
{
private:
    double center;
    double width;
    SCALE express;

    double x;
    double y;

public:
    action_MF5(double _center, double _witdth, SCALE _express){
        y = 0.0; // yの値は、必ず0以上1以下になる
       
        center = _center;
        width = _witdth;
        express = _express;
        
        if (express == LESSLESS){
            x = center - 2.0 * width;
        }
        else if (express == LESS){
            x = center - width;
        }
        else if (express == ZERO){
            x = center;
        }
        else if (express == MORE){
            x = center + width;
        }
        else if (express == MOREMORE){
            x = center + 2.0 * width;
        }
        else{
            printf("wrong scale expression\n");
        }
    };
    
    void func_Max(double b){
        y = max(b, y);
    };
    
// X座標を返す
    double func_X(void){
        return x;
    };
    
    // (最大値で更新された、最後の)Y座標を返す
    double func_Y(){
        return y;
    };

};

int main()
{
    // ダイエット経過期間
    condition_MF3 Period_Short(14, 14, LESS); // 0日
    condition_MF3 Period_Middle(14, 14, ZERO); // 14日
    condition_MF3 Period_Long(14, 14, MORE); // 28日

    // いわゆる「停滞期」(14日間あたりの平均減重変化量)
    condition_MF3 WeighChange_Small(1.0, 1.0, LESS); // 0kg
    condition_MF3 WeighChange_Middle(1.0, 1.0, ZERO); // 1kg
    condition_MF3 WeighChange_High(1.0, 1.0, MORE); // 2kg

    // 苦痛度
    condition_MF3 Suffer_Zerol(400.0, 400.0, LESS); // 0
    condition_MF3 Suffer_Middle(400.0, 400.0, ZERO); // 400
    condition_MF3 Suffer_Hight(400.0, 400.0, MORE); // 800

    // BMI
    condition_MF5 BMI_lowlow(22.0, 3.0, LESSLESS); // 痩せすぎ(15.0)
    condition_MF5 BMI_low(22.0, 3.0, LESS);// 痩せぎみ(19.0)
    condition_MF5 BMI_Normal(22.0, 3.0, ZERO);// 普通(22.0)
    condition_MF5 BMI_High(22.0, 3.0, MORE); // 太りぎみ(25.0)
    condition_MF5 BMI_HighHigh(22.0, 3.0, MOREMORE);// 太りすぎ(28.0)

    // 一日の摂取カロリー
    action_MF5 Eat_LittleLittle(2500, 1000, LESSLESS); // 500 Kcal
    action_MF5 Eat_Little(2500, 1000, LESS);// 1500 Kcal
    action_MF5 Eat_Normal(2500, 1000, ZERO);// 2500 Kcal
    action_MF5 Eat_Lot(2500, 1000, MORE);// 3500 Kcal
    action_MF5 Eat_LotLot(2500, 1000, MOREMORE);// 4500 Kcal



    
    
    // 超シンプルシミュレータ投入
    // 体重変動シミュレーションプログラム
    //基礎代謝量と求め方	?ハリス・ベネディクト方程式(日本人版) 計算式
    //http://www.kintore.info/kisotaisya_mass/index.cgi
    //【計算式】
    // 男性 66.5+(体重kg×13.8)+(身長cm×5.0)-(年齢×6.8)
    // 女性 665.1+(体重kg×9.6)+(身長cm×1.9)-(年齢×7.0)							
    // 江端智一 2014日2月4日現在のデータを使って計算
    double weight = 78.0;  // 開始時の体重 78.0kg
    double lengthw = 172.0;  // 身長 172cm
    double age = 49.0 + 94/365;  // 開始時の年齢 49歳と94日 (2014年2月4日現在)

    // 最初の基礎代謝カロリー 男性  66.5+(体重kg×13.8)+(身長cm×5.0)-(年齢×6.8)
    double consumption_calorie =  
        66.5 + weight * 13.8 + 172.0 * 5.0 - age * 6.8;
    // このカロリーに運動消費カロリーを加えて、
    // トータルの一日の消費カロリーを算出する

    // (現在の体重 66.5kgにおいて)一日運動消費カロリー 708kcalと推定し、
    // このカロリーは、体重に比例するものと仮定する。
    consumption_calorie += weight/66.5 * 708.0;
    printf("consumption_calorie = %f\n",  consumption_calorie);

    double last_weight[14]; // 過去14日分の体重
    
    // 最初は全部同じ体重とする 14日経過までは同じ体重とする
    for (int i = 0; i++; i < 14){
        last_weight[i] = weight;
    }

    // ここからループ開始
    for (int day=0; day < 1460; day++){ // 1460日は、ちょうど4年分の日数
        // 7kcal = 1g = 0.001kg とする    

        // 体重データを一日分ずらす
        for (int i = 0; i++; i < 14-1 ){
            last_weight[i+1] = last_weight[i];
        }
        last_weight[0] = weight;
        
        // 線形補完の傾きだけを求める(14日分)
        // http://d.hatena.ne.jp/rainlib/20090112/1231735459
        double k1=0,k2=0,k3=0,k4=0;
        for (int i = 0; i++; i < 14 ){
            k1 += (double)i * (double)i;
            k2 += (double)i * last_weight[i];
            k3 += (double)i;
            k4 += last_weight[i] *last_weight[i];
        }
        double dW = (14.0 * k2 - k3 * k4) / (14.0 * k4 - k3*k3); // 14

        // BMIの計算式 体重(Kg)÷身長(m)÷身長(m) 江端の身長172cm
        double bmi = weight / 1.72 / 1.72;
        
        // [ルール1] ダイエット開始直後は、「無条件にがんばれる」
        double r1 = min(Period_Short.func(day));
        Eat_Little.func_Max(r1);
        //printf("r1: %f\n",r1);
        
        //printf("Eat_Little.func_X() = %f\n",Eat_Little.func_X());
        //printf("Eat_Little.func_Y() = %f\n",Eat_Little.func_Y());
        
        // [ルール2] ダイエット一ヶ月を過ぎても、停滞し続けると「切れる」
        double r2 = min(Period_Long.func(day),WeighChange_Small.func(dW));
        Eat_LotLot.func_Max(r2);
        //printf("r2: %f\n",r2);
        
        // [ルール3] ダイエット2週間を過ぎて、停滞し続けると「緩んでくる」
        double r3 = min(Period_Middle.func(day),WeighChange_Small.func(dW));
        Eat_Normal.func_Max(r3);
        //printf("r3: %f\n",r3);
        
        // [ルール4] 停滞期がなく順調に体重が落ちている場合は「がんばれる」
        double r4 = min(WeighChange_High.func(dW));
        Eat_Little.func_Max(r4);
		//        printf("r4: %f\n",r4);
        
        // [ルール5] ダイエット一ヶ月を過ぎて、再び太り出してくると、またダイエットを再開してしまう
        double r5 = min(Period_Long.func(day),BMI_High.func(bmi));
        Eat_Little.func_Max(r5);
        //printf("r5: %f\n",r5);
        
        // [ルール6] ダイエット一ヶ月を過ぎて、太り過ぎると、滅茶苦茶なダイエットを始めてしまう
        double r6 = min(Period_Long.func(day),BMI_HighHigh.func(bmi));
        Eat_LittleLittle.func_Max(r6);

        //printf("r6: %f\n",r6);
		/*        
        printf("Eat_LittleLittle.func_X() = %f\n",Eat_LittleLittle.func_X());
        printf("Eat_LittleLittle.func_Y() = %f\n",Eat_LittleLittle.func_Y());
        printf("Eat_Little.func_X() = %f\n",Eat_Little.func_X());
        printf("Eat_Little.func_Y() = %f\n",Eat_Little.func_Y());
        printf("Eat_Normal.func_X() = %f\n",Eat_Normal.func_X());
        printf("Eat_Normal.func_Y() = %f\n",Eat_Normal.func_Y());
        printf("Eat_Lot.func_X() = %f\n",Eat_Lot.func_X());
        printf("Eat_Lot.func_Y() = %f\n",Eat_Lot.func_Y());
        printf("Eat_LotLot.func_X() = %f\n",Eat_LotLot.func_X());
        printf("Eat_LotLot.func_Y() = %f\n",Eat_LotLot.func_Y());
        */
        
        double source_calorie =  
            (Eat_LittleLittle.func_X() * Eat_LittleLittle.func_Y() + 
             Eat_Little.func_X() * Eat_Little.func_Y() +
             Eat_Normal.func_X() * Eat_Normal.func_Y() +
             Eat_Lot.func_X() * Eat_Lot.func_Y() +
             Eat_LotLot.func_X() * Eat_LotLot.func_Y() )  
            /
            (Eat_LittleLittle.func_Y() + 
             Eat_Little.func_Y() +
             Eat_Normal.func_Y() +
             Eat_Lot.func_Y() +
             Eat_LotLot.func_Y() ) ;
        
        printf("\n source_calorie = %f\n",source_calorie);

        double diff_weight = (source_calorie - consumption_calorie)/7.0 / 1000.0;
        weight += diff_weight;
        age += 1.0/365.0;
        consumption_calorie =  66.5 + weight * 13.8 + 172.0 * 5.0 - age * 6.8;
        consumption_calorie += weight/66.5 * 708.0;
        //       printf("day:%d\tweight = %f\tconsumption_calorie =%f\n", day,weight, consumption_calorie);
    }



}

ファジィ推論