I'm very new to NetLogo, and am attempting to incorporate bias into the Preferential Attachment model by making the probability of attachment depend on a node's color as well as degree; nodes will have a % bias (determined by a slider) to choose to link with a node of the same color as themselves.
So far, I've made the nodes heterogenous, either blue or red, with blue being ~70% of the population:
to make-node [old-node]
create-turtles 1
[
set color red
if random 100 < 70
[ set color blue ]
if old-node != nobody
[ create-link-with old-node [ set color green ]
;; position the new node near its partner
move-to old-node
fd 8
]
]
end
I understand the main preferential attachment code, which has the new node select a partner proportional to its link count:
to-report find-partner
report [one-of both-ends] of one-of links
end
Where I encounter issues is in the following procedure. Sometimes it works as expected, but sometimes I get the following error message: OF expected input to be an agent or agentset but got NOBODY instead - regarding the statement "[one-of both-ends] of one-of links" under my 'while' loop.
to make-node [old-node]
create-turtles 1
[
set color red
set characteristic 0
if random 100 < 70
[ set color blue
set characteristic 1]
if (old-node != nobody) and (random 100 < bias-percent) and (any? turtles with [color = red]) and (any? turtles with [color = blue])
[
while [characteristic != [characteristic] of old-node]
[
set old-node [one-of both-ends] of one-of links
]
]
if old-node != nobody
[ create-link-with old-node [ set color green ]
;; position the new node near its partner
move-to old-node
fd 8
]
]
end
Any help is appreciated!!!
I am working on an image processing project in python in which I am required to change the coordinate system
I thought it is analogous to matrix transformation and tried but it is not working, I have taken the coordinates of the red dots
Simply subtract by 256 and divide by 512. The connection is that you see values of 256 get mapped to 0. Therefore, 0 gets mapped to -256, 256 gets mapped to 0 and 512 gets mapped to 256. However, you further need the values to be in the range of [-0.5, 0.5]. Dividing everything by 512 finishes this off.
Therefore the relationship is:
out = (in - 256) / 512 = (in / 512) - 0.5
Try some values from your example input above to convince yourself that this is the correct relationship.
If you want to form this as a matrix multiplication, this can be interpreted as an affine transform with scale and translation, but no rotation:
[ 1/512 0 -0.5 ]
K = [ 0 1/512 -0.5 ]
[ 0 0 1 ]
Take note that you will need to use homogeneous coordinates to achieve the desired result.
For example:
(x, y) = (384, 256)
[X] [ 1/512 0 -0.5 ][384]
[Y] = [ 0 1/512 -0.5 ][256]
[1] [ 0 0 1 ][ 1 ]
[X] [384/512 - 0.5] [ 0.25 ]
[Y] = [256/512 - 0.5] = [ 0 ]
[1] [ 1 ] [ 1 ]
Simply remove the last coordinate to get the final answer of (0.25, 0).
Very weird "crash". I am using
oscillator = AKOperationGenerator(channelCount: 2, operations: { parameters in
let portamentoOp = parameters[0].portamento(halfDuration: parameters[1])
let sineOp = AKOperation.sineWave(frequency: portamentoOp, amplitude: parameters[2])
let sawOp = AKOperation.sawtoothWave(frequency: portamentoOp, amplitude: parameters[2])
return [sawOp, sineOp] //saw on left, sine on right.
})
oscillator?.parameters = [440.0, 0.001, 1.0, 0.99]
To generate tones in my app, however after couple minutes of "playing" it just stops, no crash, no error nothing. Only thing I can do is to unplug headphones and plug them back again, setup audio again and it starts.
This is logs from device:
default 20:32:42.906934+1200 mediaserverd CAReportingClient.mm:470:-[CAReportingClient sendMessage:category:type:reporters:]: message {
"inf_frames" = 0;
"issue_type" = NonFinite;
"nan_frames" = 1083;
node = "PreDSP - { [ type: phpw; conn: 1; rout: 1 ] }";
"rtaid_client" = VA;
}: (
133143986217
)
default 20:32:42.907327+1200 mediaserverd AudioIssueDetectorManager.cpp:250:HandleAudioIssue: RTAID [ use_case=Generic issue_type=NonFinites clientID=VA node=PreDSP - { [ type: phpw; conn: 1; rout: 1 ] } ] -- [ nan_frames=1083 inf_frames=0 ]
default 20:32:42.909321+1200 rtcreportingd sendMessageWithDictionary: Sending message for session 41
default 20:32:42.909588+1200 rtcreportingd <private>(sendMessage): realtime is 0
default 20:32:42.909701+1200 rtcreportingd <private>(sendMessage): Batching 3, 1, 1
default 20:32:42.910209+1200 mediaserverd CAReportingClient.mm:470:-[CAReportingClient sendMessage:category:type:reporters:]: message {
"inf_frames" = 0;
"issue_type" = NonFinite;
"nan_frames" = 1083;
node = "PostDSP - { [ type: phpw; conn: 1; rout: 1 ] }";
"rtaid_client" = VA;
}: (
133143986217
)
default 20:32:42.911062+1200 mediaserverd AudioIssueDetectorManager.cpp:250:HandleAudioIssue: RTAID [ use_case=Generic issue_type=NonFinites clientID=VA node=PostDSP - { [ type: phpw; conn: 1; rout: 1 ] } ] -- [ nan_frames=1083 inf_frames=0 ]
default 20:32:42.913038+1200 rtcreportingd sendMessageWithDictionary: Sending message for session 41
default 20:32:42.913957+1200 rtcreportingd <private>(sendMessage): realtime is 0
default 20:32:42.914127+1200 rtcreportingd <private>(sendMessage): Batching 3, 1, 1
default 20:32:42.935883+1200 sharingd Identification starting maintenance timer
default 20:32:42.937060+1200 rapportd BLE device changed: SFDevice ID a6207782-86f9-e3fe-2ca2-fc6f74e80bd4, IDS B710183A, RSSI -47 (-44)*N, Nm 'Tomas’s MacBook Pro', Md 'MacBookPro16,1', DuetSync, PairedBT, PairedSys Conjectured, rapportID B710183A-9C32-45F2-B698-72BBC69FED93, WiFiP2P, DF 0x88 < MyiCloud AirDrop >
default 20:32:42.938332+1200 sharingd CompanionLink changed: IDS B710183A, Nm 'Tomas’s MacBook Pro', Md 'MacBookPro16,1'
default 20:32:43.009206+1200 powerlogHelperd {"msg":"CLCopyAppsUsingLocation", "event":"activity"}
default 20:32:43.038177+1200 nsurlsessiond Triggering periodic update to powerlog for client <private>
default 20:32:43.260560+1200 DTServiceHub Heartbeat
I've currently got a list defined as:
environment.systemPackages = with pkgs; [
acpi
ag
alacritty
audacity
awscli
bash
breeze-gtk
cabal-install
];
How would I go about defining two lists and then merging them to set the environment.systemPackages value?
I'd like to split the list so it's easier to manage groups of related packages.
https://nixos.org/manual/nix/stable/expressions/language-operators.html
The ++ operator:
nix-repl> [1 2 3] ++ [5 6]
[ 1 2 3 5 6 ]
Code example:
let
unstable = import <unstable> {
config = config.nixpkgs.config;
};
examplePkgs = with pkgs; [
bash
];
in
{
environment.systemPackages = with pkgs; [
google-chrome
]
++ examplePkgs;
I was on the site rise4fun a few weeks ago and they had a python code that converted a sudoku puzzle input file to z3. I checked again today and the file is gone, and was wondering if anyone had this code or could explain to me how to implement it. Thanks!!
# 9x9 matrix of integer variables
X = [ [ Int("x_%s_%s" % (i+1, j+1)) for j in range(9) ]
for i in range(9) ]
# each cell contains a value in {1, ..., 9}
cells_c = [ And(1 <= X[i][j], X[i][j] <= 9)
for i in range(9) for j in range(9) ]
# each row contains a digit at most once
rows_c = [ Distinct(X[i]) for i in range(9) ]
# each column contains a digit at most once
cols_c = [ Distinct([ X[i][j] for i in range(9) ])
for j in range(9) ]
# each 3x3 square contains a digit at most once
sq_c = [ Distinct([ X[3*i0 + i][3*j0 + j]
for i in range(3) for j in range(3) ])
for i0 in range(3) for j0 in range(3) ]
sudoku_c = cells_c + rows_c + cols_c + sq_c
# sudoku instance, we use '0' for empty cells
instance = ((5,3,0,0,7,0,0,0,0),
(6,0,0,1,9,5,0,0,0),
(0,9,8,0,0,0,0,6,0),
(8,0,0,0,6,0,0,0,3),
(4,0,0,8,0,3,0,0,1),
(7,0,0,0,2,0,0,0,6),
(0,6,0,0,0,0,2,8,0),
(0,0,0,4,1,9,0,0,5),
(0,0,0,0,8,0,0,7,9))
instance_c = [ If(instance[i][j] == 0,
True,
X[i][j] == instance[i][j])
for i in range(9) for j in range(9) ]
s = Solver()
s.add(sudoku_c + instance_c)
if s.check() == sat:
m = s.model()
r = [ [ m.evaluate(X[i][j]) for j in range(9) ]
for i in range(9) ]
print_matrix(r)
else:
print "failed to solve"