|
If you have problems in your code then please edit your question above, and add complete details of what is not working.
|
|
|
|
|
Very few people are going to follow a link to an offsite google drive. Post the relevant code here in your post and give full details of the error, including which line it is thrown from
|
|
|
|
|
i am trying develop an algorithm to solve a Travelling Salesman Problem similar case where the goal is to find the best route with the highest attractiveness score (sum of scores for all visited sites/nodes) within a fixed time frame.
to illustrate this more:
a tourist wants to visit N attraction sites in a city and he only has 8 hours to visit as many attraction sites as possible. every site has an attractiveness score and the time spent to visit it.
example:
- site A with ID 0 has an attractiveness score of 90 and requires 10 minutes to visit it ([0, 90, 10])
- site B with ID 1 has an attractiveness score of 69 and requires 7 minutes to visit it ([1, 69, 7])
- site C with ID 2 has an attractiveness score of 72 and requires 7 minutes to visit it ([2, 72, 11])
- site D with ID 3 has an attractiveness score of 116 and requires 16 minutes to visit it ([3, 116, 16])
.
.
.
and so on.
Now we have a time matrix T where T[i][j] represents the necessary time to go from site i to site j. finally we consider site 0 as both the start site and the end site, i.e. the tourist starts his journey at site 0 and returns to site 0 (a hotel for instance).
so the task is to find an itinerary for the tourist to visit as many attractions as possible with a maximum sum score of attractiveness.
example of T matrix for sites A,B,C and D (it could be 50 sites):
T = [0, 40, 35, 90]
[30, 0, 25, 130]
[67, 83, 0, 75]
[45, 79, 130, 0]
The TSP has been solved using different algorithms or methods but i am stuck with this one as it's a little bit different in the sense that the goal is to find the maximum attractiveness score for an itinerary within a time frame, and not the shortest route.
your help is much appreciated
I thought of methods like greedy algorithm, dynamic programming used in TSP but couldn't find a way to solve this particular problem.
|
|
|
|
|
Hi. Is there a build-in function like in C# to scroll the child into viewport of ScrollPane ?
If not, how to achieve that using setVvalue() method of ScrollPane ?
I use below method to scroll, but it scrolls every control to the top of the viewport, but I want to scroll controls which are in the bottom of viewport to the bottom.
Bounds bounds = scrollPane.getViewportBounds();
scrollPane.setVvalue(flowPane.getChildren().get(3).getLayoutY() * (1/(flowPane.getHeight()-bounds.getHeight())));
|
|
|
|
|
Be careful of integer arithmetic.
1/(anything except 1) will yield 0.
Use more intermediate variables with precise names to help you via debugger.
|
|
|
|
|
I am trying to find the path of resource using Paths like below and then copying some files at runtime. While at runtime it works perfectly fine. However while running locally for junit testing, it throws below error at the below first line while trying to get Path using URI. I am not using any zip/jar file so why I am getting the below stack trace. Am I missing something?
Path path= Paths.get(ABCD.class.resource("/").toURI());
String mockFileName="cacerts";
File mockFile= new File(path+File.seperator+mockfileName);
Error
java.nio.file.FileSystemNotFoundException
at com.sun.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:171)
at com.sun.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:157)
at java.nio.file.Paths.get(Unknown Source)
|
|
|
|
|
The message is clear, the path it is trying to access does not exist. You need to use the debugger to find out exactly what paths it is trying to find. That is the only way to discover what causes the problem.
|
|
|
|
|
saurabh jasmeen mehta wrote: Path path= Paths.get(ABCD.class.resource("/").toURI());
Presumably in your test code.
Modify your test code to collect that path first, as a string, then wrap that line in a try/catch and if the exception occurs throw an exception which includes that name.
saurabh jasmeen mehta wrote: ABCD.class.resource("/")
You might also want to just create some local code to test exactly what that means. I did that years ago and the way it does that is not simple.
|
|
|
|
|
Q1. Write a program using methods to find whether a point (x1,y1) lies on a circle of radius 2 cm and h = 5; the equation of circle is given by 〖(x-h)〗^2+〖(y-h)〗^2=r^2 . The method returns a Boolean value.
|
|
|
|
|
You have all the necessary information in the question, so you need to show us what you have written and where you are stuck. We are not going to write your assignment for you.
|
|
|
|
|
[httpGet]
public string ApplyGroupOperation (string values , string op)
{
string[]valueList = values.Split(Values , ',');
var result=0;
for (int i=0 ; i<valuelist.count ;="" i++)
switch(op)
{
case"+":
result+="int.parse(ValueList[i]);
break;
case"*":
result*=int.parse(ValueList[i]);
break;
default:
break;
}
}
return" result;
}
<pre="">
|
|
|
|
|
You forgot to ask a question.
|
|
|
|
|
There is somthing wrong in this code , i need to know it
|
|
|
|
|
Then you need to explain what it is and where it occurs. We cannot guess what you see on your screen.
|
|
|
|
|
I get the feeling this is a "find the bug(s)" assignment.
|
|
|
|
|
|
How to find the answer.
Review your notes for class.
Review reading material
Look at the code
Determine where the errors (plural) are
Write that down.
|
|
|
|
|
write a recursive function which takes 2 input parameters. The first is an employee id and the second is another employee id. We need this function to check if the second Employee is one of the direct or indirect managers, it must return true if the second employee is one of the reporting line for the first employee, otherwise it will return false
Employee
Emp Id int primary key,
Name varchar(50) not null,
Manager int references Employee (Emp_ld),
JobTitle int references JobTitle(JTId)
|
|
|
|
|
You first have to figure out who's "at the top"; then you can recurse down the "tree": That would be the "one" with NO "Manager" (everyone else MUST have one). If you have more than one without a manager, then you have a leadership problem.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
is this pseudo code ok ?
bool check (emp-id1 , emp-id2)
if {(emp-id2 == emp-id1.Manager)
return true;}
else if {(emp-id1.Manager == Null)
return false;}
else {
return (emp-id1.manager , emp-id2)}
|
|
|
|
|
I am new to Java but I have worked on the Microsoft product stack. Is there a "make" and/or "project" file equivalent in Java and is there such a project file that is only associated with whichever IDE I am using?
|
|
|
|
|
Which IDE are you using? Both Eclipse and Netbeans have their own build systems. If you are not using an IDE then you could write your own Makefiles, and use nmake or similar.
[edit]
You already asked this question at What is the equivalent project file for a java project?[^], and we still have no idea which IDE you are using. If you want help then please provide full details of the problem.
[/edit]
modified 13-Oct-22 4:14am.
|
|
|
|
|
Wap in java to display this pattern
I
C
S
E
|
|
|
|
|
OK, I have done that. Now what?
|
|
|
|
|
I don't know the solution
modified 24-Sep-22 16:11pm.
|
|
|
|