What is the AND statement for HTCondor HPC? - hpc

It seems this HPC is hard to google docs. How does one write an AND statement for it? e.g. for OR one does:
requirements = (CUDADeviceName == "Quadro RTX 6000") || (CUDADeviceName == "NVIDIA A40")
would:
requirements = (CUDADeviceName != "Tesla K40m") /\ (CUDADeviceName == "NVIDIA A40")
work? What I want is NOT tesla k40m and NOT A40. Anything else is fine.
Gives error:
(metalearning_gpu) miranda9~/diversity-for-predictive-success-of-meta-learning $ condor_submit job.sub
Submitting job(s)ERROR: Parse error in expression:
Requirements = ((CUDADeviceName != "Tesla K40m") /\ (CUDADeviceName != "NVIDIA A40")) && (TARGET.Arch == "X86_64") && (TARGET.OpSys == "LINUX") && (TARGET.Disk >= RequestDisk) && (TARGET.Memory >= RequestMemory) && (TARGET.Cpus >= RequestCpus) && (TARGET.gpus >= Requestgpus) && ((TARGET.FileSystemDomain == MY.FileSystemDomain) || (TARGET.HasFileTransfer))

For an AND/conjuction this seems to work:
requirements = (CUDADeviceName != "Tesla K40m") && (CUDADeviceName != "NVIDIA A40")

Yes, you want && for conjunction.
For a complete tutorial of the classad expression language, see the manual section at https://htcondor.readthedocs.io/en/latest/classads/index.html
Or, there's a YouTube tutorial about the expression language at
https://www.youtube.com/watch?v=Y8aHj8q56ik

Related

How to "Print when" with condition

I have a question, I have a subreport that prints many lines because it is in the detail band, for me this is fine, but I want to filter the rows based on parameters when I print the report, I used the option "print when" to set the Boolean condition but not it works, this works with only one parameter.
The condition is:
(!"N".equals($P{Chk_Amministratori})
|| ($F{field1} != $P{CheckDinamico1}
|| $F{field1} != $P{CheckDinamico2}
|| $F{field1} != $P{CheckDinamico3}
|| $F{field1} != $P{CheckDinamico4}
|| $F{field1} != $P{CheckDinamico5}
|| $F{field1} != $P{CheckDinamico6}
|| $F{field1} != $P{CheckDinamico7}
|| $F{field1} != $P{CheckDinamico8}
|| $F{field1} != $P{CheckDinamico10}) ? Boolean.TRUE : Boolean.FALSE
If I put a parameter it works, for example
$F{field1} != $P{CheckDinamico10} ? Boolean.TRUE : Boolean.FALSE
Can anyone help me?
The logic in your expressions is flawed. You have this
$F{field1} != $P{CheckDinamico1}
|| $F{field1} != $P{CheckDinamico2}
|| ...
Let's say CheckDinamico1 is 5 and CheckDinamico2 is 7. So your expressions is field1 != 5 OR field1 != 7 OR ..
This expression is true whatever the value of field1. If field1 is 3, it will be different from both 5 and 7, so the expression is true. If fiedl1 is 5, it will be different from 7, and because of OR the expression will also be true. And if field1 is 7, it will be different from 5 so again the expression is true.
Maybe you wanted AND instead of OR in the expression? Also, as Alex K noted, != might not always work so it's safer to use equals, and you can use primitive boolean expressions, you don't need Boolean. Therefore try something like this:
(!"N".equals($P{Chk_Amministratori})
|| (!$F{field1}.equals($P{CheckDinamico1})
&& !$F{field1}.equals($P{CheckDinamico2})
&& !$F{field1}.equals($P{CheckDinamico3})
&& !$F{field1}.equals($P{CheckDinamico4})
&& !$F{field1}.equals($P{CheckDinamico5})
&& !$F{field1}.equals($P{CheckDinamico6})
&& !$F{field1}.equals($P{CheckDinamico7})
&& !$F{field1}.equals($P{CheckDinamico8})
&& !$F{field1}.equals($P{CheckDinamico10}))

Long and detailed AND,OR conditional IF statements on MATLAB

Could you please tell me what my mistake is on the following code:
if ((i>156-9 && i<156+9) && (j>406-9 && j<406+9)) || ((i>684-11 && i<684+11) && (j>274-11 && j<274+11)) || ((i>1066-15 && i<1066+15) && (j>67-15 && j<67+15)) || ((i>1559-15 && i<1559+15) && (j>867-15 && j<867+15)) || ((i>1082-18 && i<1082+18) && (j>740-18 && j<740+18))
plot(j, i, 'r+', 'MarkerSize', 7, 'LineWidth', 5);
end
I'd like to use an if statement which obeys to get in the expression if one of these conditions are fulfilled:
((i>156-9 && i<156+9) && (j>406-9 && j<406+9)) OR
((i>684-11 && i<684+11) && (j>274-11 && j<274+11)) OR
((i>1066-15 && i<1066+15) && (j>67-15 && j<67+15)) OR
((i>1559-15 && i<1559+15) && (j>867-15 && j<867+15)) OR
((i>1082-18 && i<1082+18) && (j>740-18 && j<740+18))
Thanks in advance...
Regards.
I have used your expression in the if as is and used this for this little piece of code.
clc; A=[];
for i=1:2000
for j=1:2000
if ((i>156-9 && i<156+9) && (j>406-9 && j<406+9)) || ((i>684-11 && i<684+11) && (j>274-11 && j<274+11)) || ((i>1066-15 && i<1066+15) && (j>67-15 && j<67+15)) || ((i>1559-15 && i<1559+15) && (j>867-15 && j<867+15)) || ((i>1082-18 && i<1082+18) && (j>740-18 && j<740+18))
A = [A, num2str(i),' ',num2str(j), char(10)];
end
end
end
display(A);
It works for me.

Formatting of new line indentation of if conditions in Eclipse CDT

In Eclipse (4.4) CDT (8.5) on windows (7) the indentation of new lines within if and else if conditions does not make sense to me. Where in eclipse is this set?
I have tried looking in Window > Preferences > C/C++ > Code Style > Formatter but could not see any relevant setting.
An example where I hit the return key as I type the conditions or select the lines and press Ctrl+I ("Fix Indentation"). Note that the first four lines all have the same indentation despite differing levels of nesting. The following fifth line indents two more levels than the preceding line, as does the seventh line both with no apparent relation to the level of nesting.
else if (((wp == SMB_Protocol_Write_Byte) && (qcn >= 1)
&& (rp != SMB_Protocol_Process_Call)
&& (rp != SMB_Protocol_Block_WR))
|| ((wp == SMB_Protocol_Write_Word) && (qcn >=2)
&& (rp != SMB_Protocol_Block_WR))
|| ((wp == SMB_Protocol_Block_Write)
&& (qcn >= (CMD_Number_Bytes_max + 1)))) {
e = EXIT_FAILURE;
}
I would prefer something along the lines of the following:
else if (((wp == SMB_Protocol_Write_Byte) && (qcn >= 1)
&& (rp != SMB_Protocol_Process_Call)
&& (rp != SMB_Protocol_Block_WR))
|| ((wp == SMB_Protocol_Write_Word) && (qcn >=2)
&& (rp != SMB_Protocol_Block_WR))
|| ((wp == SMB_Protocol_Block_Write)
&& (qcn >= (CMD_Number_Bytes_max + 1)))) {
e = EXIT_FAILURE;
}
Is it possible to change this?
Also if someone could comment with an explanation of the current indentation/nesting formatting it would be appreciated!
EDIT: Realised this may be similar to Eclipse JDT Code Formatter: Indent parameter in IF-Statement
Is it possible to change this?
Yes. With the default indentation strategy (K&R built-in) I get the same as you with Ctrl+I, but if I do Ctrl+Shift+F (format code) I get the following.
} else if (((wp == SMB_Protocol_Write_Byte) && (qcn >= 1)
&& (rp != SMB_Protocol_Process_Call)
&& (rp != SMB_Protocol_Block_WR))
|| ((wp == SMB_Protocol_Write_Word) && (qcn >= 2)
&& (rp != SMB_Protocol_Block_WR))
|| ((wp == SMB_Protocol_Block_Write)
&& (qcn >= (CMD_Number_Bytes_max + 1)))) {
If you want to get column alignment, rather than simple indentation on continued lines, create your own formatting profile and change the following:
Indentation tab -> Tab policy to either Spaces only or Mixed
With the default of Tabs only the indents will be to the next tab stop
Line Wrapping tab -> Expressions/Binary Expressions set Indentation policy to Indent on column
This is what you end up with when you format (but not when you simply correct indentation):
} else if (((wp == SMB_Protocol_Write_Byte) && (qcn >= 1)
&& (rp != SMB_Protocol_Process_Call)
&& (rp != SMB_Protocol_Block_WR))
|| ((wp == SMB_Protocol_Write_Word) && (qcn >= 2)
&& (rp != SMB_Protocol_Block_WR))
|| ((wp == SMB_Protocol_Block_Write) && (qcn
>= (CMD_Number_Bytes_max + 1)))) {
Here are screenshots showing the settings:
and

Last elseif statement does not execute

My last elseif statement does not execute even if the conditions are met:
Currency_Exchanage != 'Select...' and all other variables (ETF_Exchanage, Index_Exchanage and Stock_Exchanage) = 'Select...'
Here is the section of code that I am concerned about:
if (strcmp(ETF_Exchanage,'Select...') == 1) && (strcmp(Stock_Exchanage,'Select...') == 1) && (strcmp(Index_Exchanage,'Select...') == 1)...
(strcmp(Currency_Exchanage,'Select...') == 1)
if db == 1 && uni == 1
tickers = gnr_bloomberg; % Analsise Bloomberg natural resources
nrm=1;
elseif db == 1 && uni == 2
tickers = all_bloomberg; % Analsise Bloomberg all
nrm=1;
elseif db == 2 && uni == 1
tickers = gnr_yahoo; % Analsise Yahoo natural resources
nrm=1;
elseif db == 2 && uni == 2
tickers = all_yahoo; % Analsise Yahoo all
nrm=1;
end
else
%Yahoo inputs
if (strcmp(ETF_Exchanage,'Select...') == 0) && (strcmp(Stock_Exchanage,'Select...') == 1) && (strcmp(Index_Exchanage,'Select...') == 1)...
(strcmp(Currency_Exchanage,'Select...') == 1); %Choose exhanges from ETF
tickers = ETF_Yahoo(:,1);
Exchanges = ETF_Yahoo(:,2);
Exchange = ETF_Exchanage;
db=2; %Yahoo Selection
elseif (strcmp(Index_Exchanage,'Select...') == 0) && (strcmp(Stock_Exchanage,'Select...') == 1) && (strcmp(ETF_Exchanage,'Select...') == 1)...
(strcmp(Currency_Exchanage,'Select...') == 1); %Choose exhanges from Index
tickers = Index_Yahoo(:,1);
Exchanges = Index_Yahoo(:,2);
Exchange = Index_Exchanage;
db=2;
elseif (strcmp(Stock_Exchanage,'Select...') == 0) && (strcmp(ETF_Exchanage,'Select...') == 1) && (strcmp(Index_Exchanage,'Select...') == 1)...
(strcmp(Currency_Exchanage,'Select...') == 1); %Choose exhanges from Stock
tickers = Stock_Yahoo(:,1);
Exchanges = Stock_Yahoo(:,2);
Exchange = Stock_Exchanage;
db=2;
elseif (strcmp(Currency_Exchanage,'Select...') == 0) && (strcmp(Stock_Exchanage,'Select...') == 1) && (strcmp(Index_Exchanage,'Select...') == 1)...
(strcmp(ETF_Exchanage,'Select...') == 1); %Choose exhanges from Currency
tickers = Currency_Yahoo(:,1);
Exchanges = Currency_Yahoo(:,2);
Exchange = Currency_Exchanage;
db=2;
else
msg = 'Error occurred.\Only one Yahoo input menue must be used!';
error(msg)
end
end
Any Help would be much appropriated, I can't see where I'm going wrong here. I am using Matlab 2013a.
Put a breakpoint at the elseif statement in question and then check in the command window what your condition evaluates to.
If it does not evaluate like expected, check what the individual terms evaluate to.
It is important to actually test what the conditions evaluate to in matlab, rather than only visually comparing the string values.
Usually by that point you should get a rough idea what is wrong.
However in your case we can't do these steps for you because something is off. Your code condensed to the more reasonable minimal example
if 1 && 1 && 1...
1;
disp('I was here')
end
does not even execute in R2014a since the interpreter complains about '...' being an unexpected matlab expression.

How do I add a condition to an existing conditional expression?

I had a programmer write a Perl script for my site.
One of the functions is to update price/stock when a certain condition is met.
# update when price/stock conditions met
if ( ($force_price_updates == 1) ||
($data->{'price'} <= $product_price && $data->{'quantity'} > 0) ||
($product_quantity == 0 && $data->{'quantity'} > 0) ) {
What the above is not doing is not updating the price if the new price is higher. It updates the stock value, but if the new stock comes at a higher price, I lose out. Stock gets updated and but the price is not.
The script goes through a number of feeds and if the same product is found in any of the feeds, the script should amend price/stock change according to the rule above.
I can't find the programmer and my Perl knowledge is limited. I understand what the code is doing, but don't know what it should do if the price is higher and stock is greater than zero.
You can add the extra condition you're looking for to that statement.
The condition you're looking to match is:
$data->{'price'} > $product_price && $product_quantity > 0
So the final version would look like this:
if (($force_price_updates == 1) || ($data->{'price'} <= $product_price && $data->{'quantity'} > 0) || ($product_quantity == 0 && $data->{'quantity'} > 0) || ($data->{'price'} > $product_price && $product_quantity > 0)) {