Finding X and Y so that is satisfies the expression (XA+YB)/(X+Y) = minimum value but no less than T and 0<=x<=c and 0<=y<=d [closed] - equation

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 days ago.
Improve this question
As the titles says, I need to find X and Y so that it satisfies the expression. Input parameters are a,b,c,d and T, where 1<=a<=T<=b<=10^6 ; 1<=c<=10^6 and 1<=d<=10^6. There are more conditions.
If we find that there are multiple solutions for x and y values, choose the ones where x+y=max.
If there are more than one values again, choose the one where 𝑥 has the maximum value.
I'm having trouble understanding the last sentence. If there are more than one values again, choose the one where 𝑥 has the maximum value.. How can this be true? If we come to the realization that we have multiple x and y solutions, then we go to the condition x+y=max, which simply is x=c and y=d, since that's their respective ranges. How can x+y=max have more than one combination?
Also, I cant think of a way to keep track of a minimum value for the expression and which values of x and y that solution corresponds with. I was thinking of first setting the maxSolutionValue so that I have concrete to compare the solutions with, but I figured I cant possibly know in advance the solution with the maximum result, even if I plug in x=c and y=d, that doesn't mean I will find the maximum value of the expression.
So yeah I have a couple of problems I cant quite wrap my head around. If anyone can think of a solution for this task, or at least an idea that would be greatly appreciated.

Related

Compare two CSVs [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have two CSV . let me name them A and B. A has 70000 approx values with 20 columns and B have 1000 values with 10 columns.
Both share one common column 'ID'. Now I want to search for those 1000 items in A. If they exist in A, I want to get the values/rows of only those items from A. with all 20 columns.
I totally agree with the comment.
Still. In the hope you will edit your question according to "How do I ask a good question?", I will provide an answer so others can be helped as well.
One can use the following formula:
=ArrayFormula(IFERROR(VLOOKUP(OFFSET(F2,,,COUNTA(F2:F)),A2:D,{1,2,3,4},0),))
If you refer to separate spreadsheets, you should use IMPORTRANGE
in place of A2:D
(Please adjust ranges to your needs)
Functions used:
ArrayFormula
IFERROR
VLOOKUP
OFFSET
COUNTA
IMPORTRANGE
In 21st (U) column of file A: =match(ID,fileB!ID:ID,0)
In 22nd (V) columns of file A: =index(fileB!A:A,$U:$U)
In 23rd-41st columns of file A: copy formula from column (V)
Still, an example would help everyone!

How can I write a query to get the result I want? [closed]

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 3 years ago.
Improve this question
I could use some help writing an IIF statement in a query. I have done a lot of research on IIF statements and know their basic syntax and structure. But all of the examples I could find on the internet were very basic and pretty straight forward, and I need mine to be a little more complex.
I have two tables in MS Access 2010. One is called "ProductMasterData" and the other is "DateCodes." Every record in the ProductMasterData table has a field called "CartonDateFormat" that contains a number 1-36. Every record in the DateCodes table has a field called "OutputDateCode." What I would like for my IIF statement to say is that if CartonDateCode= 1, then return the OutputDateCode from row 1. If CartonDateCode is not equal to 1, then do nothing. I want to write similar IIF statements that will do the same thing for numbers 2-36. I have an idea of what the statements should look like, but it's fuzzy and I could use a little help. I am thinking that it should look something like this:
IIF(CartonDateFormat=1, I don't know what to put here, Nothing)
I'm not sure how to phrase what to do if the first part of the statement equates to true. This is my first query, so I would really appreciate any help anyone could give me. Thanks!
Depending on your needs maybe you should better join the 2 tables.
If you just need these IIF() statements you can do this:
IIF(
CartonDateFormat = 1,
(SELECT OutputDateCode FROM DateCodes WHERE ID = 1),
NULL
)
I assume there is a column like ID in the table DateCodes which stores these codes that the values in CartonDateFormat correspond to.
But even without IIF() if you simply use:
SELECT OutputDateCode FROM DateCodes WHERE ID = 1
the result will be the same:
-If the id is found then the OutputDateCode will be returned.
-If not then NULL will be returned.

displays all data with certain field types, from the results of the query [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
displays all data with certain field types, from the results of the query ...
I do queries in three tables, and only show data that has relations only, whereas I want to display everything even though there is no relation ...
the data that I have
I want to display the data as below
You need to use left join in this case
select a.position,c.nama from posisi a,kanaikan_posisi b,bana c
where a.id_position = b.id_position (+) and c.id_karyavan (+) = b.id_karyavan
order by a.id_position

Using SELECT * FROM table [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I understand that using a SELECT * FROM table is considered a bad practice. One reason behind this is that you are select ALL columns from the table , and in case a the table is modified in future and there are extra columns added, you will be fetching those too, and perhaps will not need those.
Assuming that at the time of writing the SELECT * , first time, there indeed was a need to select all columns.
My Question is : Is there any other reason why it might be a bad practice ?
First thing that comes to my mind is the projection the Wikipedia covers that part pretty nice. And in DBA website you have a nice question about it.
You not only miss control over the columns you will present, you also miss the control over the order of the columns. By specifying them you get to have the full control over the resultset + you optimize its size by the elements you really need.
To answer your question, you also miss the possibility to control the location of each column.
SELECT * FROM table; # it would depend of the table internal order
['Surname','Office','Name','Irrelevant']
SELECT Name,Surname,Office FROM table; # you decide which column to show the element
['Name','Surname','Office']
Another reason could be the bandwith consumed : if you only need one or two informations, it is useless to get all the informations.
The application which receives the data is also slower because it has to get a large amount of data whereas it only need a few.

Is an argument of zero a good option to allow user to say they want all results? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have a function that will allow user to return a set of results. For the purpose of this discussion, assume it is returning a sequence of objects. I want to provide a facility for the caller to limit the number of objects returned.
In python:
def get_records(max=0):
# snipped ..
The max parameter will limit the number of records returned. If it is zero, I will return all. Is this good API design ?
As long as behaviour is documented, you can use any value you want, provided it's outside the scope of what people would consider a "normal" parameter. By that I mean you would not use 2 as the special value if clients of your code would ever want two things returned.
So, provided there's not a valid use case for returning zero things (a), then zero is as good a value as any to indicate "all items".
(a) You may have a valid use case where there are side-effects in calling the function. An example is an arbitrary list where you call getFirst(n) on it and that first sorts the list then returns the first n items.
Clients may wish to call your code with getFirst(0) to just sort the list without getting any values.
Of course, I'd implement a totally separate function for that myself so this is a slightly contrived example but it hopefully illustrates the point I'm trying to get across.
If the language supports overloading, then I would use an overload without the max parameter to indicate that all rows were requested. Alternatively, given nullable values and default values, I might use a single method with a nullable integer parameter with a default value of null.
In C#:
public IEnumerable<Record> GetRecords(int? maximumRecords = null);