degmintoradians( degmin( Degrees, Minutes ), radians ) :-
print('test2'),
radians is ((Degrees + Minutes) / 60) * (pi / 180).
distance( Airport1, Airport2, DistanceMiles ) :-
airport( Airport1, _, Latitude1, Longitude1 ),
airport( Airport2, _, Latitude2, Longitude2 ),
print('test1'),
degmintoradians( Latitude1, latrads1 ),
.....
What I'm trying to do is pretty simple, just pass "Latitude1" and "longitude1" into degmintoradians. The print cases are tests, when running the full code, "test1" is printed, however "test2" is not. I can't seem to figure out why, I think I'm doing everything right.
In case it helps, airports are stored in a database like this:
airport( atl, 'Atlanta ', degmin( 33,39 ), degmin( 84,25 ) ).
Thanks.
Related
I am running multiple data analysis scripts with are often oneway analyses or t-tests.
I have written or generated many of these myself but I have run into a recurring problem.
I will often generate the code while on one data table and then when I paste it to another data table with the same headings the script replaces single or multiple variables with "As Column()"
So if I have this:
Oneway(
Y( :"parameter 1" ),
X( :"parameter 2" ),
Each Pair( 1 ),
Means( 1 ),
Mean Diamonds( 1 ),
SendToReport(
Dispatch( {}, "Oneway Anova", OutlineBox, {Close( 1 )} ),
Dispatch(
{"Means Comparisons", "Comparisons for each pair using Student's t"},
"LSD Threshold Matrix",
OutlineBox,
{Close( 1 )}
),
Dispatch(
{"Means Comparisons", "Comparisons for each pair using Student's t"},
"Connecting Letters Report",
OutlineBox,
{Close( 1 )}
)
)
)
I end up with this non-functioning code after pasting it
Oneway(
Y( :"parameter 1" ),
X( As Column() ),
Each Pair( 1 ),
Means( 1 ),
Mean Diamonds( 1 ),
SendToReport(
Dispatch( {}, "Oneway Anova", OutlineBox, {Close( 1 )} ),
Dispatch(
{"Means Comparisons", "Comparisons for each pair using Student's t"},
"LSD Threshold Matrix",
OutlineBox,
{Close( 1 )}
),
Dispatch(
{"Means Comparisons", "Comparisons for each pair using Student's t"},
"Connecting Letters Report",
OutlineBox,
{Close( 1 )}
)
)
)
Another issue that happens is the original working code will sometimes not open correctly when run directly but it will work if I click edit and can see the code.
Is there something I am doing incorrectly? I am running JMP 15.0.0
TLDR: I tried to paste code from one data table to another with the same headings. I expected it to work but it broke in an unexpected way.
I have Power BI DAX query used in a measure. It takes longer time to execute. Can anyone please help me with this?
MEASURE FACT_CONSOL_BALANCE_OL[Measure 4] =
SWITCH (
TRUE (),
CONTAINS (
DIM_ANALYTIC_STRUCT_ACCOUNT,
DIM_ANALYTIC_STRUCT_ACCOUNT[STRUCTURE_NODE (groups)], "1 - CURRENT ASSETS"
), SUM ( FACT_CONSOL_BALANCE_OL[BALANCE] ),
CONTAINS (
DIM_ANALYTIC_STRUCT_ACCOUNT,
DIM_ANALYTIC_STRUCT_ACCOUNT[STRUCTURE_NODE (groups)], "2 - NON - CURRENT ASSETS"
), SUM ( FACT_CONSOL_BALANCE_OL[BALANCE] ),
SUM ( FACT_CONSOL_BALANCE_OL[BALANCE] ) * -1
)
Performance Result on DAX Studio:
Can you please try this code, see if It solves your problem. I tried to write it without contains() function.
MEASURE FACT_CONSOL_BALANCE_OL[Measure 4] =
SUMX (
FACT_CONSOL_BALANCE_OL,
VAR Balance =
SWITCH (
RELATED ( DIM_ANALYTIC_STRUCT_ACCOUNT[STRUCTURE_NODE (groups)] ),
"1 - CURRENT ASSETS", FACT_CONSOL_BALANCE_OL[BALANCE],
"2 - NON - CURRENT ASSETS", FACT_CONSOL_BALANCE_OL[BALANCE],
FACT_CONSOL_BALANCE_OL[BALANCE] * -1
)
RETURN
Balance
)
I need to estimate four parameters using winbugs: tau[i], mu1[i],mu2[i]and tau0[i].
When I click check the model, it shows expected right parenthesis between tau0* and (t[j+1]-t[j]) in the 4th line.
When I delete the (t[j+1]-t[j]), it shows the same expected right parenthesis between c and <-(1-step( tau[i]-t[j]))
model
{
#likelihood
for(i in 1:n){
for(j in 1:m){
x[i,j]~ dnorm( mu[i,j], tau0*(t[j+1]-t[j]))
mu[i,j]<- mu1*(t[j+1]-t[j])*a+mu1*(tau[i]-t[j])*b+mu2*(t[j+1]-tau[i])*b+mu2*(t[j+1]-t[j])*c
sigma <-1/sqrt(tau0)
a<-step( tau[i]-t[ j+1] )
b<-(step(tau[i]- t[j])-(step(tau[i]- t[j+1]))
c<-(1-step( tau[i]-t[j]))
}
#prior
tau[i]~dnorm(mutau,tautau)
mutau~dorm(0, 0.001)
tautau~dgamma(0.01, 0.01)
sigmatau<-1/sqrt(tautau)
mu1[i]~dnorm(mumu1, tau1)
mumu1~dorm(0, 0.001)
tau1~dgamma(0.01,0.01)
sigmatau1<-1/sqrt(tau1)
mu2[i]~dnorm(mumu2, tau2)
mumu2~dorm(0, 0.001)
tau2~dgamma(0.01,0.01)
sigmatau2<-1/sqrt(tau2)
tau0[i]~dgamma(alpha,beta)
sigmatau0<-1/tau0
}
}
DATA
list(n=5, m=16, mutau=0, tautau=1, mumu1=0, tau1=1, mumu2=0, tau2=1, alpha=0.01, beta=0.01 )
I expected the right model syntax
b<-(step(tau[i]- t[j])-(step(tau[i]- t[j+1]))
(
step(
tau[i]- t[j]
)
-
(
step(
tau[i]- t[j+1]
)
)
4 brackets opening, 3 brackets closing.
First bracket is not closed.
How to convert atom '2015-12-15T05 PST' to timestamp or datetime?
I've tried parse_time/3
?- parse_time('2015-12-15T05 PST', '%Y-%m-%dT%H %Z', Stamp)
false.
and format_time/3
?- format_time('2015-12-15T05 PST', '%Y-%m-%dT%H %Z', date(Y,M,D,H,M,S,O,TZ,DST)).
ERROR: format_time/3: Arguments are not sufficiently instantiated
According to the documentation, the mode of format_time/3 can't really help you, because it's expecting everything to be passed in:
format_time(+Out, +Format, +StampOrDateTime)
This means you supply each of the arguments. You want to see something with a - prefix which means it's handing something back, which seems like it would mean parse_time/3, but there the documentation says:
Supported formats for Text are in the table below.
and it then proceeds to list exactly two options, rfc_1123 and iso_8601, neither of which really match your format. There does not seem to be a way to supply a format code here, which I find really puzzling, because there are underlying Unix libraries here that can certainly do this.
However, the problem can be solved with everyone's favorite tool: definite clause grammars! Here's my solution:
:- use_module(library(dcg/basics)).
myformat(date(Y,M,D,H,_,_,_,TZ,_)) -->
integer(Y), "-", integer(M), "-", integer(D),
"T", integer(H), " ", timezone(TZ).
timezone('UTC') --> "UTC".
timezone('UTC') --> "GMT".
timezone(-18000) --> "PST".
timezone(Secs) -->
[Sign], digit(H0), digit(H1), digit(M0), digit(M1),
{
(Sign = 0'+ ; Sign = 0'-),
number_codes(Hour, [H0,H1]),
number_codes(Minutes, [M0, M1]),
(Sign = 0'+
-> Secs is Hour * 3600 + Minutes * 60
; Secs is -(Hour * 3600 + Minutes * 60))
}.
my_time_parse(Atom, Date) :-
atom_codes(Atom, Codes),
phrase(myformat(Date), Codes).
I'm sure the learned will see ways to improve this code but it did the trick for me with your sample data. You will unfortunately need to either enumerate timezones or find a better source of data on them (perhaps parsing the system timezone definitions?) but if you know a-priori that you only need to handle PST, you can try it. Here's an example:
?- my_time_parse('2015-12-15T05 PST', Date).
Date = date(2015, 12, 15, 5, _G3204, _G3205, _G3206, -18000, _G3208) ;
false.
Hope this helps!
Coming late to this question: the desired format is close to iso_8601, which would take the format "2015-12-15T05-08". To replace the time zone " PST" with "-08", we can use append. For code:
:- set_prolog_flag(double_quotes, chars).
timezone(" PST", "-08").
timezone(" PDT", "-07").
%% etc
convert_time(Date, Stamp) :-
timezone(Zone, Delta),
append(Front, Zone, Date),
append(Front, Delta, Date2),
string_chars(Date3, Date2),
parse_time(Date3, iso_8601, Stamp).
test :-
convert_time("2015-12-15T05 PST", Stamp),
writeln('Stamp'=Stamp),
fail.
with output
?- test.
Stamp=1450184400.0
false.
I create hidden IWebBrowser2 object and it work's fine but after few seconds I want to
change visibility to true and my application crashes.
pBrowser2->put_Visible(VARIANT_TRUE);
What I'm doing wrong ?
You're using pBrowser2 after releasing it.
You have:
pBrowser2->Release(); // pBrowser NOW INVALID!!!
srand( time( NULL ) );
//Sleep( ( std::rand() % 5000 ) + 5000 );
if(std::rand() % 100 <= chance ){
pBrowser2->put_Visible(VARIANT_TRUE); // instant crash here!
}
Move the call to Release() after you're done using it, or use a COM smart pointer so you don't have to manage it yourself. Simplest fix:
srand( time( NULL ) );
//Sleep( ( std::rand() % 5000 ) + 5000 );
if(std::rand() % 100 <= chance ){
pBrowser2->put_Visible(VARIANT_TRUE); // works
}
pBrowser2->Release(); // pBrowser NOW INVALID!!!