161022

Python vs C#


”重い処理は C#で書くと軽くなって処理が早いのでコンポーネント実装を移植するだけの作業がある”
とくま事務所からの噂きいたので50x50x50の点オブジェクトを作る処理で実験。

grasshopperとghPythonとC#など

f:id:ysok_na:20161022195610j:plain


写真上から
grasshopper : 330ms (2%)

ghPython : 10.9s (85%)

C# : 1.2s (9%)

(grasshopperのところは他にもseriesなどのコンポーネントもあるので、もう少しかかる(ほぼゼロに近いが))



結果として、今回の作業だと、C#は、Pythonよりもはやいが、
grasshopperのコンポーネントで直接やったほうが早かった。

50x50x50 ならば コンポーネントが早いが、1万とかになると、cs が早かった。

  1. + + + +


以下、そーす

Python

(追記)これは、RhinoPython でラップされた rhinoscriptsyntax で書いているので遅い。Rhino.Geometry で書いた方がいい。ループも避けたほうがいい。

import rhinoscriptsyntax as rs

a = []

for i in range(x):
    for j in range(x):
        for k in range(x):
            point = rs.AddPoint(i,j,k)
            a.append(point)

C#

  private void RunScript(int x, ref object A)
  {
    List<Point3d> pts = new List<Point3d>();

    for (int i = 0; i < x; i++){
      for (int j = 0; j < x; j++){
        for (int k = 0; k < x; k++){
          Point3d tempPt = new Point3d(i, j, k);
          pts.Add(tempPt);
        }
      }
    }
    A = pts;
  }


(さらに追記、2022)
複数の処理を書くときにコンポーネントの中でデータをハンドルし要らない中間データをコンポーネントの外に出さない(表示もしない)ようにすると、
要らないものが描画のプロセスにかからないのでかなりパフォーマンスが良くなる。
また、RhinoCommon 経由でプロパティから抜けるもの関数使わずに情報が抜けるのでそれもパフォーマンスの改善につながる。

ghPython error : no module named perlin

ghPython Component
Python Module Import Error

ghPython コンポーネントの、
モジュールのインポートでエラーが出る。


nature of code
NOC Python Grasshopper: 06 2d Perlin Noise - YouTube

import rhinoscriptsyntax as rs
import perlin

sn = perlin.SimplexNoise()

pList = []

for i in range(x):
    for j in range(y):
        perVal = sn.noise2(i*scaleX,j*scaleY)
        point = rs.AddPoint(i,j,perVal)   
        pList.append(point) 
     
a = pList


error message: no module named perlin

add perlin.py
github.com


C:\Users\xxx\AppData\Roaming\McNeel\Rhinoceros\5.0\Plug-ins\IronPython (xxx)\settings\lib

ここに入れておく

・-・-・-・

同様に、
PostgreSQL 用の、psycopg2 とかもこの場所に入れる。

initd.org





(終わり)

160825

ABC of Incremental Housing

プリツカー賞アレハンドロ・アラヴェナのプロジェクト

 

自身が設計した集合住宅の図面をオープンソース化し、

お金が少ないところでも快適な生活環境を整えることができるように手助けする。

 

アラヴェナの事務所、ElementalのABC of Incremental Housingのプレス(http://www.elementalchile.cl/en/projects/abc-of-incremental-housing/

以下、英文が原文、日本語文が訳したもの。

ABC of Incremental Housing

Out of the 3 billion people living in cities today, 1 billion is under the line of poverty. By 2030 out of the 5 billion people that will be living in cities, 2 billion are going to be under the line of poverty. That means that we will have to build a 1 million people city per week with 10,000 dollars per family. Given the magnitude of the housing shortage, we won’t solve this problem unless we add people’s own resources and building capacity to that of governments and market. That is why we thought of putting in place an OPEN SYSTEM able to channel all the available forces at play. In that way people will be part of the solution and not part of the problem.

今日の都市には30億人の人が住み、10億人が貧困の基準を下回る。2030年には50億人が都市に住むようになり、20億人が貧困の基準を下回ることになる。それは100万人の都市を1週間で、1家族あたり10000ドルで建てなければならないことを意味する。住宅不足の重大さを考えると、政府や市場が人材と建材を投入しない限り、我々はこの問題を解決することができない。遊びの勢いをその解決に向けることができることが、オープンシステムとすると考えた理由だ。このようにして、人々が問題の一部でなく、解決策の一端を担うこととなる。

 

On the other hand, it is a fact that available resources are not enough. To face such scarcity of means, the market tends to do two things: Reduce and Displace; reduce the size of the houses, threatening the quality of life of its inhabitants, and displace them to underserved peripheries where land costs nothing, segregating people from the opportunities that made them come to cities in the first place. In order to face scarcity we propose a principle of INCREMENTALITY.

一方で、利用できる資源(ここではお金と時間)は、充分ではないのが事実だ。そのことに直面すると、市場は、減らすこと、置き換えること、この2つをする傾向がある(家のサイズを小さくするこし、 住人の生活の質を脅かす、土地代のかからない都市の周辺へ移動させる、まず第一に人々を都市に来る機会から遠ざける)。この住宅不足の問題にに直面するにあたり、我々は、INCREMENTALITY(増加性)の原理を提案する。

 

If you can´t do everything, focus on:

A. What is more difficult

B. What cannot be done individually

C. What will guarantee the common good in the future

もし、あなたが、このすべてをできないのならば

A. より難しいこと

B. 個人ではできないこと

C. 将来の公益を保証すること

 

We identified 5 design conditions as the ABC of incremental housing:

1. Good location: dense enough projects able to pay for expensive well located sites.

2. Harmonious growth in time: build strategically the first half (partition structural and firewalls, bathroom, kitchen, stairs, roof) so that expansion happens thanks to the design and not despite it. Frame individual performances and actions, so that we get a customization instead of deterioration of the neighborhood.

3. Urban layout: introduce in between private space (lot) and public space (street), the collective space, not bigger than 25 families, so that social agreements can be maintained.

4. Provide structure for the final scenario of growth (middle class) and not just for the initial one.

5. Middle-class DNA: plan for a final scenario of at least 72m2 or 4 bedrooms (3x3m), with space for closet or double bed, bathrooms should not be at the front door (which is the typical case to save pipes) but where bedrooms are; they may include a bathtub and not just a shower receptacle and space for washing machine; there should be possibility of parking place for a car. None of this is even close to be the case in social housing nowadays.

我々は、ABC OF INCREMENTAL HOUSINGというプロジェクトについて、5つのデザインの条件を確認した。

1. 良い立地。高価な良い土地(の代金)を支払うにも充分な密度の濃いプロジェクトである

2. 時間の中での調和のとれた成長。前半に戦略的に作ったにもかかわらず(区画ごとの躯体、防火壁、浴室、キッチン、階段、屋根)、デザインのおかげで拡張が起こる。個人の振る舞いや行動から、我々はカスタマイズされる。

3. 都市の配置。プライベートな場所と、公共の場所の間に、集団的空間というものを導入し、それにより、社会的な調和を維持できる。

4. 最初の状態のためでなく、成長の最終的なシナリオに向けて躯体を提供する。

5. 中流クラスのDNA。最終的なシナリオは、最低72平米または、3mX3mの4つの寝室とし、クローゼットまたはダブルベッドがある。浴室から寝室へのドアがあるべきではない。(寝室の)ドアからはバスタブではなく、脱衣場、洗濯機置き場も含めているスペースがあるはずだ。車を停めることが可能な場所がなければならない。最近の公共住宅の場合、このどれもがない。

 

In other words, make sure you balance: low-rise high density, without overcrowding, with possibility of expansion (from social housing to middle class dwelling).

言い換えると、低層でその密度が過密でなく、拡張可能で、(公共住宅と中流階級の住居の間で)バランスを取ろうとする。

 

HERE you will find 4 examples, with four different designs that pursue the same goals and principles. From now on they are public knowledge, an open source that we hope will be able to rule out one more excuse for why markets and governments don’t move in this direction to tackle the challenge of massive rapid urbanization. These designs may require to be adjusted to comply with local regulations and structural codes, follow local realities and use pertinent building materials. But they are knowledge that we have tested, that has proved to be beneficial to communities and that have been implemented accepting very pressing budget and policy constraints.

この4種は、同じ目的や同じ原理を追求した4つの設計だ。このオープンソース化により、市場や政府が、大規模で即急な都市作りの課題に取り組むという方向を取らないことの、これ以上の言い訳を排除できると、我々は望んでいる。いずれの設計も、現地の規制や構造的な規定に従うように調整すること、現地の実情に合わせ、適切な材料を使うことが必要だろう。しかし、これらは、我々がテストして、社会に有益であることが証明し、圧迫された予算や政策の制約を受け入れて実施されたと知られている。

 以上、全訳おわり。