Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/jacopobono/learning_cognitive_maps_code
24 February 2026, 16:03:07 UTC
  • Code
  • Branches (2)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/first_branch
    • refs/heads/main
    No releases to show
  • 5701fc7
  • /
  • utils_environment.py
Raw File Download Save again
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge
swh:1:cnt:ee4ed135c4e907a44e482f7bf486bc29f7935008
origin badgedirectory badge
swh:1:dir:5701fc7fe0b96ca0f3351dbf9c6f6ed4627884f1
origin badgerevision badge
swh:1:rev:8aed486bb756b5aed6085f9b2a60e49d65445904
origin badgesnapshot badge
swh:1:snp:3e11e29283bbaf71786af24d2d77c12596b6e584

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
Tip revision: 8aed486bb756b5aed6085f9b2a60e49d65445904 authored by jacopobono on 29 August 2021, 13:07:26 UTC
first commit
Tip revision: 8aed486
utils_environment.py
import numpy as np 

def f_generate_traj(no_states, starts, T, max_steps):
        
    #### Sample initial position 
    in_pos = np.random.choice(no_states, 1, p=starts)[0]
    #### Generate trajectory     
    traj = [None]*max_steps
    traj[0] = in_pos

    for i in range(max_steps-1):
        
        pi=T[traj[i],:]
        traj[i+1] = np.random.choice(len(pi), 1, p=pi)[0] #use len(p) for the non absorbing state (actually no_states+1 states)
        if traj[i+1] == traj[i]:
            del traj[i+2:]
            break
    return np.array(traj)

def f_generate_n_traj(no_states, starts, T, max_steps, Trials):
    traj_tot = [] 
    for i in range(Trials):
         traj_tot.append(f_generate_traj(no_states, starts, T, max_steps))
    return traj_tot 
    

def T_open_field(no_states):

    side_len = no_states**0.5
    T = np.zeros((no_states, no_states))
        
    for i in range(no_states):
        
        neighb_states = [i-side_len,i+side_len]
        
        if (i+1)%side_len != 0:
            neighb_states = neighb_states + [i+1]
        if i%side_len != 0:
            neighb_states = neighb_states + [i-1] 
            
        neighb_states = np.array(neighb_states)
        neighb_states = neighb_states[neighb_states>=0]
        neighb_states = neighb_states[neighb_states<no_states]

        for j in neighb_states:
            T[i][int(j)] = 1 
            
    T = (np.transpose(T))/np.sum(T, axis=1)
    T = (np.transpose(T))
    
    return T  

def T_add_absorbing_states(T, eps=0.1):
    
    no_states = np.size(T,axis=0)
    
    T_new = np.zeros((no_states+1,no_states+1))
    T_new[:-1,:-1] = T
    
    to_abs_states = np.arange(no_states)
    
    for abz in to_abs_states:
        cols = T_new[abz,:]!=0
        T_new[abz, cols] -=  eps/sum(cols)
        T_new[abz,-1] = eps

    T_new[-1,-1] = 1
    
    return T_new, no_states + 1

def T_open_field_with_absorbing_state(no_states, eps=0.1):
    
    T = T_open_field(no_states)
    T = T_add_absorbing_states(T, eps)
    
    return T 

def T_random_walk_linear_track(no_states):

    T = np.array([[i == j+1 or i == j -1 for j in range(no_states)] for i in range(no_states)])*1
    # add absorbing state 
    T_new = np.zeros((no_states+1,no_states+1))
    T_new[:-1,:-1] = T
    T_new[-2:, -1] = 1
    T_new[0, -1] = 1 
    T_new = np.divide(T_new, T_new.sum(axis = 1).reshape(no_states+1, 1))    
    return T_new  

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API