2021/03,江端さんの技術メモ

GO 1.5 と C++ を SWIG でブリッジさせる方法

を試してみたのですが、私は上手く動かすことができませんでした。

で、こんな風にしてみたら動いたので、記録を残しておきます。

ebata@DESKTOP-P6KREM0 MINGW64 ~/kese/swig
$ tree
.
├── main1.go
└── sc1
    ├── nop.go
    ├── sc1.h
    └── sc1.swigcxx

1 directory, 4 files
// main1.go

package main

import (
	"fmt"

	"./sc1"
)

func Dump(p interface{}) {
	fmt.Printf("%v:%T\n", p, p)
}

func main() {
	Dump(sc1.EchoIntN(8))
	Dump(sc1.EchoDoubleN(9))
}

でもって、nop.go

package sc1

sc1.h

#pragma once

inline  int
EchoIntN( int p ) {
    return p;
}

inline  double
EchoDoubleN( double p ) {
    return p;
}

sc1.swigcxx

%module sc1
%{
#include    "sc1.h"
%}

%include    "sc1.h"

ちなみに、sc1.hのインラインをやめて、sc1.hとsc1.cに分けて実施したら、こうなった

$ go build main1.go
# _/C_/Users/ebata/kese/swig2/sc1
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w6
4-mingw32/bin/ld.exe: $WORK\b002\_x004.o:/tmp/go-build/sc1_wrap.cxx:279: undefin
ed reference to `EchoIntN(int)'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w6
4-mingw32/bin/ld.exe: $WORK\b002\_x004.o:/tmp/go-build/sc1_wrap.cxx:292: undefin
ed reference to `EchoDoubleN(double)'
collect2.exe: error: ld returned 1 exit status

ずいぶん悩んだが、もしかしたらと思い、sc1.c → sc1.cpp   にリネームしたら、あっさり通った

sc1.hは以下の通り

#pragma once

int EchoIntN(int);

double EchoDoubleN(double);

sc1.cppは以下の通り

//#pragma once
#include "sc1.h"

int EchoIntN( int p ) {
    return p;
}

double EchoDoubleN( double p ) {
    return p;
}

以上

 

 

 

 

2021/03,江端さんの忘備録

(昨日の続きです)

(Continuation from yesterday)

次女:「私は、パパの新型コロナに関する情報が徹底しているから、同級生の中では「コロナリテラシー」は高い方だよ」

Junior Daughter: "I'm more 'Corona literate' than most of my classmates because I'm thoroughly informed about Dad's new Corona.

江端:「でも、結構頻繁に友人と外出しているよね」

Ebata: "But you go out with your friends quite often, don't you?

次女:「まあ、高校生活、最後の一ヶ月だし」

JD: "Well, it's my last month of high school.

江端:「では、同級生のコロナリテラシーを10段階として、自分のリテラシーは、いくつだと思う」

E: "So, on a scale of one to ten, how would you rate your corona literacy in comparison to your classmates?

次女:「"9"かな」

JD: "I think it's a nine."

次女の話を聞いた家族が、全員ビックリしていました。

All the family members who heard my junior daughter's story were surprised.

私は、次女の状況分析力をそれなりに信頼しているので、この値は"真"であると認定することができます。

I have a fair amount of faith in my second daughter's ability to analyze situations, so I can qualify this value as "true".

とすれば、

If that's the case,

―― ティーンエイジャの、コロナリテラシーは、私たちの想像を絶するほど『低い』

"Teenagers' corona literacy is 'low' beyond our imagination"

という可能性は『高い』です。

This possibility is 'high'.

しかし、若者の多くは、ちゃんと感染対策をしていると思います。

However, I believe that most young people are taking proper measures to prevent infection.

飲食店で大声で会話している低能なオヤジたちよりは、本当に真面目に取り組んでいると信じています。

I believe they are really more serious than the lowly old men who are talking loudly in restaurants.

しかし、そこには「死の影」が全く感じられないのです。

However, there is no sense of "shadow of death" there at all.

-----

現時点で、16歳以下の若者の新型コロナによる死亡者数は0で、ワクチン接種対象外です。

At this time, there have been zero deaths from the new coronavirus in young people under the age of 16, and they are not eligible for vaccination.

これで、『死の恐怖と隣り合わせの高齢者』と意識を共有しろ、というのは、かなり無茶だと思います。

I think it's quite absurd to ask people to share their consciousness with "elderly people who live with the fear of death".

「全世代で等しい死亡率」であるとか、逆に「子どもを集中的に襲うウイルス」なら、状況は変わっていたでしょう。

The situation would have been different if the virus had "equal mortality in all generations" and "concentrated on children.

いわゆるスペイン風邪のように「乳幼児を直撃」「若者から重症化」という特性を持っていたのであれば ――

If, like the so-called Spanish flu, it would have been the characteristics of "hitting infants directly" and "severe disease in young people" --

今回の緊急事態宣言の中において「緩み」などという言葉は出てこなかっただろうなぁ、と思うのです。

I don't think the word "loosening" would have been used in the declaration of the state of emergency this time.

2021/03,江端さんの忘備録

緊急事態宣言 ―― というからには、戒厳令がセットメニューでなければならないと思うのです。

When it comes to declaring a state of emergency, I think "martial law" should be on the menu.

「戒厳令」ということになれば、当然、新宿や渋谷のスクランブル交差点に、戦車と小火器を携帯した自衛隊隊員が、仁王立ちで、街行く市民を睨めつけていなければならない、と思うのです。

If "martial law" were to be declared, of course there would have to be Self-Defense Forces personnel with tanks and small arms at the scramble intersections of Shinjuku and Shibuya, standing on their heads and glaring at the citizens on the street.

自衛隊 ―― となると、治安出動となりますが、

The Self-Defense Forces -- that would mean mobilizing security forces, however,

我が国では、『実際に治安出動が発令されたことは一度もない』です。

In Japan, there has never been a "security mobilization" actually issued.

これが発動されるためには、大手町あたりが火の海になっているか、自衛隊基地がミサイル攻撃を受けている、くらいのレベルでないとダメでしょう。

In order for this to be triggered, it would have to be at a level where Otemachi is on fire or the SDF base is under missile attack.

内閣として安易に切れるカードではありません。

This is not a card that the Cabinet can easily play.

―― 感染症ごときで、治安出動できるか

"I don't know if I can mobilize security for an infectious disease"

と、私でも思います。

I think that.

-----

街行く人が、インタビューで「緩んできていますね」と語るのは、なんというか違和感を感じます。

When people on the street talk about "loosening up" in interviews, I feel somewhat uncomfortable.

そもそも、テレビ局の人間は、インタビューする相手を間違っているし、インタビューに応じている人もどうかしていると思う。

In the first place, I think the people at the TV station are interviewing the wrong people, and I think the people being interviewed are nonsense.

私なら、この手のインタビューが近寄ってきたら、直ぐに逃げます。

For me, I would run away immediately if this kind of interview approached me.

もし、逃げないで、受け答えするのであれば、

If I don't run away and answer...

『うん! 私は、緩んでいます。だから、ここにいるんですよ。あなたも、下らない質問をしないで下さいね!!』

"Yes! I'm loose. That's why I'm here. You don't have to ask me any lame questions either!

と応答して、夕方のニュースの映像に出てきて、名前と住所を晒されて、炎上を喰らう覚悟があります。

I will respond as such. And I'm ready to appear in the evening news footage, have my name and address exposed, and go to the flames.

というか、インタビューするなら、一日15時間以上、自宅のPCで、シミュレーションとコーディングをやっている、この私に聞くのが筋だろうが、と思うのです。

I mean, if they're going to interview someone, it's me, I think, who spends more than 15 hours a day doing simulations and coding on my PC at home.

我が家において、「緩んできていますね」とか「緩んできてはいませんね」とコメントできるのは、この私くらいです。

In my family, I am the only one who can comment that things are loosening up or that things are not loosening up.

(続く)

(To be continued)

未分類

このコンテンツはパスワードで保護されています。閲覧するには以下にパスワードを入力してください。

2021/03,江端さんの技術メモ

シミュレータの対象人数が増えると、シミュレータがフリーズしてしまう、という問題が生じたので、まずは、手っ取り早く、Dockerコンテナのメモリとスワップを倍にしてみる処理をしてみた。

起動開始までの時間が恐ろしく長い(5分以上。なんでだ?)が、とりあえず、シミュレーション人数500人(実行時間4分弱)→3000人(22分)→4000人(16分? なんで減っている)→での稼動を確認。

しかし、5000人は失敗、4500人も失敗。では、メモリをもう2G増量。

そこで、6GBまで上げてみた。

うん、こうしても、4500人は落ちるなぁ。

websocketコネクション数の問題かなぁ?

それより、多分、これは私のPCの物理メモリが16GBしかないので、Dockerの設定を大きくしても効果が出てこないのだろう、と推測しています。

ならば、逆に6GBで設定してしたままにしておいて、コンテナの方でメモリ制限するというのは、どうかな、と思いやってみました。

以下、docker-compose.ymlで改造した部分。今回は、controlのコンテナだけメモリ増量できれば良い(それ以外のコンテナは1GBで縛る)、という方針としました。

# docker-compose のバージョン
version: '3'
# 各コンテナの情報
services:
  # postgres サービス
  postgres:
    image:  pamtrak06/postgis-pgrouting-osm:latest
    # コンテナの名前
    # container_name: postgres_db
    # Dockerfile のディレクトリパス
    build:
      context: .
      dockerfile: ./docker/postgres/Dockerfile
    # postgres 設定
    environment:
      - POSTGRES_HOST_AUTH_METHOD=trust
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=XXXXXXX
      - POSTGRES_DB=XXXXXX
    volumes:
      - db_data
      - ./control:/go/src/work # マウントディレクトリ指定
    expose:
      - 5432 # 兄弟コンテナから5432でアクセスできるようにする
    ports:
      - "8910-8911:5432"
    tty: true # コンテナの起動永続化
    mem_limit: 1g # メモリを1Gに制限
  db_data:
    image: busybox
    volumes:
      - /data/db
    mem_limit: 1g # メモリを1Gに制限
  app_control: # service名
    build: . # ビルドに使用するDockerfileがあるディレクトリ指定
    tty: true # コンテナの起動永続化
    volumes:
      - ./control:/go/src/work # マウントディレクトリ指定
    expose:
      - 8900
    ports:
      - "8900-8901:8900"
    image: control_agent
    # container_name: control_agent_app
    # restart: always  # ログイン時に自動起動
    # ここだけメモリの制限をしない
  app_user: # service名
    build: . # ビルドに使用するDockerfileがあるディレクトリ指定
    tty: true # コンテナの起動永続化
    volumes:
      - ./user:/go/src/work # マウントディレクトリ指定
    expose:
      - 8920
    ports:
      - "8920-8921:8920"
    image: user_agent
    # container_name: user_agent_app
    # restart: always  # ログイン時に自動起動
    mem_limit: 1g # メモリを1Gに制限
  app_bus: # service名
    build: . # ビルドに使用するDockerfileがあるディレクトリ指定
    tty: true # コンテナの起動永続化
    volumes:
      - ./bus:/go/src/work # マウントディレクトリ指定
    expose:
      - 8930
    ports:
      - "8930-8931:8930"
    image: bus_agent
    # container_name: bus_agent_app
    # restart: always  # ログイン時に自動起動
    mem_limit: 1g # メモリを1Gに制限

 

5000人は失敗したけど、4500人まで増やすことに成功しました。

それと、controlコンテナのスピードが物凄く上がっているような気がします(比較計測できませんが)。

 

 

 

 

2021/03,2021/03,江端さんの忘備録

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

がでてきたら、

とりあえず、

sudo apt-get update

sudo apt-get install

だな。

 

2021/03,江端さんの忘備録

私は、菓子の製造方法について、全く知見がありませんが、通常の加工食品より、緻密な制御が必要である、ということくらいは知っています。

I don't have any knowledge about how to make confectioneries, but I do know that they require more precise control than normal processed foods.

特に重要なのが、材料の量。グラム単位で緻密に計測する必要があるそうです。

What is especially important is the amount of material, which they says should be measured precisely in grams.

また、わずかな温度や時間によって、できあがるお菓子の味が全く変わってくるのだそうです。

Also, the slightest change in temperature or time can completely change the taste of the finished pastry.

さまざまなお菓子の中でも、「マカロン」は、超絶難しい ―― という話を、次女から聞かさました。

My junior daughter told me that among the various sweets, "macarons" are extremely difficult to make.

私の聞いたところでは、マカロンの味を左右するパラメータは、軽く10を越え、そのパラメータが独立変数でないようです。

From what I've heard, there are lightly more than 10 parameters that affect the taste of macarons, and it seems that these parameters are not independent variables.

「独立変数ではない」とは、変数どうしが影響し合うということで、つまるところ、最適解が線形に求められない、ということで ――

The term "not independent variables" means that the variables influence each other, and in short, the optimal solution cannot be obtained linearly.

つまり、これは、マカロンを最高の状態で完成させる、材料の量、混合比、燃焼温度、放熱時間、外気温や湿度その他もろもろが、簡易に求められない、という難問であるということで、

This means that the amount of ingredients, mixing ratio, combustion temperature, heat release time, outside temperature and humidity, and other factors that make macarons perfect are not easily determined.

―― マカロンの作り方は、数学で言うところのNP困難問題と同じである

"Making macaroons is like an NP-hard problem in mathematics"

と、(私なりの解釈ですが)次女はそのような話をしていました。

(That's my interpretation) my junior daughter talked about it that way.

『しかるに、バレンタインに「手作りマカロン」を平気で要求してくる、あの男は馬鹿か?』

"And yet, that guy who insists on homemade macaroons for Valentine's Day is an idiot?"

と、娘は、自分の彼氏を罵倒しまくっていました。

She was cursing her boyfriend all the time.

-----

ええ、今の私は、次女の憤りが手に取るように分かります。

Yes, now I understand my second daughter's indignation.

江端:「絶対的にお前が正しい。課題の困難さを理解していない上に、気楽に人に要求するやつはだなぁ、「極刑」に値するといっても良いであろう」

Ebata: "You are absolutely right. Those who don't understand the difficulty of the task, and who comfortably make demands of others, deserve the ultimate punishment.

江端:「『NP困難であるDial-A-Ride問題に、人間の心理状態を加えて上で、リアルタイムで解くことを「簡単」のように言う奴は、馬鹿なのか?』って思っているぞ!」

Ebata: "I'm also thinking, 'Is that guy stupid enough to think that adding human psychological states to an NP-hard Dial-A-Ride problem, and then solving it in real time, is 'easy'? That's what I'm thinking!

と、親子二人で、世の中の理不尽に対して、怒りの雄叫びを上げ続けていました。

The two of us, father and daughter, continued to scream in anger at the unreasonableness of the world.

2021/02,江端さんの忘備録

長女の大学の卒業式が中止されることなく実施されることになったようなのですが、コロナ対策で色々制約がでているようでした。

It seems that the graduation ceremony of my eldest daughter's university will be held without being cancelled, but there seemed to be various restrictions due to the Corona measures.

先ず、「保護者の出席禁止」は、まあ当然として、不明点があったので、大学に問い合わせをしてみました。

Aside from the obvious "no parent/guardian allowed to attend," I had other questions, so I contacted the university.

電話が繋がらなかったので、メールで連絡してみた結果、以下の回答を頂きました。

Since I couldn't get through on the phone, I contacted them by email and received the following response.

■ 大学構内に入ることもダメ

- We can't even enter the university campus.

■ 大学の門前での記念撮影もダメ

- Taking a picture in front of the university gate is also not allowed.

つまり「卒業式からの卒業生以外の人間の完全排除」です。

In other words, "the complete exclusion of non-graduates from the graduation ceremony.

(今日、イベイト通知のWebサイトを見直してみたら、上記の2つについての情報が追記されていました)

(I reviewed the Evite Notification web site today and found that information about the above two has been added.)

-----

『良い決断だ』と、私は高く評価しています。

I think it's a good decision".

そもそも、卒業式を敢行したという決断だけでも、「大した度量だ」と思っているくらいです。

I even consider the decision to hold the graduation ceremony in the first place as "a great degree".

-----

この時期に、イベントの開催についての采配をしなければならない立場の方々に、心からの感謝を。

I would like to express my sincere gratitude to those who are in a position to take charge of organizing the event at this time of the year.

私にできることは、その方々の苦労を、できるだけ少なくすることくらいです。

The least I can do is to minimize their hardships as much as possible.

2021/02,江端さんの忘備録

前回のコラム(「シバタレポート前半」)の執筆を終えて、私は、新型コロナワクチンに関する知識をざっくりと理解することができた、と思っています。

After writing my last column (the first half of the Shibata Report), I think I have a rough idea of what I know about the new coronary vaccine.

そして、ITエンジニアとしての私は、デジタルで設計されたワクチンを、体内に投入する日(ワクチン接種の日)を、楽しみに待っています。

And I, as an IT engineer, am looking forward to the day when the digitally designed vaccine is put into my body (the day of vaccination).

『フッフッフ・・。コンピュータで設計された「なんちゃって(デジタル?)コロナウイルス」に、騙(だま)されろ!私の体!!』

"Huh-uh. My body! Be fooled by the computer-designed 'digital coronavirus'"

と考えるだけで、ワクワクが止まりません。

I can't stop the excitement just thinking about it (*)

という話を家族にしたら、『世の中には、色々な考えをする人がいるのね』と、軽くスルーされました。

When I mentioned this to my family, they just brushed it off, saying, "There are many people in the world who think in different ways.

-----

デジタルウイスル(mRNA)(*)を体内に注入して、アナログウイルス(SARS-CoV-2)を駆逐する ――

"Digital virus (mRNA)(*) is injected into the body to eradicate the analog virus (SARS-CoV-2)"

(*)もちろん、この表現はメタファです

(*) Of course, this expression is just a metaphor.

こんなSFのような話が、今、世界で、人類全員に施されようとしている ―― これは、凄いことです。

This kind of science fiction story is now being given to all human beings in the world -- this is a great thing.

勿論、「今回は運が良かった」「SARS-CoV-2と相性が良かった」とは言えますが、この技術は、他のウイルス感染症への展開はできるはずです。

Of course, we can say that "we were lucky this time" or "it was a good match with SARS-CoV-2," but this technology should be able to be deployed to other viral infections.

デジタルウイルスの活用先は、今回のようなウイルス感染は勿論として、ほとんどのガン治療にもあるはずです。

Digital viruses can be used to treat most cancers, not to mention viral infections such as this one.

さらに言えば、

What's more,

「同性間で子どもをつくることはできる?検証のための基礎知識~iPS、ES細胞」

"Can homosexuals have children? Basic Knowledge for Verification - iPS and ES Cells"

で記載した、iPS細胞への展開も可能なはずです。

This technology should also be able to be applied to iPS cells, as described in this column.

mRNAは、私たちのDNAに記載されていない情報のタンパク質も作り出すことができるのですから、その目的を「抗体生成」に限定する必要はないはずです。

Since mRNA can also produce proteins with information that is not described in our DNA, it should not be necessary to limit its purpose to "antibody production.

これからは、「IT(Information Technology) x GT(Genetic technology) という時代が本格化する」という予感がビンビンしています。

I have a strong feeling that the era of IT (Information Technology) x GT (Genetic technology) will be in full swing from now on.

-----

まあ、同時に、その抵抗勢力の動きも予見できます。

Well, at the same time, we can foresee the movement of that resistance.

今や常識となった「試験管ベイビー」や、「クローン牛」。

Test tube babies" and "cloned cows" are now common knowledge.

そういえば、今回のmRNAについて「ワクチンの設計アプローチが神の教えに反している」という抗議をしている団体(バチカン等)の話は聞きませんね。

By the way, I haven't heard of any groups (Vatican, etc.) protesting about this mRNA, saying that the vaccine design approach is against God's teachings.

彼らは、「iPS細胞」が登場する前、「ES細胞」にすら抗議していたハズですが ―― ES細胞は「胎児の細胞を使う」という点がひっかっかったのだから、今回のケースとは違うかもしれません。

They were even protesting against "ES cells" before the advent of "iPS cells". However, ES cells were stuck on the point of "using fetal cells", which may be different from this case.

-----

今回、もしバチカンが「mRNAワクチン」を叩くような方向で動けば、私たちが「バチカンを世界から破門する」という事態になるかもしれません ――

This time, if the Vatican moves in the direction of slamming the "mRNA vaccine", we may end up "excommunicating the Vatican from the world" -- a situation that would be very difficult to avoid.

それはそれで、見てみたい気もしますが。

That's something I'd like to see, though.

2021/02,江端さんの技術メモ

今回のコラム「あの医師がエンジニアに寄せた“なんちゃってコロナウイルスが人類を救う”お話」で、使わなかった図面。

でも、今後、「素材として使える」かもしれないので、忘れないようにアップしておく。

ファイル名は「ワクチン_ボツ図面.pptx」で、いつものところに置いておくので、忘れないように > 私