<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Just a Note</title>
        <link>https://shnarazk.now.sh</link>
        <description>a collection of memo</description>
        <lastBuildDate>Tue, 17 Dec 2019 08:26:16 GMT</lastBuildDate>
        <docs>http://blogs.law.harvard.edu/tech/rss</docs>
        <generator>nuxtjs/feed</generator>
        <item>
            <title><![CDATA[Solver Development Log]]></title>
            <link>https://shnarazk.now.sh/2019/2019-12-17-blog</link>
            <guid>https://shnarazk.now.sh/2019/2019-12-17-blog</guid>
            <pubDate>Tue, 17 Dec 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[# はじめに
自由気ままに研究をする生活は思ったほど自堕落でも非生産的でもなくそれなりにコミットを繰り返す生活ではあるけども、一体何を今週していたのか後で振り返ってもよくわからないまま今年が終わろうとしている。。おそらく1年後には「今年も早かった。何をしていたのか全然覚えていないなあ」ということになってしまうのは必定。やはり何か文章時な足跡は残した方がいいのではと思う。

記録メディアになりそうな世間で広く使われるWebサービスを見回してみると、Twitterはあまりにも時間軸に縛られむしろ文脈が霧散してしまう。Github Issueは実行前の決意表明なり問題意識が結論なく浮かび上がっているだけで知識の蓄積には程遠い（ような使い方しか個人的にはできていない）。Mediumは首尾一貫したそして成功したストーリーでないといけない雰囲気がある。そして、ここはメモに特化しすぎて日記ではない。まあ]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Nix on Catalina]]></title>
            <link>https://shnarazk.now.sh/2019/2019-10-08-nix-on-catalina</link>
            <guid>https://shnarazk.now.sh/2019/2019-10-08-nix-on-catalina</guid>
            <pubDate>Thu, 17 Oct 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[Catalinaでは'/'にディレクトリが作れなくなってしまったので
`/nix`がどうにもならんことになってしまった。
[Discourseのトピック](https://discourse.nixos.org/t/current-status-of-nix-on-macos-catalina/4286/2)によれば、
パーティションを作ってマウントすることが必要らしい（[参考](https://github.com/NixOS/nix/issues/2925)）。
うーむ、どうもこれしかなさそうなんだけど、
もうちょっとやり方が確定するまでメインマシンのアップグレードはしばらく待ってみようか。

ちなみに現在、Nixで（メインマシンに）インストールしているものは以下の通り。

- **coreutils-8.31** -- あって当然のGNU系のオプションを使うために重要
- **ema]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Directions for the next Splr]]></title>
            <link>https://shnarazk.now.sh/2019/2019-09-20-splr015</link>
            <guid>https://shnarazk.now.sh/2019/2019-09-20-splr015</guid>
            <pubDate>Fri, 29 Nov 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[- https://gitlab.com/shnarazk/SAT/splr/issues/90

1. global control of restart
  'global'は大局観ってやつ。`restart_step` の存在はやはり気になる。今のソルバーはまだ何かに気づけていない。
1. [solved by 0.1.5] a better bounded var-rewarding mechanism
  ASIDS, CHBどちらも確認済みではあるのだが。ただやる意味あるのかちょっと疑問に思ってきた。
  時間変化するのだから、求解直後の値を見てもそこには最終ステップを解くのに必要だった情報しか残っていないと考えるべきだろう。
  従って、最適な値分散なんてものは存在しない。そこに至るまでの履歴も重要。
  もう一つ、zero-sum rewardingについても検討のこと。
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Splr-0.1.4 released]]></title>
            <link>https://shnarazk.now.sh/2019/2019-09-14-splr014</link>
            <guid>https://shnarazk.now.sh/2019/2019-09-14-splr014</guid>
            <pubDate>Sat, 14 Sep 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[2019-09-14にsplr-0.1.4をリリースした。

- https://github.com/shnarazk/splr/
- https://crates.io/splr/

性能劣化を極力抑えて、いくつかのバグを取って今後の拡張のための足回りを固めたリリース。
0.1.3以降の半年は（とんでもなく）頑張ったのだけど、結局性能改善には繋がらなかった。ということで0.2.0に向けてのTODOは、

- var rewarding/restart policy: どうしてもどんどん値が大きくなっていくVSIDSはやめたいよねえ
- usage of global statistics: これは問題の分類に使うべきなんだろうけど、成果が出るまでに必要な計算リ
  ソースがとてもまかなえないだろう。
- SAT competition 2019の情報収拾：もうタダでproceeding]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A trait definition with lifetimes]]></title>
            <link>https://shnarazk.now.sh/2019/2019-08-08-rust-lifetime</link>
            <guid>https://shnarazk.now.sh/2019/2019-08-08-rust-lifetime</guid>
            <pubDate>Thu, 08 Aug 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[あるプログラムでアルゴリズムのバリエーションを併用するため、以下のトレイトが必要になったとしよう。

```rust
pub trait RestartHeuristics {
    type Item;
    fn add(&mut self, item: Self::Item);
    ...
```

ここで、実装ごとにメソッド`add`に渡す引数を変えたいので、関連型`Item`を引数の型としてもたせた。
例えば、以下のような実装を実現したい。

- 単なる数値(`f64`)を受け取って計算する`add`
- 何か構造体へのmut pointer(`&mut Var`)をもらってそれに対して変更を加えながら計算する`add`

それぞれ以下のような定義になった。

```rust
impl RestartHeuristics for RestartByLBD {
    ty]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Consideration about Restart (2019-07-31)]]></title>
            <link>https://shnarazk.now.sh/2019/2019-07-31-restart</link>
            <guid>https://shnarazk.now.sh/2019/2019-07-31-restart</guid>
            <pubDate>Tue, 10 Sep 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[### これまでのまとめ

- [First UIP distribution (2019-07-21)](/2019/2019-07-21-first-UIP-distribution/)
- [Development of Var activities (2019-07-11)](/2019/2019-07-11-varact-distribution/)
- [Some Stats about Partial Restart (2019-08-04)](/2019/4f2a110a30ee837b/obs/)

求解状況の平滑化された数値化を実現して、それをリスタートに反映させようとしてきた。
しかし、リスタートは本当に必要なのだろうか。
途中で打ち切るという非連続な、余計なものを持ち込むから制御が複雑怪奇になるのであって、
適切なバックトラックレベルの計算の中に部分的リスタートとし]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[About Observable]]></title>
            <link>https://shnarazk.now.sh/2019/2019-07-31-observable</link>
            <guid>https://shnarazk.now.sh/2019/2019-07-31-observable</guid>
            <pubDate>Sun, 04 Aug 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[Javascript版jupyterのようなものの一つの[Observable](https://observablehq.com/)。
可視化の結果を貼り付けられるように、Nuxtベースのこのブログに組み込めないか現在考え中。
とりあえず[こういうこと](https://observablehq.com/d/1cbb7a450b192e69)ができるなら、
やる価値はありそうだ。

まず、以下のコードでObservableのノートは一つのJavascriptにexportできるらしい。

```js
<script type="module">
import {Runtime, Inspector} from "https://cdn.jsdelivr.net/npm/@observablehq/runtime@4/dist/runtime.js";
import notebook fr]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[First UIP distribution (2019-07-21)]]></title>
            <link>https://shnarazk.now.sh/2019/2019-07-21-first-UIP-distribution</link>
            <guid>https://shnarazk.now.sh/2019/2019-07-21-first-UIP-distribution</guid>
            <pubDate>Wed, 24 Jul 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[- [Development of Var activities (2019-07-11)](/2019/2019-07-11-varact-distribution/)


ふと思ったのだが、first UIP になりうる変数はどれくらいだろう。
industrial problems でのコア（バックボーン？）はとても小さいはずだが、そもそもそれは矛盾変数はどれくらいであると言うことを意味するのだろう？　
少ないようでもあり、いや、複数回矛盾を起こすものが少ないだけのような気もする。
1 回の矛盾に対して 1 つの first UIP が決まるのだからそして別に 1 対 1 ではないのだから、
first UIP になる変数の個数は意外に小さいのではなかろうか。

CHB4 でやってみた。

まず解ける問題での時間進化。

![](/img/2019/07-21/T56.png)

!]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[EMA of LBD]]></title>
            <link>https://shnarazk.now.sh/2019/2019-07-15-splr</link>
            <guid>https://shnarazk.now.sh/2019/2019-07-15-splr</guid>
            <pubDate>Mon, 15 Jul 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[学習節の平均 LBD は大きく揺れすぎ。節削減の影響もあるので節の持つ数値は使いにくい気がする。
そんなこともあって、統計処理したからといって探索パラメータとしては使いにくいのではないだろうか。
むしろ個々の学習節の生データで戦略を決定した方がいいかもしれない。ともあれ、データを取ってみよう。

まずは、枝刈り（悪い状態からの離脱）の効果に関して。

#### A. CHB branch から普通のやつ

```
v360-c1530: 9 SATs + 1 UNS

T56.2.0.cnf                                3145220,10854665 |time:   721.82
 #conflict:     319339, #decision:      1751376, #propagate:      965031514
  Assignmen]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Development of Var activities (2019-07-11)]]></title>
            <link>https://shnarazk.now.sh/2019/2019-07-11-varact-distribution</link>
            <guid>https://shnarazk.now.sh/2019/2019-07-11-varact-distribution</guid>
            <pubDate>Sun, 25 Aug 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[以下は変数活性度の分散（青色の線）と変数割当量のEMA（緑色の線）の時間変化である。

![](/img/2019/07-11/vadist-fixedvars.png)

どうもこの両者には負の相関があるらしい。変数割当てが減ると分散は高くなる。
これは、

- リスタートにより活性度が高い変数群の割当てを優先する。
  他の変数の割当てはなくなり、全体としての割当量は減少する。
- リスタート後もその矛盾する変数に関連する変数のみ活性度が繰り返し増加する。
  従って活性度の分散は大きくなる。

ということで説明できるだろう。

難しい山を乗り越えたからこそ（変数割当てに関する）進捗があるらしい。
逆に、割当量が小さくなりながら（困難な矛盾が解決して）新しい変数が見つかる。
とは言え、決して小ささを維持しようとしているわけではない。
小さくなった後では大したことはできないと思う。

逆]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Can't bind an expression to v-scroll-to]]></title>
            <link>https://shnarazk.now.sh/2019/2019-06-26-vue-scrollto</link>
            <guid>https://shnarazk.now.sh/2019/2019-06-26-vue-scrollto</guid>
            <pubDate>Wed, 26 Jun 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[[vue.js](https://vuejs.org) + [nuxt.js](https://nuxtjs.org/)で作った
このblog（実はつい最近hugoから変更しました）のtagページで
タグ一覧からそのセクションへのページ内ジャンプを実現するために
[vue-schrollto](https://www.npmjs.com/package/vue-scrollto)
を入れてみた。

もともとのタグ一覧の生成コードはこんな感じ：

```javascript
<div v-for="tag in tags" :key="tag">
#{{ tag }},
</div>
```

これを `v-scroll-to` でジャンプできるように変えてみた：

```javascript
<template v-for="tag in tags">
  <nuxt-link :key=]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Connect mongoDB Atlas from Rust]]></title>
            <link>https://shnarazk.now.sh/2019/2019-05-31-connect-mongodb-atlas-from-rust</link>
            <guid>https://shnarazk.now.sh/2019/2019-05-31-connect-mongodb-atlas-from-rust</guid>
            <pubDate>Fri, 31 May 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[クラウドの勉強をしようと思って無料データベース[mongoDB Atlas](https://cloud.mongodb.com/)にアカウントを作ってみた。

mongoDBを選んだのは、以下の理由から。

- [nlp100](http://www.cl.ecei.tohoku.ac.jp/nlp100/)の課題で、
自前のmongoDBをrustから利用するプログラムを作ってた
- [Zeit@now](https://zeit.co/)からも[統合](https://zeit.co/blog/zeit-now-integrations-platform)できる

セットアップはサクサクできて、あとはプログラムにconnectするだけ。
もちろん、ちゃんと参考例が表示される。

![](/img/2019/05-31/mongodb-1.png)

例えば**Connect Your]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Compiling Rust programs that use openssl]]></title>
            <link>https://shnarazk.now.sh/2019/2019-03-28-rust-programs-using-openssl</link>
            <guid>https://shnarazk.now.sh/2019/2019-03-28-rust-programs-using-openssl</guid>
            <pubDate>Thu, 28 Mar 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[The simplest way is using the old version of openssl.

```
$ pacman -Ss openssl
core/openssl 1.1.1.b-1 [installed]
    The Open Source toolkit for Secure Sockets Layer and Transport Layer Security
core/openssl-1.0 1.0.2.r-1 [installed]
    The Open Source toolkit for Secure Sockets Layer and Transport Layer Security
```

Select it by environment variables.

```
OPENSSL_LIB_DIR=/usr/lib/openssl-1.0]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Install Rust programs with resources on NixOS]]></title>
            <link>https://shnarazk.now.sh/2019/2019-03-22-rust-program-with-resources-on-nixos</link>
            <guid>https://shnarazk.now.sh/2019/2019-03-22-rust-program-with-resources-on-nixos</guid>
            <pubDate>Fri, 22 Mar 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[## 目標

同梱ファイルを参照するRustプログラムをNixOSにインストールしたい。

## 方法

1. build.rsで頑張る →試してません
1. 最終保存場所をソースに書き込む

ここでは2番目の手法についてメモしておきます。


## 前提条件

rustPlatform.buildRustProgramを使っている

## 実現手段

1. patchPhaseでsedで`$out`をソースに埋め込む
2. PostInstallで同梱ファイルを`$out`にコピーする

# 実例

[sat-bench](https://github.com/shnarazk/SAT-bench)はSATソルバーのベンチマークをするためのユーティリティなので、
複数のCNFファイルを同梱している。実行時にはこのファイルを参照することが必要。
しかし、そもそもcargoは実行ファイルしか]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Memo about @now/rust by Zeit]]></title>
            <link>https://shnarazk.now.sh/2019/2019-03-17-now</link>
            <guid>https://shnarazk.now.sh/2019/2019-03-17-now</guid>
            <pubDate>Sun, 10 Mar 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[## 準備

まずシステムを汚染しないようにnowをインストール：

```
npm config set prefix ~/.local/npm/
npm install -g now
ln -s ~/.local/npm/bin/now `/.local/bin/now
```

## 試行

[紹介ポスト](https://zeit.co/blog/introducing-now-rust)は色々と内容が古くなっているので[Document](https://zeit.co/docs/v2/deployments/official-builders/now-rust/)をたどる方がよい。

## Tips

### 要求: `$TOP/index.rs`ではなくsrc/の下においてcargoでコンパイルしたい。

now.jsonでビルド元を指定すればよい。

```json
   ]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GTK development on Nix on macOS]]></title>
            <link>https://shnarazk.now.sh/2019/2019-03-14-gtk-development-on-nix</link>
            <guid>https://shnarazk.now.sh/2019/2019-03-14-gtk-development-on-nix</guid>
            <pubDate>Thu, 14 Mar 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[## C

- sample target: https://developer.gnome.org/gtk3/stable/gtk-getting-started.html

Dive into the environment:

```shell
nix-shell -p gtk3 gcc pkgconfig
```

And compile:
```shell
gcc `pkg-config --cflags gtk+-3.0` -o example example.c `pkg-config --libs gtk+-3.0`
```

That works.

## Rust

- package: https://crates.io/crates/gtk  
   - Cargo.toml: `gtk = 0.5`  # 0.6 requires unstable channel]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build GNU Source-highlight supporting Rust for NixOS]]></title>
            <link>https://shnarazk.now.sh/2019/2019-03-10-source-highlight-Rust</link>
            <guid>https://shnarazk.now.sh/2019/2019-03-10-source-highlight-Rust</guid>
            <pubDate>Sun, 10 Mar 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[Let's Rust syntax highlighten in less!

1. We need to apply [a patch](https://gist.github.com/tav/3846383).
1. To apply the patch, make a simple overlay(~/.config/nixpkgs/overlays/source-highlight.nix) against [the expression](https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/text/source-highlight/default.nix) in the master branch.
1. But somehow I failed to build it due to lack of makeinfo.]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Post to Discord from shell]]></title>
            <link>https://shnarazk.now.sh/2019/2019-03-07-post-to-discord</link>
            <guid>https://shnarazk.now.sh/2019/2019-03-07-post-to-discord</guid>
            <pubDate>Thu, 07 Mar 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[- 第1引数はメッセージ本体
- 第2引数には投稿者名

```shell
#!/bin/sh -norc
message=${1:-"empty message"}

if [ "$2" == "" ] ;
then
    payload="{\"content\":\"${message}\"}"
else
    payload="{\"username\":\"$2\",\"content\":\"${message}\"}"
fi

url='https://discordapp.com/api/webhooks/aaa/bbb'
curl -X POST -H "Accept: application/json" -H "Content-type: application/json" -d "${payload}" ${url}
```

- `url`には先に取得しておいた]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NixOS administration]]></title>
            <link>https://shnarazk.now.sh/2019/2019-03-06-nixos-administration</link>
            <guid>https://shnarazk.now.sh/2019/2019-03-06-nixos-administration</guid>
            <pubDate>Wed, 06 Mar 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[- Where's configuration: /etc/nixos/configuration.nix
   - The option `system.nixos.stateVersion` has been renamed `system.stateVersion`.
- Choose kernel version: https://nixos.wiki/wiki/Choose_your_kernel_on_NixOS
- how to update:
```
nixos-rebuild switch --upgrade
```
- 'nix search' is faster than `nix-env -qa`.]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running Glucose in benchmark mode]]></title>
            <link>https://shnarazk.now.sh/2019/2019-03-04-benchmarking-glucose</link>
            <guid>https://shnarazk.now.sh/2019/2019-03-04-benchmarking-glucose</guid>
            <pubDate>Mon, 04 Mar 2019 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[Using my [patched](https://gitlab.com/satisfiability01/glucose/tree/v.4.1) glucose, we can get more useful result.

```
glucose -cpu-lim=TIMEOUT -verb=0 a.cnf result.file
```

- `-cpu-lim=TIMEOUT` ; you can't insert whitespaces.
- no progress report if `verb`== 0.

Now the result file contains the stats information.

```
c restarts              : 2 (2201 conflicts in avg)
c blocked restarts      :]]></content:encoded>
        </item>
    </channel>
</rss>