Loading ...
Sorry, an error occurred while loading the content.
 

A learning mechianism on the network

Expand Messages
  • zhannghui43
    Hello everyone: I want to biuld a model about a learning mechianism on the network, the agent s decision to buy or sell his assets not only depend on the
    Message 1 of 5 , Jan 31, 2012
      Hello everyone:
      I want to biuld a model about a learning mechianism on the network, the agent's decision to buy or sell his assets not only depend on the decisions of other agents who link with him buy also his own sentiment. however, i get a problem on the Netlogo, my codes as follows:

      to agent-decision
      ask turtles [
      ifelse (([weight] of links * sum [my-sentiment] of other turtles + news-sensitivity * news-qualitative-meaning + random-normal miu opinion-vol) > 0)
      [set my-sentiment 1
      set number-of-shares number-of-shares + 1] ;; Buy
      [set my-sentiment -1
      set number-of-shares number-of-shares - 1] ;; Sell
      ]
      end

      when i run the model, Netlogo says:* expected input to be a number but got the list. i knows there is a mistake about "[weight] of links * sum [my-sentiment] of other turtles", but i don't know how to deal with it.
      Appreciate for anyone's help
    • Jim Lyons
      ... If you want each turtle to compute the sum of each of its link s weight times the sentiment of the turtle linked to, I think that would be something like:
      Message 2 of 5 , Feb 1, 2012
        On Feb 1, 2012, at 2:11 AM, zhannghui43 wrote:

        I want to biuld a model about a learning mechianism on the network, the agent's decision to buy or sell his assets not only depend on the decisions of other agents who link with him buy also his own sentiment. however, i get a problem on the Netlogo, my codes as follows:

        to agent-decision
        ask turtles [
        ifelse (([weight] of links * sum [my-sentiment] of other turtles + news-sensitivity * news-qualitative-meaning + random-normal miu opinion-vol) > 0)
        [set my-sentiment 1
        set number-of-shares number-of-shares + 1] ;; Buy
        [set my-sentiment -1
        set number-of-shares number-of-shares - 1] ;; Sell
        ]
        end

        when i run the model, Netlogo says:* expected input to be a number but got the list. i knows there is a mistake about "[weight] of links * sum [my-sentiment] of other turtles", but i don't know how to deal with it.

        If you want each turtle to compute the sum of each of its link's weight times the sentiment of the turtle linked to, I think that would be something like:

        sum [weight * [my-sentiment] of other-end] of my-links

        HTH,
        Jim
      • zhannghui43
        ... Thank you very much
        Message 3 of 5 , Feb 7, 2012
          --- In netlogo-users@yahoogroups.com, Jim Lyons <jimlyons@...> wrote:
          >
          > On Feb 1, 2012, at 2:11 AM, zhannghui43 wrote:
          >
          > > I want to biuld a model about a learning mechianism on the network, the agent's decision to buy or sell his assets not only depend on the decisions of other agents who link with him buy also his own sentiment. however, i get a problem on the Netlogo, my codes as follows:
          > >
          > > to agent-decision
          > > ask turtles [
          > > ifelse (([weight] of links * sum [my-sentiment] of other turtles + news-sensitivity * news-qualitative-meaning + random-normal miu opinion-vol) > 0)
          > > [set my-sentiment 1
          > > set number-of-shares number-of-shares + 1] ;; Buy
          > > [set my-sentiment -1
          > > set number-of-shares number-of-shares - 1] ;; Sell
          > > ]
          > > end
          > >
          > > when i run the model, Netlogo says:* expected input to be a number but got the list. i knows there is a mistake about "[weight] of links * sum [my-sentiment] of other turtles", but i don't know how to deal with it.
          >
          > If you want each turtle to compute the sum of each of its link's weight times the sentiment of the turtle linked to, I think that would be something like:
          >
          > sum [weight * [my-sentiment] of other-end] of my-links
          >
          > HTH,
          > Jim
          >

          Thank you very much
        • zhannghui43
          ... Dear Jim: Thanks for your advice for my last question, it is useful to my work. I have a new question about reinforcement learning on Netlogo. I want to
          Message 4 of 5 , Feb 8, 2012
            --- In netlogo-users@yahoogroups.com, "zhannghui43" <zhannghui43@...> wrote:
            >
            >
            >
            > --- In netlogo-users@yahoogroups.com, Jim Lyons <jimlyons@> wrote:
            > >
            > > On Feb 1, 2012, at 2:11 AM, zhannghui43 wrote:
            > >
            > > > I want to biuld a model about a learning mechianism on the network, the agent's decision to buy or sell his assets not only depend on the decisions of other agents who link with him buy also his own sentiment. however, i get a problem on the Netlogo, my codes as follows:
            > > >
            > > > to agent-decision
            > > > ask turtles [
            > > > ifelse (([weight] of links * sum [my-sentiment] of other turtles + news-sensitivity * news-qualitative-meaning + random-normal miu opinion-vol) > 0)
            > > > [set my-sentiment 1
            > > > set number-of-shares number-of-shares + 1] ;; Buy
            > > > [set my-sentiment -1
            > > > set number-of-shares number-of-shares - 1] ;; Sell
            > > > ]
            > > > end
            > > >
            > > > when i run the model, Netlogo says:* expected input to be a number but got the list. i knows there is a mistake about "[weight] of links * sum [my-sentiment] of other turtles", but i don't know how to deal with it.
            > >
            > > If you want each turtle to compute the sum of each of its link's weight times the sentiment of the turtle linked to, I think that would be something like:
            > >
            > > sum [weight * [my-sentiment] of other-end] of my-links
            > >
            > > HTH,
            > > Jim
            > >
            >
            > Thank you very much
            >

            Dear Jim:
            Thanks for your advice for my last question, it is useful to my work. I have a new question about reinforcement learning on Netlogo. I want to ask the node reinforce the links' weight of its link-neighbors whoes market behaviors are in the same direction with the stock market's retruns, set these link-neighbors "trusters". otherwise, the nodel will reduce the links' weight of its link-neighbors and set these link-neighbors "doubters". If the links' weight > 1, set the links' weight = 1, If the links' weight <= 0, ask links with [weight <= 0] die, and randomly cteate a new link with one of nodes which don't link with the nodeself, and randomly set the weight of the new link between 0 and 1.
            The codes as follows:

            to update-maket-sentiment
            ask nodes [set nodel self
            ask nodel [if returns > 0
            [set trusters nodes with [(self != nodel) and (link-neighbor? nodel) and (my-sentiment = 1)]
            set doubters nodes with [(self != nodel) and (link-neighbor? nodel) and (my-sentiment = -1)]
            set [[weight] of links] of trusters [[weight] of links] of trusters * (1 + 0.1)
            set [[weight] of links] of doubters [[weight] of links] of doubters * (1 - 0.2)
            ]
            if returns < 0
            [set trusters nodes with [(self != nodel) and (link-neighbor? nodel) and (my-sentiment = -1)]
            set doubters nodes with [(self != nodel) and (link-neighbor? nodel) and (my-sentiment = 1)]
            set [[weight] of links] of trusters [[weight] of links] of trusters * (1 + 0.1)
            set [[weight] of links] of doubters [[weight] of links] of doubters * (1 - 0.2)
            ]
            if [weight] of my-links > 1
            [set [weight] of my-links [weight] of my-links = 1]
            if [weight] of my-links <= 0
            [ask my-links with [weight <= 0] [die]
            create-link-with one-of nodes with [(self != nodel) and (not link-neighbor? nodel)]
            set [[weight] of links] of nodes with [(self != nodel) and (not link-neighbor? nodel)] random-float 1
            ]
            ]

            ]
            end

            When i run the model, it doesn't work and Netlogo says:" You can't use set for '[[weight] of links] of trusters [[weight] of links] of trusters * (1 + 0.1)' ". Certainly, there are also some other mistakes in my codes, can you give some suggestions to me?
          • Jim Lyons
            ... Sorry, I don t have time to go through this in detail, but it looks like the main problem is that you have one agent trying to set another agent s
            Message 5 of 5 , Feb 10, 2012
              On Feb 8, 2012, at 11:06 PM, zhannghui43 wrote:

              Dear Jim:
              Thanks for your advice for my last question, it is useful to my work. I have a new question about reinforcement learning on Netlogo. I want to ask the node reinforce the links' weight of its link-neighbors whoes market behaviors are in the same direction with the stock market's retruns, set these link-neighbors "trusters". otherwise, the nodel will reduce the links' weight of its link-neighbors and set these link-neighbors "doubters". If the links' weight > 1, set the links' weight = 1, If the links' weight <= 0, ask links with [weight <= 0] die, and randomly cteate a new link with one of nodes which don't link with the nodeself, and randomly set the weight of the new link between 0 and 1.
              The codes as follows:

              to update-maket-sentiment
              ask nodes [set nodel self
              ask nodel [if returns > 0
              [set trusters nodes with [(self != nodel) and (link-neighbor? nodel) and (my-sentiment = 1)]
              set doubters nodes with [(self != nodel) and (link-neighbor? nodel) and (my-sentiment = -1)]
              set [[weight] of links] of trusters [[weight] of links] of trusters * (1 + 0.1)
              set [[weight] of links] of doubters [[weight] of links] of doubters * (1 - 0.2)
              ]
              if returns < 0
              [set trusters nodes with [(self != nodel) and (link-neighbor? nodel) and (my-sentiment = -1)]
              set doubters nodes with [(self != nodel) and (link-neighbor? nodel) and (my-sentiment = 1)]
              set [[weight] of links] of trusters [[weight] of links] of trusters * (1 + 0.1)
              set [[weight] of links] of doubters [[weight] of links] of doubters * (1 - 0.2)
              ]
              if [weight] of my-links > 1
              [set [weight] of my-links [weight] of my-links = 1]
              if [weight] of my-links <= 0
              [ask my-links with [weight <= 0] [die]
              create-link-with one-of nodes with [(self != nodel) and (not link-neighbor? nodel)]
              set [[weight] of links] of nodes with [(self != nodel) and (not link-neighbor? nodel)] random-float 1
              ]
              ]

              ]
              end

              When i run the model, it doesn't work and Netlogo says:" You can't use set for '[[weight] of links] of trusters [[weight] of links] of trusters * (1 + 0.1)' ". Certainly, there are also some other mistakes in my codes, can you give some suggestions to me?

              Sorry, I don't have time to go through this in detail, but it looks like the main problem is that you have one agent trying to set another agent's variables. This used to be allowed but since about version 4 (?) we must ask the agent to set its variables. So:

              set [var] of agent <new-value>  ;; XXX -- WRONG -- NOT ALLOWED
              ask agent [ set var <new-value> ]  ;; correct way

              HTH,
              Jim
            Your message has been successfully submitted and would be delivered to recipients shortly.