How to setup a condition in anylogic, that will return true, only when specific message is received? - anylogic

Good day,
I'm trying in AnyLogic to make block "Ped Select Output" (from Pedestrian library) select output based on the received message, using the command in conditions table receive("go");. This block is located in Main, while the message is supposed to be sent from the agent tab (MyAgent) using the command send("go", main.pedSource);. Yet if I try to launch this model I get the error "Type mismatch, cannot convert void to boolean". I believe I have incorrectly selected one of the commands (or maybe both), thus I hope for advice about it. Thanks in advance for the answer.
P.s. check screenshots, for more detailed information.
P.p.s. the model, that is presented on screenshots is just an oversimplified example of the real model (that's why 4 out of 5 outputs of the block are connected to one place).
main
agent

Each condition in the selectoutput should return a boolean... a boolean can be true or false
Some example of booleans are 3==2, 5>4, agent.priority==1, etc
These things are booleand because they are true or false
you are putting in the condition a function that doesn't return anything (receive) and I have absolutely no idea what is in your head that would suggest that this might work in any way...
I suggest you add a variable in your ped agent that defines what the pedestrian should do...

Related

Cimplicity Screen - one object/button that is dependent on hundreds of points

So I have created a huge screen that essentially just shows the robot status for every robot in this factory (individually)… At the very end of the project, they decided they want one object on the screen that blinks if any of the 300 robots fault. I am trying to think of a way to make this work. Maybe a global script of some kind? Problem is, I do not do much scripting in Cimplicity, so any help is appreciated.
All the points that are currently used on this screen (to indicate a fault) have very similar names… as in, the beginning is the same… so I was thinking of a script that could maybe recognize if a bit is high based on PART of it's string name characteristic. The end will change a little each time, but I am sure there is a way to only look for part of a string and negate the rest. If the end has to be hard coded, that's fine.
You can use a Python script in Cimplicity.
I will not go into detail on the use of python in Cimplicity, which is well described in the documentation indicated above.
Here's an example of what can be done... note that I don't have a way to test it and, of course, this will work if the name of your robots in the declaration follows the format Robot_1, Robot_2, Robot_3 ... Robot_10 ... Robot_300 and it also depends on the Name and the Type of the fault variable... as you didn't define it, I imagine it can be an integer, with ZERO indicating no error. But if you use something other than that, you can easily change it.
import cimplicity
(...)
OneRobotWithFault = False
# Here you get the values and check for fault
for i in range(0, 300):
pointName = f'MyFactory.Robot_{i}.FaultCode'
robotFaultCode = cimplicity.point_get(pointName)
if robotFaultCode > 0:
OneRobotWithFault = True
break
# Set the status to the variable "WeHaveRobotWithFault"
cimplicity.point_set("WeHaveRobotWithFault", OneRobotWithFault)

How can I make this Max MSP/M4L patch update zl.len and zl.mth for an empty list?

Background
I'm trying to build a Max for Live device as a solution to the problem presented in this related question. As part of my solution I need to keep track of a group of notes (i.e. the selected, or in-scale notes).
My patch (see below) works great for any combination of held notes, but fails once the last note is released. When that happens, zl.len stays stuck at 1 and zl.mth continues to output whatever note was released last.
The question
How can I update my patch so that the length is 0 and the selected note is empty when the input list of held notes is empty?
What I have tried
I have tried banging the left inlet of the various zl objects manually and as part of the kslider update but this only produces the same unwanted behavior.
Here is a screen-shot of the patch:
and here is the corresponding code:
----------begin_max5_patcher----------
917.3ocyX0zbaCBD8ryL4+.iN6jAPHaodr8P+AzicxjQePrIUB4AgRcal9eu
7gUrSprJJF5zKlQqA18s6agmzyWe0hnh18ztHvG.eErXwyJKKL1zVVLXXQTS
99x57NyDi38METQzxC+m5QFulJM+I5Dqs8xAy3AypoxZ5az1fKOt4C1Pur9c
4h7FpjJtmxyKpouZE1cV9icTajGEsDDUjy2DAtaXNrJSv1V73MIwQG2VY4VF
ey8BZoztXbRxsvk.BYkdHNV+KFeKDbmYM+55qzipgkNmgJaaZnb4KdUR2abV
zmZ64RfbKErkVWA3sRUxeXV0LNsTOgWkwbI8BGCz3o.8ZnArYFLmhLOPtHLW
zKks7YwJdmE6IJzvovLxVniIolRLY32PTn+nJFM0YcIFnfPzkVOIYSgsXnkD
mYpqnDy.FFFv8EpDv3Uz8f1G.UzNlfVA5Jyqo2ng6kC0zI6WyHmzuhxPAEps
BosMUgXPdWIkWoBGPqnZlGANJPWOMPOzWlY.55rPBzOKZ628lSlTPV1BxA0r
NOveSlj+d3zWHxVTiCM+cn2zTW0OX3uWNJm7pFBw1dptdIwWco+Obta7j20f
WYNvkj5uyc4zuq76eVY+Y8scpN1wyF3+h1jQUULNfwS23FSN4hFBxCJJNGfk
B1lMTAn38Q.lQMFSlDxqSsMtlCoRhCHj2ITGKA5n0JmSqt3NVLxgRYhkBmBC
HtTb2F41fScQYtfW6PPot153F88NWbQDs1AwQGT6tZUXKhSfHeVFW4P6XLzP
XSBeYrlx2bNx6bpiwNHfmfMfy1RFt5nBRguJ5zKrX4swq8.d+VWM6TkqsO7P
G03tUv2EXmmDBlVNlc3X9nosh9JdhPcIj0BdjbV5z5HMoLDz9hsjgaiB.EoH
eyr3GnIyJiSOb.pXqlRblVR4nrC6Va97Bu8K8X1V8e7lDPWaunbH7F9DJ.3w
fT8VeRFOWxTROONK8cK.zT4ZmcnVgkiN7jYYesLcx1CgfVUq6gfGb3aQy3NT
KXwSNzwjL7LIYrGBgD3bBAefYhSI40ADyNl1OWH.+mkEzhLBV6kigP.SBoNw
DHALGfbi8G6uiXVMG1uOb3b3YdplhbgTg7l67FG9vE04618DUzcXOr9VII4w
VyhRWZelwsOakUDInOwFVRh0TtPIYPpzKzKLgbz9UGdGdijKAumMvi0nW6Zi
pGtRPW2tbKNMpit9J0D9MXvABqM
-----------end_max5_patcher-----------
Indeed the only way to know if there is nothing in a zl group object is to somehow keep track of whether something came in.
Here is an example that should do what you are looking for if I understand correctly:
----------begin_max5_patcher----------
1066.3ocwY1rbaaCDG+rzSAFdVQC9fe1iIGxCPO1wiGJQXYlRBpgDLUsYx6d
AVPZoXCICYBxbQ1DBlK9s6+cwB3erdUvtlS7t.zef9KzpU+X8pUvP5AVM77p
f57S6qx6foEH3+SytuErw7UR9IILrDsCUNNZYALlZdehMNlnutTTwkvagbdv
ld43nzgQMCI+2ibyBKXWt3PvFTPoPYrGFl0wb49mKEGdrkuWZlHkw1Ri1fHL
5V7FDMaq5Ap52QOn+a94505O1LMRsQI0JkTqTRtFkuGcDEcJpBYwyGbRD1VP
L5NhhSkOFk.7QG+zm70wqPXDwFigVYjYkQ16oTG+oK.SS.fCCmCfslSxVP4J
MjNmx0R6AShOJ6nI7dp5jk5CR6q2waGW9puprtuFV7j2xYzKQxi4s40bIu8Q
tHeWEf.1C9fWDy2zCDEBdfHLFxfYmUxibTJF4.+AbJ6apq45nwqh+eooWHQx
m4nm4UEHQiTsY1vjpJE785u+R9tz2QuCMB95vaJGGFBPmRFc.enf+tdorQXQ
PGg8TflbyJW2LeFm.fhGRqG+7CA50BneVsJf3oNThTKRK9hvLOE3vCpVSkWR
DHdoXOizexUUoDE7SnlmPE7txVdApaedE+SZHsAXpe.jlwtLsjjQlG.aZklT
OEmn7t8bQgZgfZZKNWH6R7R7EdX.OVHT2kjjMK3801l9iupFiBTYCJGUU1YU
gF4YBoCAP1roPGy4fXn9APgZiMlux9.XhX5cKmZt2Uqaxn+1qaRiSFJyP8Pg
yqzHz+UssSkFZ6nII2Qyd2rM.mZBZHYLjLGMyBGxz5ITng2gpj4x4LcowOro
vCFfMNaNP9XqZUfTGaQYUdgMxIdpVyP.L1bvqT7bPiRlVKe1BEjrEUkFkNip
TSH6fdaCajl32tWXlMEhimo30U4HdYqqX1BLZFiXUbwA6hSOsk23E3XNueb5
LEwTbXCB7hDuHQT8F5CmRfkLIF+6tpxK5gr4om53fchwuEvz6dmd57bc.lcE
LnmFNzjyEGEtofeo7oUsoiY.p+jA6xOXSCrD26yKWGhQfGktMw18g.uB3P5u
55mgWod7ek5tl918iqgg3M5rWUcvJYoHWVpZC77bzsEftl1yUCM9Rtokz2ol
erD0EKQ7gkHumk7.RLG7cDOYGxBXG8Ew79xNenEbww4kHTzBQDYwbcIt3690
Ui4xJzUCmjoScTFN072Hmxqx7fkXNU8KxGBQWpIoa6b5VxEuGyG6cvntFmlr
kHtTQ2G6cvHtvT7hkHmYOQlr.lNwtowSqNYlK0I8wlYiAoaaoDeXIWR3dKRl
lDyOd7671tgYC1P0D72Z.ec5l0l++RlGg1VCZ4eubb9lIj2p5SUpZRsuEVWA
mhMWYDzOdqnubPynnSYRnAag5XDcGyMf.8gu9mq+eNu4kL.
-----------end_max5_patcher-----------
With the help of the Cycling74 forum, I came up with this solution that uses borax to count the held notes, and as a trigger to clear the zl object when the count is 0.
----------begin_max5_patcher----------
866.3ocuX1zaaBCFG+bxmBKzNlEgMP.lTOsO.6vNNMUYHtItCLHioKqU869r
eLrzlBIPBrKfvA3u+87N4kkKbRJNvpbPeA8CzhEurbwBXIyBKZtdgSN8PZFs
BtMmzh7blP4rx9aJ1AEr92j6nB9yLjZOCIJTrJDWnJPTTUgTw1hx3U+6ox3B
VZQs.dTulEE04E0pLlBDxsY0RpJcOWr6dIKUY2nDb7Z2UHOhm4TD1bzObsK5
mMOCeKrkJRd7ydwNGe8bQ6aGaV60kKMGVcij+0LFUBXq29k0JD+AsAnwFPkL
zdV11NI2erj6ERLvRb8MmBgiab6g7vYm7uyxzas24wgKpRoYrNIlLZhcAmre
75fUHbfK3385g3fIiXA62523G.VgdNK03tc5jC7YhYii.O2Ff.KGDxa3v9ZT
+ojYe.mVk5hTRzbSpNF9SbL5t6PtFWp.gGg+b.1AaD7F3BufyYG5z.fcmaCP
Rgjdna2b7YvyEHB6A3gsAum2OyMIVW4oNiM5zx3cMVl57DVOg5jyjxFrA7pg
gsIqmXBzhvyqyAGFtW2tFwDpXWmLF347O8kzblhIumInIYr2VNQieqNtSUzR
RsRUHFc5umIFWaL7gSD+1i8GVzK6djgv9bkV7b1ZS+7QGTfC7so5PCLe7kyK
LA.cGf2ciMxTVlOYzd3F.aJrQHWFvd8vD+4t3VoTW8.UAsuYacF8.X1h39a.
2XzGal8VXvNyeHYtZ+niHagfDdyQj334NhTy3NYQc4Um2YmUN3lnbyjQ4upx
3auhVK3X6j+vzfQ.YAdCr45w1OEaYuMYVpyCsKP9HzQCoXawCOTwT8V9cBiC
Rn6F+nmVyUynmD6EWbjjNi.tX..7TvHhm7Qkv9xr96YtpnVl1JaapD53VaKq
RwETEW2y83MYpoXtoNsqCVoMCQovoPoAHT6t4lDJZHDMQ5fGfN3aTGy6v6RF
tIfGiN9CPmofGxkzw8cNwBooNooxxsor+HhAOUZ7rC8IauoR4AA8rXtCGhxw
SQsE2gjyGMEIIQ+uXx70cCSoaMgzibcLYayQKKehIqZtaPDcS7GKf.nnUKse
Bp8Rn+rij8Du89g+1SGpT2tVo6UWKgMlygM1o+gwTjhZdSdfFOsjv.BB8fHU
kTKIvbDKec4eADs2DjA
-----------end_max5_patcher-----------

Protractor - check if element is present and either stop test or continue

I have a Protractor test that pulls various values from the UI and stores them as variables for comparison with values from a different database.
Now this test needs to run against multiple sites BUT of the 25 maximum data points recorded, some sites only have 22.
Clearly the test fails on those "22" sites since the elements are not present.
What I want to achieve is where there's a "22" site, the tests against the not present elements are ignored and the test proceeds to the end. Conveniently, the "missing" elements are the last ones in the spec.
Crudely speaking...
if element-y is not present end test or if element-y is present continue
Grateful if anyone could advise.
Thanks #sergey. I've modified your example as below....
if (!(await element(by.xpath('//*[#id="root"]/div/div[2]/main/div/div/section[5]/div/div/div[1]/section/div/span')).isPresent())) {
console.warn ('Functions are not present, closing the session')
await browser.close()
I get this error:
if (!(await element(by.xpath('//*[#id="root"]/div/div[2]/main/div/div/section[5]/div/div/div[1]/section/div/span')).isPresent())) {
^^^^^^^
SyntaxError: Unexpected identifier
I've tried using a 'var' instead of the actual element, but get the same result.
Thanks
well the best option that I recall is still pretty dirty... you can do something like this
if (!(await element.isPresent())) {
console.warn('Element not present, closing the session')
await browser.close()
}
And then the rest of test cases will fail as session not found or similar error
The reason you can't do anything better because in protractor you can't do conditional test cases based on a Promise-like condition, if that makes sense...

Creating easy classification visual tool (with Shiny)

I have a model that predicts, based on multiple variables like income and marital status, whether a person is credit worthy (yes/no).
My question is whether it is possible to create a visual tool where you enter the value of each of the variables and then the tool gives you a YES or NO if it predicts this person is credit worthy.
I have seen something like this before and I think it was made with Shiny. However, I cannot find it anymore.
Any help or tips would be very appreciated!
Bert
Code a function mymodel(a,b,c,d....) where a:d are your variables, and it returns TRUE or FALSE based on credit worthiness.
In your UI, use the widgets found here: http://shiny.rstudio.com/tutorial/lesson3/ to pass values to the input object.
Then, you can use:
shinyServer(
function(input, output) {
output$text1 <- renderText({
if(mymodel(input$widget1,input$widget2,...)) {
"Credit-Worthy"
} else {
"Not Credit-Worthy"
}
})
}
)
Make sure in your UI, you then pass:
mainPanel(
textOutput("text1")
)
As found in http://shiny.rstudio.com/tutorial/lesson4/
This will give you a text output of a individuals credit-worthiness. If you want to have other visual effects, you can use the same if statement above to pass different themes/images/etc.. to output.

Matlab/Simulink: If block error

Please refer to the image at the following link attached for understanding the question.
Image is at this link: http://www5.picturepush.com/photo/a/12014483/img/12014483.jpg)
here are 2 inputs: 1.Speed_Pulse 2.PreviousSpeedPulse_1_old
The second input is nothing but the first input delayed in time by 1 time instant using the unit delay block. The 'If' block compares the 2 inputs. If the input 'u1' (Speed_Pulse) is less than 'u2'(PreviousSpeedPulse_1_old) then, in the 'if action' block, the value 64 is simply added to u1 (Speed_Pulse) value. Else, the input Speed_Pulse is directly transmitted to the output via the 'else action' block. One of the outputs is transmitted to 'Temp' (depending on the 'if-else') using the 'Merge' block.
Now, please refer to following table of inputs and outputs.
The table is at this link: http://img521.imageshack.us/img521/8684/tablewy.png
In the table, the values are wrong for instant 4 and instant 7.
I could not find a reason for this abrupt wrong output.
Any idea what is going wrong?
Sorry it was my mistake. Actually I was using a Framework below it and it was the error of the Framework. Got it resolved. Thanks for your help.