コード例 #1
0
def main():
    in_data = input()
    in_data = list(map(int, in_data.split()))
    matrix = []

    for i in range(in_data[1]):
        matrix.append(list(map(int, input().split())))

    mx1 = Matrix(matrix)
    Search = Compression(mx1)
    Search.find_minima(in_data[0], in_data[3])

    for i in Search.get_best_solution():
        for j in i:
            print(j, file=sys.stderr, end=' ')

        print(file=sys.stderr)

    print(Search.get_best_distance())
コード例 #2
0
##
## Copyright 2020 Centreon
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
##     http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
## For more information : [email protected]
##
from compression import Compression
import sys

if len(sys.argv) < 2:
    print("Usage: view-retention.py retention_file")

if __name__ == '__main__':
    compress = Compression(sys.argv[1])
    compress.unserialize()
コード例 #3
0
ファイル: nogui.py プロジェクト: PiRK/compaction_bands
##rs = StratifiedRockSample(nlines = 55, ncols = 23, leq0 = 1, Rl = 0.94, A0 = 1,
##                          Ka = 1, E0 = 1, Ke = 1, F0cr = 0.032, D = 0.03,
##                          F1cr = 0.028, dip = 20, t0 = 4, t1 = 8)
rs = RockSample(nlines=71,
                ncols=31,
                leq0=1,
                Rl=0.94,
                A0=1,
                Ka=1,
                E0=1,
                Ke=1,
                F0cr=0.03,
                D=0.1)

cpr = Compression(rs, F0x=0, Kbc=20, d0=0., delta_d=0.005, max_comp=50)

delta_comp_rate = 2


def draw_sample():
    "fonction d'affichage de l'echantillon"
    DisplayRS(rs, scale=8, d=cpr.d)


iteration = 0
dFy = DisplayCurve(xlegend="\u03B5(%)", ylegend="Fy", yscale=10000, ymax=0.05)

cpr.d += cpr.delt_d
strain = cpr.d / rs.h0 * 100
comp_rate = rs.comp_count / rs.nsprings * 100
コード例 #4
0
 def setUp(self):
     self.comp = Compression(True)
コード例 #5
0
 def setUp(self):
     self.comp = Compression(False)
コード例 #6
0
ファイル: gui.py プロジェクト: PiRK/compaction_bands
    def run(self):
        '''Fonction executee quand l'utilisateur clique sur "Run".'''
        self.stopped = False
        # Creation de l'echantillon en testant la validite des parametres
        # fournis par l'utilisateur
        try:
            rs = RockSample(self.L.get_val(), self.C.get_val(),
                            self.leq0.get_val(), self.Rl.get_val(),
                            self.A0.get_val(), self.Ka.get_val(),
                            self.E0.get_val(), self.Ke.get_val(),
                            self.F0cr.get_val(), self.D.get_val())
            #rs.debug = True
            print(rs)

            cpr = Compression(rs, self.F0x.get_val(), self.Kbc.get_val(),
                              self.d0.get_val(), self.delt_d.get_val(),
                              self.max_comp.get_val())
            delta_comp_rate = self.delta_comp.get_val()
        except:
            # si une erreur dans les parametres est detectee, soulever
            # l'erreur pour interrompre le programme
            raise

        def draw_sample():
            "fonction d'affichage de l'echantillon"
            DisplayRS(rs, scale=self.scale.get_val(), d=cpr.d)

        iteration = 0
        dFy = DisplayCurve(parent=self,
                           xlegend="\u03B5(%)",
                           ylegend="Fy",
                           yscale=10000,
                           ymax=0.05)

        cpr.d += cpr.delt_d
        strain = cpr.d / rs.h0 * 100
        comp_rate = rs.comp_count / rs.nsprings * 100
        comp_rate_next_display = 0

        first_compacted_displayed = False

        # Commencer la compression
        while comp_rate < cpr.max_comp:
            if self.stopped:
                print("Stopped.")
                return
            iteration += 1

            cpr.solve()

            test_comp_count = rs.comp_count
            comp_rate = rs.comp_count / rs.nsprings * 100

            # Affichage
            dFy.add_point(strain, cpr.Fy)
            if not first_compacted_displayed and comp_rate > 0.:
                threading.Thread(target=draw_sample).start()
                first_compacted_displayed = True
                time.sleep(2)
            if comp_rate >= comp_rate_next_display:
                threading.Thread(target=draw_sample).start()
                comp_rate_next_display += delta_comp_rate
                time.sleep(2)

            print("\nIteration %5d: " % iteration)
            print("\tCompaction rate:", comp_rate)

            # Incrementer le deplacement si aucun ressort n'a ete compacte
            if cpr.rs.comp_count == test_comp_count:
                cpr.d += cpr.delt_d
                strain = cpr.d / rs.h0 * 100
                print("\tStrain: %f" % strain)

        threading.Thread(target=draw_sample).start()
        time.sleep(2)
        print("Done.")
コード例 #7
0
def test_it_compresses_1():
    compression = Compression()
    input_list = ["a","a","b","b","c","c","c"]

    assert compression.compress(input_list) == 6
コード例 #8
0
def test_it_initializes():
    compression = Compression()

    assert isinstance(compression, Compression)
コード例 #9
0
def go(deep):
    return Compression(deep).count(INPUT.read().replace('\n', ''))