Why does my lp file give #number for each variable? - visual-c++
I am using Ilog Cplex with Visual C++ 2015 to solve my problem. Generally, when I export lp file of my problem, the lp file will not contain any #number(such #0, #1, and so on) for variables. It is like this:
\ENCODING=ISO-8859-1
\Problem name: IloCplex
Minimize
obj: Ope(1,1,1) + Ope(1,1,2) + Ope(1,1,3) + Ope(1,1,4) + Ope(1,1,5)
+ Ope(1,1,6) + Ope(1,1,7) + Ope(1,1,8) + Ope(1,1,9) + Ope(1,1,10)
+ Ope(1,1,11) + Ope(1,1,12) + Ope(1,1,13) + Ope(1,1,14) + Ope(1,1,15)
+ Ope(1,1,16) + Ope(1,1,17) + Ope(1,1,18) + Ope(1,1,19) + Ope(1,1,20)
+ Ope(1,1,21) + Ope(1,1,22) + Ope(1,1,23) + Ope(1,1,24) + Ope(1,2,1)
+ Ope(1,2,2) + Ope(1,2,3) + Ope(1,2,4) + Ope(1,2,5) + Ope(1,2,6)
+ Ope(1,2,7) + Ope(1,2,8) + Ope(1,2,9) + Ope(1,2,10) + Ope(1,2,11)
+ Ope(1,2,12) + Ope(1,2,13) + Ope(1,2,14) + Ope(1,2,15) + Ope(1,2,16)
+ Ope(1,2,17) + Ope(1,2,18) + Ope(1,2,19) + Ope(1,2,20) + Ope(1,2,21)
+ Ope(1,2,22) + Ope(1,2,23) + Ope(1,2,24) + Ope(2,1,1) + Ope(2,1,2)
+ Ope(2,1,3) + Ope(2,1,4) + Ope(2,1,5) + Ope(2,1,6) + Ope(2,1,7)
+ Ope(2,1,8) + Ope(2,1,9) + Ope(2,1,10) + Ope(2,1,11) + Ope(2,1,12)
+ Ope(2,1,13) + Ope(2,1,14) + Ope(2,1,15) + Ope(2,1,16) + Ope(2,1,17)
+ Ope(2,1,18) + Ope(2,1,19) + Ope(2,1,20) + Ope(2,1,21) + Ope(2,1,22)
+ Ope(2,1,23) + Ope(2,1,24) + Ope(2,2,1) + Ope(2,2,2) + Ope(2,2,3)
+ Ope(2,2,4) + Ope(2,2,5) + Ope(2,2,6) + Ope(2,2,7) + Ope(2,2,8)
+ Ope(2,2,9) + Ope(2,2,10) + Ope(2,2,11) + Ope(2,2,12) + Ope(2,2,13)
+ Ope(2,2,14) + Ope(2,2,15) + Ope(2,2,16) + Ope(2,2,17) + Ope(2,2,18)
+ Ope(2,2,19) + Ope(2,2,20) + Ope(2,2,21) + Ope(2,2,22) + Ope(2,2,23)
+ Ope(2,2,24)
However, today I add some constraints to my model, the lp file gives #number to each variable. It is like this:
\ENCODING=ISO-8859-1
\Problem name: IloCplex
Minimize
obj: Ope(1,1,1)#0 + Ope(1,1,2)#1 + Ope(1,1,3)#2 + Ope(1,1,4)#3 +
Ope(1,1,5)#4
+ Ope(1,1,6)#5 + Ope(1,1,7)#6 + Ope(1,1,8)#7 + Ope(1,1,9)#8
+ Ope(1,1,10)#9 + Ope(1,1,11)#10 + Ope(1,1,12)#11 + Ope(1,1,13)#12
+ Ope(1,1,14)#13 + Ope(1,1,15)#14 + Ope(1,1,16)#15 + Ope(1,1,17)#16
+ Ope(1,1,18)#17 + Ope(1,1,19)#18 + Ope(1,1,20)#19 + Ope(1,1,21)#20
+ Ope(1,1,22)#21 + Ope(1,1,23)#22 + Ope(1,1,24)#23 + Ope(1,2,1)#24
+ Ope(1,2,2)#25 + Ope(1,2,3)#26 + Ope(1,2,4)#27 + Ope(1,2,5)#28
+ Ope(1,2,6)#29 + Ope(1,2,7)#30 + Ope(1,2,8)#31 + Ope(1,2,9)#32
+ Ope(1,2,10)#33 + Ope(1,2,11)#34 + Ope(1,2,12)#35 + Ope(1,2,13)#36
+ Ope(1,2,14)#37 + Ope(1,2,15)#38 + Ope(1,2,16)#39 + Ope(1,2,17)#40
+ Ope(1,2,18)#41 + Ope(1,2,19)#42 + Ope(1,2,20)#43 + Ope(1,2,21)#44
+ Ope(1,2,22)#45 + Ope(1,2,23)#46 + Ope(1,2,24)#47 + Ope(2,1,1)#48
+ Ope(2,1,2)#49 + Ope(2,1,3)#50 + Ope(2,1,4)#51 + Ope(2,1,5)#52
+ Ope(2,1,6)#53 + Ope(2,1,7)#54 + Ope(2,1,8)#55 + Ope(2,1,9)#56
+ Ope(2,1,10)#57 + Ope(2,1,11)#58 + Ope(2,1,12)#59 + Ope(2,1,13)#60
+ Ope(2,1,14)#61 + Ope(2,1,15)#62 + Ope(2,1,16)#63 + Ope(2,1,17)#64
+ Ope(2,1,18)#65 + Ope(2,1,19)#66 + Ope(2,1,20)#67 + Ope(2,1,21)#68
+ Ope(2,1,22)#69 + Ope(2,1,23)#70 + Ope(2,1,24)#71 + Ope(2,2,1)#72
+ Ope(2,2,2)#73 + Ope(2,2,3)#74 + Ope(2,2,4)#75 + Ope(2,2,5)#76
+ Ope(2,2,6)#77 + Ope(2,2,7)#78 + Ope(2,2,8)#79 + Ope(2,2,9)#80
+ Ope(2,2,10)#81 + Ope(2,2,11)#82 + Ope(2,2,12)#83 + Ope(2,2,13)#84
+ Ope(2,2,14)#85 + Ope(2,2,15)#86 + Ope(2,2,16)#87 + Ope(2,2,17)#88
+ Ope(2,2,18)#89 + Ope(2,2,19)#90 + Ope(2,2,20)#91 + Ope(2,2,21)#92
+ Ope(2,2,22)#93 + Ope(2,2,23)#94 + Ope(2,2,24)#95
I do not want #number to appear in my lp file. What should I do?
The LP file format does not allow arbitrary names for variables and/or constraints. You can find details in the user manual at CPLEX > File formats > LP file format.
If any of your variables or constraints has a name that is not supported in the LP file format then this name has to be changed. To avoid the new name clashing with any existing name, CPLEX appends #number to all names in your model.
One likely/frequent unsupported name is a name that starts in e. Try to avoid such names in case you want to export to LP.
Related
AWS S3 Authenticating Requests Using Query Parameters to download file with custom name
I'm trying to create a signed URL of a file that can let the user download file from the S3 bucket. I'm following this way written in docs. The generated signature is working perfectly and it gets to download the file as well when a user visits the URL. The problem is that I want the name of the downloaded file to be custom. For example: FileKey: tg6AbybBgFMidmKy5dz4vVXZ FileName: test.xlsx The file is saved on S3 with the key and without the file extension. So, when a user downloads the file, it's extensionless and hence unrecognized by OS. I want it to be downloaded with the FileName. I tried adding response-content-disposition in the query but it throws the error: Below is the code I'm using right now. # Create a date for headers and the credential string time = datetime.datetime.utcnow() amz_date = time.strftime('%Y%m%dT%H%M%SZ') datestamp = time.strftime('%Y%m%d') # Date w/o time, used in credential scope # **CREATE A CANONICAL REQUEST** canonical_uri = '/' + document_key canonical_headers = 'host:' + bucket_url + '\n' algorithm = 'AWS4-HMAC-SHA256' credential_scope = datestamp + '/' + region + '/' + service + '/' + 'aws4_request' # Create the canonical query string in URL-encoded (space=%20). canonical_querystring = 'response-content-disposition=attachment; filename="' + document_name + '"; filename*=UTF-8\'\'' + document_name canonical_querystring += '&response-content-type=' + document_type canonical_querystring += '&X-Amz-Algorithm=AWS4-HMAC-SHA256' canonical_querystring += '&X-Amz-Credential=' + quote_plus(access_key + '/' + credential_scope, safe='') canonical_querystring += '&X-Amz-Date=' + amz_date canonical_querystring += '&X-Amz-Expires=' + url_expiry canonical_querystring += '&X-Amz-SignedHeaders=' + signed_headers canonical_request = request_method + '\n' + canonical_uri + '\n' + canonical_querystring + '\n' + canonical_headers.lower() + '\n' + signed_headers.lower() # CREATE THE STRING TO SIGN string_to_sign = algorithm + '\n' + amz_date + '\n' + credential_scope + '\n' + hashlib.sha256(canonical_request.encode('utf-8')).hexdigest() # CALCULATE THE SIGNATURE signing_key = getSignatureKey(secret_key, datestamp, region, service) signature = hmac.new(signing_key, (string_to_sign).encode("utf-8"), hashlib.sha256).hexdigest() # ADD SIGNING INFORMATION TO THE REQUEST canonical_querystring += '&X-Amz-Signature=' + signature # Merge for downloadable URL download_url = 'https://' + bucket_url + canonical_uri +'?' + canonical_querystring I'm not using AWS SDK. I'm trying to do it on my own! EDIT: Even after adding & which was missing, I was getting a signature mismatch.
The issue was with encoding and I missed a & in canonical_querystring = 'X-Amz-Algorithm! It killed my 3 days looking around all forums and trying different things! Here's the working piece of code! # Create a date for headers and the credential string time = datetime.datetime.utcnow() amz_date = time.strftime('%Y%m%dT%H%M%SZ') datestamp = time.strftime('%Y%m%d') # Date w/o time, used in credential scope # **CREATE A CANONICAL REQUEST** canonical_uri = '/' + document_key canonical_headers = 'host:' + bucket_url + '\n' algorithm = 'AWS4-HMAC-SHA256' credential_scope = datestamp + '/' + region + '/' + service + '/' + 'aws4_request' # Create the canonical query string in URL-encoded (space=%20). canonical_querystring = 'X-Amz-Algorithm=AWS4-HMAC-SHA256' canonical_querystring += '&X-Amz-Credential=' + quote_plus(access_key + '/' + credential_scope, safe='') canonical_querystring += '&X-Amz-Date=' + amz_date canonical_querystring += '&X-Amz-Expires=' + url_expiry canonical_querystring += '&X-Amz-SignedHeaders=' + signed_headers canonical_querystring += '&response-content-disposition=' + quote('attachment; filename=\"' + document_name + '\"; filename*=UTF-8\'\'' + document_name, safe='') canonical_querystring += '&response-content-type=' + quote(document_type, safe='') canonical_request = request_method + '\n' + canonical_uri + '\n' + canonical_querystring + '\n' + canonical_headers.lower() + '\n' + signed_headers.lower() + '\n' + 'UNSIGNED-PAYLOAD' # CREATE THE STRING TO SIGN string_to_sign = algorithm + '\n' + amz_date + '\n' + credential_scope + '\n' + hashlib.sha256(canonical_request.encode('utf-8')).hexdigest() # CALCULATE THE SIGNATURE signing_key = getSignatureKey(secret_key, datestamp, region, service) signature = hmac.new(signing_key, (string_to_sign).encode("utf-8"), hashlib.sha256).hexdigest() # ADD SIGNING INFORMATION TO THE REQUEST canonical_querystring += '&X-Amz-Signature=' + signature # Merge for downloadable URL download_url = 'https://' + bucket_url + canonical_uri +'?' + canonical_querystring I was using quote_plus('attachment; filename=\"' + document_name + '\"; filename*=UTF-8\'\'' + document_name,) instead of which I had to use quote('attachment; filename=\"' + document_name + '\"; filename*=UTF-8\'\'' + document_name, safe='') Using this method/logic you can generate link of S3 Object with custom filename without using aws-sdk
Alphametic solves up to 10 letter problems but with large number of addends fails
Decided to try the alphametics problem on Exercism and using a brute force but concurrent approach I solve all but the final test in fairly efficient manner. I can't figure out why the final test is failing as the only extra complexity is the number of addends. I assume it's an issue with how I'm handling the carry digit for a column but that should have tripped me up on the other tests too. My code: use combination::combine::*; use combination::permutate::*; use rayon::prelude::*; use std::collections::HashMap; use std::collections::HashSet; const DIGITS: [u8; 10] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; pub fn solve(input: &str) -> Option<HashMap<char, u8>> { let alphametic = Alphametic::from_str(input); alphametic.brute_force() } #[derive(Debug, Clone)] struct Alphametic { firsts: HashSet<char>, columns: Vec<Vec<char>>, keys: HashSet<char>, } impl Alphametic { fn from_str(input: &str) -> Self { let mut firsts = HashSet::new(); let terms = input .split_whitespace() .rev() .filter(|&sub| sub != "+" && sub != "==") .map(|sub| { firsts.insert(sub.chars().next().unwrap()); sub }) .map(|sub| sub.chars().rev().collect::<Vec<char>>()) .collect::<Vec<Vec<char>>>(); let max_cols = terms[0].len(); let mut columns = vec![]; for i in 0..max_cols { columns.push( terms .iter() .filter(|term| !(term.len() <= i)) .map(|term| term[i]) .collect::<Vec<char>>(), ) } let keys = terms .iter() .flatten() .map(|&c| c) .collect::<HashSet<char>>(); Alphametic { firsts, columns, keys, } } fn brute_force(&self) -> Option<HashMap<char, u8>> { let combo_len = self.keys.len(); let combos = combine_vec(&DIGITS.to_vec(), combo_len); if let Some(soln) = combos .par_iter() .map(|combo| { let perms = permutate_vec(&combo); perms .par_iter() .map(|perm| self.to_guess(&perm)) .filter(|guess| self.no_leading_zeros(guess)) .find_first(|guess| self.guess_columns(guess.clone(), 0, 0).is_some()) }) .find_first(|x| x.is_some()) { soln } else { None } } fn no_leading_zeros(&self, guess: &HashMap<char, u8>) -> bool { self.firsts.iter().all(|c| guess.get(c).unwrap_or(&0) > &0) } fn guess_columns( &self, guess: HashMap<char, u8>, column: usize, carry: u8, ) -> Option<HashMap<char, u8>> { if column >= self.columns.len() { Some(guess) } else { let col = &self.columns[column]; let sum = *guess.get(&col[0]).unwrap(); let addition = col[1..].iter().map(|c| guess.get(c).unwrap()).sum::<u8>() + carry; if sum == addition % 10 { self.guess_columns(guess, column + 1, addition / 10) } else { None } } } fn to_guess(&self, perm: &&Vec<u8>) -> HashMap<char, u8> { self.keys .iter() .zip(*perm) .map(|(k, v)| (*k, *v)) .collect::<HashMap<char, u8>>() } } test input: fn test_puzzle_with_ten_letters_and_199_addends() { assert_alphametic_solution_eq( "THIS + A + FIRE + THEREFORE + FOR + ALL + HISTORIES + I + TELL + A + TALE + THAT + FALSIFIES + ITS + TITLE + TIS + A + LIE + THE + TALE + OF + THE + LAST + FIRE + HORSES + LATE + AFTER + THE + FIRST + FATHERS + FORESEE + THE + HORRORS + THE + LAST + FREE + TROLL + TERRIFIES + THE + HORSES + OF + FIRE + THE + TROLL + RESTS + AT + THE + HOLE + OF + LOSSES + IT + IS + THERE + THAT + SHE + STORES + ROLES + OF + LEATHERS + AFTER + SHE + SATISFIES + HER + HATE + OFF + THOSE + FEARS + A + TASTE + RISES + AS + SHE + HEARS + THE + LEAST + FAR + HORSE + THOSE + FAST + HORSES + THAT + FIRST + HEAR + THE + TROLL + FLEE + OFF + TO + THE + FOREST + THE + HORSES + THAT + ALERTS + RAISE + THE + STARES + OF + THE + OTHERS + AS + THE + TROLL + ASSAILS + AT + THE + TOTAL + SHIFT + HER + TEETH + TEAR + HOOF + OFF + TORSO + AS + THE + LAST + HORSE + FORFEITS + ITS + LIFE + THE + FIRST + FATHERS + HEAR + OF + THE + HORRORS + THEIR + FEARS + THAT + THE + FIRES + FOR + THEIR + FEASTS + ARREST + AS + THE + FIRST + FATHERS + RESETTLE + THE + LAST + OF + THE + FIRE + HORSES + THE + LAST + TROLL + HARASSES + THE + FOREST + HEART + FREE + AT + LAST + OF + THE + LAST + TROLL + ALL + OFFER + THEIR + FIRE + HEAT + TO + THE + ASSISTERS + FAR + OFF + THE + TROLL + FASTS + ITS + LIFE + SHORTER + AS + STARS + RISE + THE + HORSES + REST + SAFE + AFTER + ALL + SHARE + HOT + FISH + AS + THEIR + AFFILIATES + TAILOR + A + ROOFS + FOR + THEIR + SAFE == FORTRESSES", &[ ('A', 1), ('E', 0), ('F', 5), ('H', 8), ('I', 7), ('L', 2), ('O', 6), ('R', 3), ('S', 4), ('T', 9), ], ); I know the correct guess is being generated because if insert a conditional checking for the hashmap the test expects it succeeds. Any tips for how to debug this?
Overflowing u8 on the addition. Fixed with some casts to u64.
im created a word scrambler and i am having difficulty implementing a block of code that scrambles each word individually
print (' ') print ('=================================') print ('Options:') print ('A.) Hello world ---> olHle dlWro') print ('B.) Hello world ---> Hlelo Wlord') while True: #changes input to lowercase letters sctype = input('Enter scramble type') sclower = sctype.lower() #if 'a' or 'b' not in sctype: #print ('follow directions') #input and input related variables print ('There is a 26 character limit') text = input(' Type your message or word: ') length = len(text) remaining = 26 - length counter = 1 just a fancy cage for length and remaining print ('============================') print ('||Length:', length, 'Remaining:', remaining, '||') print ('============================') letter order and loop for option A dash replaces spaces in original text with dashes a fills in extra character space with spaces so length = 26 b scrambles a in the order it is given if sclower == 'a': print ('Results for option A') print (' ') dash = text.replace(" ", "-") a = dash + ' ' * remaining b = a[25] + a[0] + a[24] + a[1] + a[23] + a[2] + a[22] + a[3] + a[21] + a[4] + a[20] + a[5] + a[19] + a[6] + a[18] + a[7] + a[17] + a[8] + a[16] + a[9] + a[15] + a[10] + a[14] + a[11] + a[13] + a[12] a = b scrambles a the amount its original text length is if a == b: while counter <= length: b = a[25] + a[0] + a[24] + a[1] + a[23] + a[2] + a[22] + a[3] + a[21] + a[4] + a[20] + a[5] + a[19] + a[6] + a[18] + a[7] + a[17] + a[8] + a[16] + a[9] + a[15] + a[10] + a[14] + a[11] + a[13] + a[12] a = b nospaces = b.replace(" ", "") #deletes all spaces made in var a nodashes = nospaces.replace("-", " ") #changes all dashes to spaces print (counter, '.)', nodashes) counter += 1 print (' ') option b elif sclower == 'b': print ('Results for option B') print (' ') dash = text.replace(" ", "-") a = dash + ' ' * remaining b = a[21] + a[23] + a[20] + a[25] + a[22] + a[24] + a[19] + a[2] + a[18] + a[0] + a[16] + a[1] + a[17] + a[4] + a[15] + a[3] + a[14] + a[5] + a[13] + a[7] + a[11] + a[6] + a[10] + a[9] + a[12] + a[18] a = b if a == b: while counter <= length : b = a[21] + a[23] + a[20] + a[25] + a[22] + a[24] + a[19] + a[2] + a[18] + a[0] + a[16] + a[1] + a[17] + a[4] + a[15] + a[3] + a[14] + a[5] + a[13] + a[7] + a[11] + a[6] + a[10] + a[9] + a[12] + a[18] a = b nospaces = b.replace(" ", "") nodashes = nospaces.replace("-", " ") print (counter, '.)', nodashes) counter += 1 print (' ') if input("Repeat the program? (Y/N)").strip().upper() != 'Y': break i need to impliment the code below into the code above. this will allow the program to scramble each word within a string individually instead of all at once counter = 0 text = 'Hello World' split = str.split(text) for str in split: no_name = split[counter] scramble = c[4] + c[0] + c[3] + c[1] + c[2] counter += 1 print (scramble, end=" ") PLEASE NOTE: the variable "text" should allow user input in the final version, above is just an example of the structure
Prevent replacing of single variable expressions in sympy.cse
I want extract and replace common expressions in a set of equations using sympy.cse When I run sympy.cse(eqs) I get the results below. How can I prevent sympy.cse to extract single variables eg. replacing S2_comp3 with -x0. (I have noticed that all these single variables are their negative) result ([(x0, -S2_comp3), (x1, -S_source_comp3), (x2, S_source_total/S1_total), (x3, -S_source_comp1), (x4, -S_source_comp2), (x5, -S_source_comp4), (x6, -S2_comp1), (x7, -S2_comp2)], [S2_comp3*eff_c3 - S6_comp3, S6_comp3 + S9_comp3 + x0, S1_comp3 + S2_comp3 + S3_comp3 + S4_comp3 + x1, S1_comp3*x2 + x1, S1_comp1*x2 + x3, S1_comp2*x2 + x4, S1_comp4*x2 + x5, -S1_comp1 - S1_comp2 - S1_comp3 - S1_comp4 - S1_comp5 + S1_total, S1_comp1 + S2_comp1 + S3_comp1 + S4_comp1 + x3, S2_comp1*eff_c1 - S6_comp1, S6_comp1 + S9_comp1 + x6, S1_comp2 + S2_comp2 + S3_comp2 + S4_comp2 + x4, S2_comp2*eff_c2 - S6_comp2, S6_comp2 + S9_comp2 + x7, S1_comp4 + S2_comp4 + S3_comp4 + S4_comp4 + x5, -S2_comp4 - S2_comp5 + S2_total + x0 + x6 + x7, S1_comp5 + S2_comp5 + S3_comp5 + S4_comp5 - S_source_comp5]) With eqs = [S2_comp3*eff_c3 - S6_comp3, -S2_comp3 + S6_comp3 + S9_comp3, S1_comp3 + S2_comp3 + S3_comp3 + S4_comp3 - S_source_comp3, S1_comp3*S_source_total/S1_total - S_source_comp3, S1_comp1*S_source_total/S1_total - S_source_comp1, S1_comp2*S_source_total/S1_total - S_source_comp2, S1_comp4*S_source_total/S1_total - S_source_comp4, -S1_comp1 - S1_comp2 - S1_comp3 - S1_comp4 - S1_comp5 + S1_total, S1_comp1 + S2_comp1 + S3_comp1 + S4_comp1 - S_source_comp1, S2_comp1*eff_c1 - S6_comp1, -S2_comp1 + S6_comp1 + S9_comp1, S1_comp2 + S2_comp2 + S3_comp2 + S4_comp2 - S_source_comp2, S2_comp2*eff_c2 - S6_comp2, -S2_comp2 + S6_comp2 + S9_comp2, S1_comp4 + S2_comp4 + S3_comp4 + S4_comp4 - S_source_comp4, -S2_comp1 - S2_comp2 - S2_comp3 - S2_comp4 - S2_comp5 + S2_total, S1_comp5 + S2_comp5 + S3_comp5 + S4_comp5 - S_source_comp5] With var = [S6_comp3, S2_comp3, S9_comp1, S2_comp1, S2_comp5, S1_comp1, S2_comp4, S1_comp4, S1_comp2, S9_comp2, S6_comp1, S1_comp3, S1_comp5, S9_comp3, S2_comp2, S6_comp2, S1_total]
For situations like this where the return value is not as you like it, the postprocess option can be used. For example, def noneg(r,e): rv = [] negs = [] for i in range(len(r)): o, n = r[i] if (-n).is_Symbol: for j in range(i + 1, len(r)): oj, nj = r[j] r[j] = oj, nj.subs(o, n) negs.append((o, n)) else: rv.append((o, n)) for o, n in reversed(negs): e = [ei.subs(o, n) for ei in e] return rv, e >>> print filldedent(cse(your_eqs, postprocess=noneg)) ([(x2, 1/S1_total)], [S2_comp3*eff_c3 - S6_comp3, -S2_comp3 + S6_comp3 + S9_comp3, S1_comp3 + S2_comp3 + S3_comp3 + S4_comp3 - S_source_comp3, S1_comp3*S_source_total*x2 - S_source_comp3, S1_comp1*S_source_total*x2 - S_source_comp1, S1_comp2*S_source_total*x2 - S_source_comp2, S1_comp4*S_source_total*x2 - S_source_comp4, -S1_comp1 - S1_comp2 - S1_comp3 - S1_comp4 - S1_comp5 + S1_total, S1_comp1 + S2_comp1 + S3_comp1 + S4_comp1 - S_source_comp1, S2_comp1*eff_c1 - S6_comp1, -S2_comp1 + S6_comp1 + S9_comp1, S1_comp2 + S2_comp2 + S3_comp2 + S4_comp2 - S_source_comp2, S2_comp2*eff_c2 - S6_comp2, -S2_comp2 + S6_comp2 + S9_comp2, S1_comp4 + S2_comp4 + S3_comp4 + S4_comp4 - S_source_comp4, -S2_comp1 - S2_comp2 - S2_comp3 - S2_comp4 - S2_comp5 + S2_total, S1_comp5 + S2_comp5 + S3_comp5 + S4_comp5 - S_source_comp5])
How can I reverse the direction of arrow shown in this jsfiddle http://jsfiddle.net/5qaL886d/1/
I want to display arrow in the reverse directions of this jsfiddle http://jsfiddle.net/5qaL886d/1/ I an not understanding which attributes to change to do so. Thanks in advance..
The arrows in this snippet are drawn "by hand", i.e. the arrow points are calculated manually. So what you need to do is to recalculate them, so that they are located at the different end. Normally, the arrows are supposed to be created using "defs" (it is much easier) but in this case they seem to cause issues with IE10, therefore drawn by hand. Anyways, here is the updated version of the snippet, with arrows "reversed", but without reversing the input data. You just need to change signs here and there: var dx = d.target.x - d.source.x, dy = d.target.y - d.source.y, dr = Math.sqrt(dx * dx + dy * dy), theta = Math.atan2(dy, dx) - Math.PI / 7.85, d90 = Math.PI / 2, dtxs = d.source.x + 6 * Math.cos(theta), dtys = d.source.y + 6 * Math.sin(theta); return "M" + d.source.x + "," + d.source.y + "A" + dr + "," + dr + " 0 0 1," + d.target.x + "," + d.target.y + "A" + dr + "," + dr + " 0 0 0," + d.source.x + "," + d.source.y + "M" + dtxs + "," + dtys + "l" + (3.5 * Math.cos(d90 - theta) + 10 * Math.cos(theta)) + "," + (-3.5 * Math.sin(d90 - theta) + 10 * Math.sin(theta)) + "L" + (dtxs - 3.5 * Math.cos(d90 - theta) + 10 * Math.cos(theta)) + "," + (dtys + 3.5 * Math.sin(d90 - theta) + 10 * Math.sin(theta)) + "z"; http://jsfiddle.net/4kmhugof/1/