In the Anylogic 8.3 version PalletRack constructor works fine as defined:
PalletRack palletRack1 = new PalletRack(root, SHAPE_DRAW_2D3D, true, 760.0, 90.0, 0.0, 160.0, 14.0, 14.0, 10.0, 0.0, PALLET_RACK_TWO_PALLET_RACKS, PALLET_RACK_NO_DIRECTION,
11.0, 40.0, 16.0, 10, 2, 1000, cyan, maroon, 100 );
But when install the newest version of Anylogic (8.7.2) the PalletRack constructor not work the error message is:
Description: The constructor PalletRack(Main, ShapeDrawMode, boolean, double, double, double, double, double, double, double, double, PalletRackType, PalletRackDirection, double, double, double, int, int, int, Color, Color, int) is undefined.
seems that there is one new argument is expected in this constructor.
It is "boolean isObstacle". And its expected at 4th position.
So this code is compiled sucessfully:
PalletRack palletRack1 = new PalletRack(root, SHAPE_DRAW_2D3D, true, false, 760.0, 90.0, 0.0, 160.0, 14.0, 14.0, 10.0, 0.0, PALLET_RACK_TWO_PALLET_RACKS, PALLET_RACK_NO_DIRECTION,
11.0, 40.0, 16.0, 10, 2, 1000, cyan, maroon, 100 );
Related
Im studing right now in iOS developement.
Making a interactive text quest analogue of "Life Line" app
Here we have a score of oxygen (oxygenScore). If the score drops below 0, I need the story in the structure stories to be selected as number 6 (death). What function would you advise?
//
// StoryBrain.swift
// Destini-iOS13
//
// Created by Angela Yu on 08/08/2019.
// Copyright © 2019 The App Brewery. All rights reserved.
//
import Foundation
struct StoryBrain {
let stories = [Story( //0
story: "The landing on the asteroid was successful. Noticing abnormal readings during the scan of the asteroid it was decided to investigate it. When you landed, you filled the oxygen tanks to maximum and went outside.",
choice1: "Look around", choice1Destination: 1,
choice2: "Go inside the ship", choice2Destination: 2,
choice3: "boo", choice3Destination: 0,
backgroundImage: "AppDelegate",
oxygen: 100,
placeOutside: false,
hideChoice3: true
),
Story( //1
story: "As you look around, you find multiple human footprints and moonwalking vehicles leading to the nearest hill to the east of your landing point.",
choice1: "Go inside the ship", choice1Destination: 2,
choice2: "Check the tread marks of the moonwalker", choice2Destination: 3,
choice3: "", choice3Destination: 0,
backgroundImage: "AppDelegate",
oxygen: 15,
placeOutside: true,
hideChoice3: true
),
Story( //2
story: "When you returned to the ship, you were overwhelmed with a sense of calm and safety. Fresh oxygen filled your lungs and your consciousness cleared up. You remembered what you needed...",
choice1: "Go into the Warehouse", choice1Destination: 5,
choice2: "Go outside", choice2Destination: 1,
choice3: "", choice3Destination: 0,
backgroundImage: "AppDelegate",
oxygen: 100,
placeOutside: false,
hideChoice3: true
),
Story( //3
story: "The moonwalker tracks go up a hill three miles away.",
choice1: "Follow in the tracks of the moonwalker", choice1Destination: 4,
choice2: "Turn back", choice2Destination: 2,
choice3: "", choice3Destination: 0,
backgroundImage: "rover tracks",
oxygen: 15,
placeOutside: true,
hideChoice3: true
),
Story( //4
story: "When you finally got to the moonwalker, you saw an interesting picture: there were about 20 dead bodies lying nearby, and another moonwalker, apparently destroyed. A container towered among the dead bodies",
choice1: "Check the container", choice1Destination: 5,
choice2: "End", choice2Destination: 0,
choice3: "", choice3Destination: 0,
backgroundImage: "rover",
oxygen: 30,
placeOutside: true,
hideChoice3: true
),
Story( //5
story: "When you approached the container, you saw a man sitting leaning against the container. He was still alive, but unconscious - his oxygen tanks were damaged and there was almost no air left in them. The container was undamaged and the dial of the code lock was visible near the man",
choice1: "The", choice1Destination: 0,
choice2: "End", choice2Destination: 0,
choice3: "", choice3Destination: 0,
backgroundImage: "space background",
oxygen: 100,
placeOutside: true,
hideChoice3: true
),
Story( //6
story: "oops, you dead!",
choice1: "The", choice1Destination: 0,
choice2: "End", choice2Destination: 0,
choice3: "", choice3Destination: 0,
backgroundImage: "space background",
oxygen: 0,
placeOutside: true,
hideChoice3: true
),
]
var storyNumber = 0
var oxygenScore = 0
mutating func checkPlace() -> Int! { //check is the charachter outside of the ship
if stories[storyNumber].placeOutside {
oxygenScore -= stories[storyNumber].oxygen
} else {
oxygenScore = stories[storyNumber].oxygen
}
return oxygenScore
}
func hideChoiceThree() -> Bool! { //hide choice 3 button
return stories[storyNumber].hideChoice3
}
func getStoryText() -> String! { //get story text
return stories[storyNumber].story
}
func getUserChoice1() -> String!{
return stories[storyNumber].choice1
}
func getUserChoice2() -> String!{
return stories[storyNumber].choice2
}
func getUserChoice3() -> String!{
return stories[storyNumber].choice3
}
func getBackgroundImage() -> String! {
return stories[storyNumber].backgroundImage
}
mutating func nextStory(_ userChoice: String) -> Int{
if userChoice == stories[storyNumber].choice1{
storyNumber = stories[storyNumber].choice1Destination
} else if userChoice == stories[storyNumber].choice2{
storyNumber = stories[storyNumber].choice2Destination
} else if userChoice == stories[storyNumber].choice3{
storyNumber = stories[storyNumber].choice3Destination
} else {
storyNumber = 0
}
return storyNumber
}
}
try to attach oxygen score in nextStory function...
main viewController
Here is my data:
["aRetinol": (800.0, 24.0, 3.0, 24.0, 3.0), "aBetacarotene": (2100.0, 231.0, 11.0, 100.0, 4.7619047), "vitamineC": (80.0, 197.38002, 246.72504, 100.0, 125.0), "vitamineB1": (1.1, 0.6, 54.545456, 0.6, 54.545456), "omega3": (2.0, 2.06, 103.0, 2.06, 103.0), "calcium": (800.0, 297.4, 37.175, 100.0, 12.5)]
It's a dictionary type : [String: (Float, Float, Float, Float, Float)]
This is for a table view where I have to display the second smallest value of each nutrient.
I need to obtain a dictionary like this (the value concerned is between **) :
["calcium": (800.0, **297.4**, 37.175, 100.0, 12.5), "aBetacarotene": (2100.0, **231.0**, 11.0, 100.0, 4.7619047),"vitamineC": (80.0, **197.38002**, 246.72504, 100.0, 125.0), "aRetinol": (800.0, **24.0**, 3.0, 24.0, 3.0), "omega3": (2.0, **2.06**, 103.0, 2.06, 103.0), "vitamineB1": (1.1, **0.6**, 54.545456, 0.6, 54.545456)]
As suggested in the comments, a struct might work better than a tuple for this kind of data.
Also, you can't sort a dictionary and get a dictionary as a result because the dictionary is not an ordered collection, i.e. you can't have the keys be ordered arbitrarily. A result of sorting a dictionary will be an array of tuples where each tuple consists of a key and a value.
That said, if you had no choice but using tuples, here's how this problem could be solved:
extension Dictionary where Value == (Float, Float, Float, Float, Float) {
func sortedBySecondSubvalue(ascending: Bool) -> [(key: Key, value: Value)] {
self.sorted { keyValuePair1, keyValuePair2 -> Bool in
let secondSubvalue1 = keyValuePair1.value.1
let secondSubvalue2 = keyValuePair2.value.1
return ascending ? secondSubvalue1 < secondSubvalue2 : secondSubvalue1 > secondSubvalue2
}
}
}
And you'd use it like this:
let sampleDict: [String:(Float, Float, Float, Float, Float)] = ["aRetinol": (800.0, 24.0, 3.0, 24.0, 3.0), "aBetacarotene": (2100.0, 231.0, 11.0, 100.0, 4.7619047), "vitamineC": (80.0, 197.38002, 246.72504, 100.0, 125.0), "vitamineB1": (1.1, 0.6, 54.545456, 0.6, 54.545456), "omega3": (2.0, 2.06, 103.0, 2.06, 103.0), "calcium": (800.0, 297.4, 37.175, 100.0, 12.5)]
print(sampleDict.sortedBySecondSubvalue(ascending: false))
// Prints: [(key: "calcium", value: (800.0, 297.4, 37.175, 100.0, 12.5)), (key: "aBetacarotene", value: (2100.0, 231.0, 11.0, 100.0, 4.7619047)), (key: "vitamineC", value: (80.0, 197.38002, 246.72504, 100.0, 125.0)), (key: "aRetinol", value: (800.0, 24.0, 3.0, 24.0, 3.0)), (key: "omega3", value: (2.0, 2.06, 103.0, 2.06, 103.0)), (key: "vitamineB1", value: (1.1, 0.6, 54.545456, 0.6, 54.545456))]
The extension like that can be surely modified for dictionaries containing structs as values rather than tuples.
This is the required map. I want the output to be neutral.
{anger: 0.0, contempt: 0.02, disgust: 0.0, fear: 0.0, happiness: 0.0, neutral: 0.978, sadness: 0.002, surprise: 0.0}
Map themap={"anger": 0.0, "contempt": 0.02, "disgust": 0.0, "fear": 2.0, "happiness": 0.0, "neutral": 0.978, "sadness": 0.002, "surprise": 0.0};
var thevalue=0.0;
var thekey;
themap.forEach((k,v){
if(v>thevalue) {
thevalue = v;
thekey = k;
}
});
print (thekey);
I am trying to round all elements in the vector using new static function convertElements from Accelerate framework.
Sadly i don't know how to use it.
Here is what i tried:
let a: [Double] = [10.6, 20, 30.8, 40, 50, 60, 70, 80, 90, 100]
var b = [Int](repeating: 0, count: a.count)
var round: vDSP.RoundingMode = vDSP.RoundingMode.towardNearestInteger
vDSP.convertElements(of: a, to: &b, rounding: round)
This code throws error:
error: ambiguous reference to static method 'convertElements(of:to:rounding:)'
vDSP.convertElements(of: a, to: &b, rounding: vDSP.RoundingMode.towardNearestInteger)
Any idea how to use this function?
Seems like setting value of vDSP.RoundingMode type is the problem.
You're using the wrong type for the to: array. It needs to be [Int32], not [Int].
Change:
var b = [Int](repeating: 0, count: a.count)
to:
var b = [Int32](repeating: 0, count: a.count)
In the link you provided, the definition of the function is:
static func convertElements<U, V>(of source: U, to destination: inout V,
rounding: vDSP.RoundingMode) where U : AccelerateBuffer,
V : AccelerateMutableBuffer, U.Element == Double, V.Element == Int32
Notice that V.Element is Int32.
As noted by #MartinR in the comments, other types are possible including Int8, UInt8, Int16, UInt16, and UInt32. All of the calls are detailed here.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I have two dictionaries: a data dict and a results dict
var data = ["flushes": 0.0, "times": 0.0, "glasses": 0.0, "showers": 0.0, "brushings": 0.0, "loads": 0.0, "washings": 0.0, "baths": 252.0, "dishes": 0.0]
let results = ["flushes": 21.0, "times": 0.0, "glasses": 0.0, "showers": 150.0, "brushings": 4.0, "loads": 0.0, "washings": 5.0, "baths": 0.0, "dishes": 9.0]
I am wondering how to add like values based on key and have only one dictionary.
Assuming data is mutable, this should do it:
data.merge(results, uniquingKeysWith: { $0 + $1 })
In addition to Ole`s answer, at this point there are two other -syntactic sugar- options:
You could type it as:
data.merge(results, uniquingKeysWith: +)
Or as a trailing closure syntax:
data.merge(results) { $0 + $1 }
Hence:
print(data)
/*
["flushes": 21.0,
"times": 0.0,
"glasses": 0.0,
"showers": 150.0,
"brushings": 4.0,
"loads": 0.0,
"washings": 5.0,
"baths": 252.0,
"dishes": 9.0]
*/